Skip to content

Commit

Permalink
fixes for win32
Browse files Browse the repository at this point in the history
  • Loading branch information
cruppstahl committed Nov 29, 2011
1 parent ea034ae commit 58173a4
Show file tree
Hide file tree
Showing 42 changed files with 731 additions and 983 deletions.
536 changes: 264 additions & 272 deletions src/backend.h

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions src/blob.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@
#define HAM_BLOB_H__ #define HAM_BLOB_H__


#include "internal_fwd_decl.h" #include "internal_fwd_decl.h"

#include "endianswap.h" #include "endianswap.h"



#ifdef __cplusplus
extern "C" {
#endif

#include "packstart.h" #include "packstart.h"


/** /**
Expand Down Expand Up @@ -272,8 +266,4 @@ blob_duplicate_get_table(ham_env_t *env, ham_offset_t table_id,
dupe_table_t **ptable, ham_bool_t *needs_free); dupe_table_t **ptable, ham_bool_t *needs_free);




#ifdef __cplusplus
} // extern "C"
#endif

#endif /* HAM_BLOB_H__ */ #endif /* HAM_BLOB_H__ */
8 changes: 0 additions & 8 deletions src/btree.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
#include "db.h" #include "db.h"




#ifdef __cplusplus
extern "C" {
#endif

/** /**
* the backend structure for a b+tree * the backend structure for a b+tree
* *
Expand Down Expand Up @@ -404,8 +400,4 @@ btree_copy_key_int2pub(Database *db, const btree_key_t *source,
ham_key_t *dest); ham_key_t *dest);




#ifdef __cplusplus
} // extern "C"
#endif

#endif /* HAM_BTREE_H__ */ #endif /* HAM_BTREE_H__ */
8 changes: 0 additions & 8 deletions src/btree_cursor.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
#include "blob.h" #include "blob.h"




#ifdef __cplusplus
extern "C" {
#endif

/** /**
* the Cursor structure for a b+tree cursor * the Cursor structure for a b+tree cursor
*/ */
Expand Down Expand Up @@ -283,8 +279,4 @@ extern void
btree_cursor_close(btree_cursor_t *cursor); btree_cursor_close(btree_cursor_t *cursor);




#ifdef __cplusplus
} // extern "C"
#endif

#endif /* HAM_BTREE_CURSORS_H__ */ #endif /* HAM_BTREE_CURSORS_H__ */
8 changes: 0 additions & 8 deletions src/btree_key.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
#include "internal_fwd_decl.h" #include "internal_fwd_decl.h"




#ifdef __cplusplus
extern "C" {
#endif

#include "packstart.h" #include "packstart.h"


/** /**
Expand Down Expand Up @@ -182,8 +178,4 @@ key_erase_record(Database *db, btree_key_t *key,
ham_size_t dupe_id, ham_u32_t flags); ham_size_t dupe_id, ham_u32_t flags);




#ifdef __cplusplus
} // extern "C"
#endif

#endif /* HAM_KEY_H__ */ #endif /* HAM_KEY_H__ */
8 changes: 0 additions & 8 deletions src/btree_stats.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
#include "internal_fwd_decl.h" #include "internal_fwd_decl.h"




#ifdef __cplusplus
extern "C" {
#endif

/** /**
* get a reference to the statistics data of the given operation * get a reference to the statistics data of the given operation
*/ */
Expand Down Expand Up @@ -212,8 +208,4 @@ btree_stats_fill_ham_statistics_t(ham_env_t *env, Database *db,
ham_statistics_t *dst); ham_statistics_t *dst);




#ifdef __cplusplus
} // extern "C"
#endif

#endif /* HAM_FREELIST_H__ */ #endif /* HAM_FREELIST_H__ */
10 changes: 0 additions & 10 deletions src/cache.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
#include "internal_fwd_decl.h" #include "internal_fwd_decl.h"
#include "env.h" #include "env.h"



#ifdef __cplusplus
extern "C" {
#endif


/** CACHE_BUCKET_SIZE should be a prime number or similar, as it is used in /** CACHE_BUCKET_SIZE should be a prime number or similar, as it is used in
* a MODULO hash scheme */ * a MODULO hash scheme */
Expand Down Expand Up @@ -282,12 +278,6 @@ class Cache


/** the buckets - a linked list of ham_page_t pointers */ /** the buckets - a linked list of ham_page_t pointers */
std::vector<ham_page_t *> m_buckets; std::vector<ham_page_t *> m_buckets;

}; };



#ifdef __cplusplus
} // extern "C"
#endif

#endif /* HAM_CACHE_H__ */ #endif /* HAM_CACHE_H__ */
9 changes: 0 additions & 9 deletions src/changeset.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@


#include "internal_fwd_decl.h" #include "internal_fwd_decl.h"


#ifdef __cplusplus
extern "C" {
#endif



/** /**
* The changeset class * The changeset class
Expand Down Expand Up @@ -75,9 +71,4 @@ class Changeset


}; };



#ifdef __cplusplus
} // extern "C" {
#endif

#endif /* HAM_CHANGESET_H__ */ #endif /* HAM_CHANGESET_H__ */
12 changes: 8 additions & 4 deletions src/cursor.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ Cursor::update_dupecache(ham_u32_t what)
dc->append(DupeCacheLine(false, op)); dc->append(DupeCacheLine(false, op));
} }
else if (txn_op_get_flags(op)&TXN_OP_INSERT_OW) { else if (txn_op_get_flags(op)&TXN_OP_INSERT_OW) {
DupeCacheLine *e=dc->get_first_element();
ham_u32_t ref=txn_op_get_referenced_dupe(op); ham_u32_t ref=txn_op_get_referenced_dupe(op);
if (ref) { if (ref) {
ham_assert(ref<=dc->get_count(), ("")); ham_assert(ref<=dc->get_count(), (""));
DupeCacheLine *e=dc->get_first_element();
(&e[ref-1])->set_txn_op(op); (&e[ref-1])->set_txn_op(op);
} }
else { else {
Expand Down Expand Up @@ -173,7 +173,7 @@ Cursor::couple_to_dupe(ham_u32_t dupe_id)
if (e->use_btree()) { if (e->use_btree()) {
btree_cursor_t *btc=get_btree_cursor(); btree_cursor_t *btc=get_btree_cursor();
couple_to_btree(); couple_to_btree();
btree_cursor_set_dupe_id(btc, e->get_btree_dupe_idx()); btree_cursor_set_dupe_id(btc, (ham_size_t)e->get_btree_dupe_idx());
} }
else { else {
ham_assert(e->get_txn_op()!=0, ("")); ham_assert(e->get_txn_op()!=0, (""));
Expand Down Expand Up @@ -1067,14 +1067,18 @@ Cursor::is_nil(int what)
{ {
switch (what) { switch (what) {
case CURSOR_BTREE: case CURSOR_BTREE:
return (__btree_cursor_is_nil(get_btree_cursor())); return (__btree_cursor_is_nil(get_btree_cursor())
? true
: false);
case CURSOR_TXN: case CURSOR_TXN:
return (txn_cursor_is_nil(get_txn_cursor())); return (txn_cursor_is_nil(get_txn_cursor()));
default: default:
ham_assert(what==0, ("")); ham_assert(what==0, (""));
/* TODO btree_cursor_is_nil is different from __btree_cursor_is_nil /* TODO btree_cursor_is_nil is different from __btree_cursor_is_nil
* - refactor and clean up! */ * - refactor and clean up! */
return (btree_cursor_is_nil(get_btree_cursor())); return (btree_cursor_is_nil(get_btree_cursor())
? true
: false);
} }
} }


Expand Down
23 changes: 7 additions & 16 deletions src/cursor.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -86,30 +86,26 @@
#include "db.h" #include "db.h"




#ifdef __cplusplus
extern "C" {
#endif

/** /**
* A single line in the dupecache structure - can reference a btree * A single line in the dupecache structure - can reference a btree
* record or a txn-op * record or a txn-op
*/ */
class DupeCacheLine class DupeCacheLine
{ {
public: public:
DupeCacheLine(ham_bool_t use_btree=true, ham_u64_t btree_dupeidx=0) DupeCacheLine(bool use_btree=HAM_TRUE, ham_u64_t btree_dupeidx=0)
: m_use_btree(use_btree), m_btree_dupeidx(btree_dupeidx), m_op(0) { : m_use_btree(use_btree), m_btree_dupeidx(btree_dupeidx), m_op(0) {
ham_assert(use_btree==true, ("")); ham_assert(use_btree==true, (""));
} }


DupeCacheLine(ham_bool_t use_btree, txn_op_t *op) DupeCacheLine(bool use_btree, txn_op_t *op)
: m_use_btree(use_btree), m_btree_dupeidx(0), m_op(op) { : m_use_btree(use_btree), m_btree_dupeidx(0), m_op(op) {
ham_assert(use_btree==false, ("")); ham_assert(use_btree==false, (""));
} }


/** Returns true if this cache entry is a duplicate in the btree */ /** Returns true if this cache entry is a duplicate in the btree */
ham_bool_t use_btree(void) { ham_bool_t use_btree(void) {
return (m_use_btree); return ((ham_bool_t)m_use_btree);
} }


/** Returns the btree duplicate index */ /** Returns the btree duplicate index */
Expand Down Expand Up @@ -139,15 +135,14 @@ class DupeCacheLine
} }


private: private:
/** Are we using btree or txn duplicates? */ /** using btree or txn duplicates? */
ham_bool_t m_use_btree; bool m_use_btree;


/** The btree duplicate index (of the original btree dupe table) */ /** The btree duplicate index (of the original btree dupe table) */
ham_u64_t m_btree_dupeidx; ham_u64_t m_btree_dupeidx;


/** The txn op structure */ /** The txn op structure */
txn_op_t *m_op; txn_op_t *m_op;

}; };




Expand All @@ -164,7 +159,7 @@ class DupeCache {


/** retrieve number of elements in the cache */ /** retrieve number of elements in the cache */
ham_size_t get_count(void) { ham_size_t get_count(void) {
return (m_elements.size()); return ((ham_size_t)m_elements.size());
} }


/** get an element from the cache */ /** get an element from the cache */
Expand Down Expand Up @@ -278,7 +273,7 @@ class Cursor


/** Returns true if a cursor is coupled to a txn-op */ /** Returns true if a cursor is coupled to a txn-op */
bool is_coupled_to_txnop(void) { bool is_coupled_to_txnop(void) {
return (get_flags()&_CURSOR_COUPLED_TO_TXN); return ((get_flags()&_CURSOR_COUPLED_TO_TXN) ? true : false);
} }


/** Couples the cursor to a btree key */ /** Couples the cursor to a btree key */
Expand Down Expand Up @@ -620,8 +615,4 @@ class Cursor
}; };




#ifdef __cplusplus
} // extern "C"
#endif

#endif /* HAM_CURSORS_H__ */ #endif /* HAM_CURSORS_H__ */
9 changes: 0 additions & 9 deletions src/db.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
#include "btree.h" #include "btree.h"
#include "mem.h" #include "mem.h"



#ifdef __cplusplus
extern "C" {
#endif

/** /**
* a macro to cast pointers to u64 and vice versa to avoid compiler * a macro to cast pointers to u64 and vice versa to avoid compiler
* warnings if the sizes of ptr and u64 are not equal * warnings if the sizes of ptr and u64 are not equal
Expand Down Expand Up @@ -1112,8 +1107,4 @@ db_erase_txn(Database *db, ham_txn_t *txn, ham_key_t *key, ham_u32_t flags,
struct txn_cursor_t *cursor); struct txn_cursor_t *cursor);




#ifdef __cplusplus
} // extern "C" {
#endif

#endif /* HAM_DB_H__ */ #endif /* HAM_DB_H__ */
8 changes: 0 additions & 8 deletions src/device.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
#include "internal_fwd_decl.h" #include "internal_fwd_decl.h"




#ifdef __cplusplus
extern "C" {
#endif

/** /**
* the device structure * the device structure
*/ */
Expand Down Expand Up @@ -215,8 +211,4 @@ ham_device_new(mem_allocator_t *alloc, ham_env_t *env, int devtype);
#define HAM_DEVTYPE_CUSTOM 2 #define HAM_DEVTYPE_CUSTOM 2




#ifdef __cplusplus
} // extern "C"
#endif

#endif /* HAM_DEVICE_H__ */ #endif /* HAM_DEVICE_H__ */
8 changes: 0 additions & 8 deletions src/endianswap.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
#ifndef HAM_ENDIANSWAP_H__ #ifndef HAM_ENDIANSWAP_H__
#define HAM_ENDIANSWAP_H__ #define HAM_ENDIANSWAP_H__


#ifdef __cplusplus
extern "C" {
#endif



/** /**
* byte swapping macros - we use little endian * byte swapping macros - we use little endian
Expand Down Expand Up @@ -71,8 +67,4 @@ extern "C" {
(((x) & 0x00000000000000ffull) << 56)) (((x) & 0x00000000000000ffull) << 56))




#ifdef __cplusplus
} // extern "C"
#endif

#endif /* HAM_ENDIANSWAP_H__ */ #endif /* HAM_ENDIANSWAP_H__ */
2 changes: 1 addition & 1 deletion src/env.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ __purge_cache_max20(ham_env_t *env)
ham_status_t st; ham_status_t st;
ham_page_t *page; ham_page_t *page;
Cache *cache=env_get_cache(env); Cache *cache=env_get_cache(env);
unsigned i, max_pages=cache->get_cur_elements(); unsigned i, max_pages=(unsigned)cache->get_cur_elements();


/* don't remove pages from the cache if it's an in-memory database */ /* don't remove pages from the cache if it's an in-memory database */
if ((env_get_rt_flags(env)&HAM_IN_MEMORY_DB)) if ((env_get_rt_flags(env)&HAM_IN_MEMORY_DB))
Expand Down
9 changes: 0 additions & 9 deletions src/env.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
#include "page.h" #include "page.h"
#include "changeset.h" #include "changeset.h"



#ifdef __cplusplus
extern "C" {
#endif

#define OFFSETOF(type, member) ((size_t) &((type *)0)->member) #define OFFSETOF(type, member) ((size_t) &((type *)0)->member)


/** /**
Expand Down Expand Up @@ -672,8 +667,4 @@ extern ham_status_t
env_purge_cache(ham_env_t *env); env_purge_cache(ham_env_t *env);




#ifdef __cplusplus
} // extern "C" {
#endif

#endif /* HAM_ENV_H__ */ #endif /* HAM_ENV_H__ */
7 changes: 0 additions & 7 deletions src/error.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
#include <ham/hamsterdb.h> #include <ham/hamsterdb.h>




#ifdef __cplusplus
extern "C" {
#endif

/* /*
* function prototypes * function prototypes
*/ */
Expand Down Expand Up @@ -89,8 +85,5 @@ extern void (*ham_test_abort)(void);
dbg_verify_failed f; \ dbg_verify_failed f; \
dbg_unlock(); \ dbg_unlock(); \
} }
#ifdef __cplusplus
} // extern "C"
#endif


#endif /* HAM_ERROR_H__ */ #endif /* HAM_ERROR_H__ */
Loading

0 comments on commit 58173a4

Please sign in to comment.