Commit 2d5b56eb authored by Yoni Fogel's avatar Yoni Fogel

closes[t:2515] Accurately distinguish between 32bit and 64bit windows

git-svn-id: file:///svn/toku/tokudb@19288 c7de825b-a66e-492c-adef-691d508d4ae1
parent a933417b
......@@ -60,7 +60,12 @@ CPPFLAGS+= -D_GNU_SOURCE
TOKUDB=libtokudb.$(SOEXT)
default: build
build: build.tdb build.bdb
ifeq ($(OS_CHOICE),windows)
build: build.tdb;
else
build: build.tdb build.bdb;
endif
build.bdb: $(TARGET_BDB) $(SCANSCAN_BDB) $(WINDOWS_BDB_LIB_NAME)
build.tdb: $(TARGET_TDB) $(SCANSCAN_TDB)
......
......@@ -102,7 +102,7 @@ void memarena_close(MEMARENA *map) {
*map = 0;
}
#if defined(_WIN32)
#if TOKU_WINDOWS_32
#include <windows.h>
#include <crtdbg.h>
#endif
......@@ -113,7 +113,7 @@ void memarena_move_buffers(MEMARENA dest, MEMARENA source) {
static int move_counter = 0;
move_counter++;
REALLOC_N(dest->n_other_bufs + source->n_other_bufs + 1, other_bufs);
#if defined(_WIN32)
#if TOKU_WINDOWS_32
if (other_bufs == 0) {
char **new_other_bufs;
printf("_CrtCheckMemory:%d\n", _CrtCheckMemory());
......
......@@ -282,7 +282,7 @@ main(int argc, char * const argv[])
#endif
{
int r;
#if IS_TDB && (defined(_WIN32) || defined(_WIN64))
#if IS_TDB && TOKU_WINDOWS
int rinit = toku_ydb_init();
CKERR(rinit);
#endif
......@@ -293,7 +293,7 @@ main(int argc, char * const argv[])
#endif
toku_os_initialize_settings(1);
r = test_main(argc, argv);
#if IS_TDB && (defined(_WIN32) || defined(_WIN64))
#if IS_TDB && TOKU_WINDOWS
int rdestroy = toku_ydb_destroy();
CKERR(rdestroy);
#endif
......
......@@ -29,12 +29,27 @@ BOOL WINAPI DllMain(HINSTANCE h, DWORD reason, LPVOID reserved) {
UNUSED(h); UNUSED(reserved);
// printf("%s:%lu\n", __FUNCTION__, reason);
int r = 0;
if (reason == DLL_PROCESS_ATTACH)
switch(reason) {
case DLL_PROCESS_ATTACH:
r = toku_ydb_init();
if (reason == DLL_PROCESS_DETACH)
break;
case DLL_PROCESS_DETACH:
r = toku_ydb_destroy();
break;
case DLL_THREAD_ATTACH:
//TODO: Any new thread code if necessary, i.e. allocate per-thread
// storage.
break;
case DLL_THREAD_DETACH:
//TODO: Any cleanup thread code if necessary, i.e. free per-thread
// storage.
break;
default:
break;
}
assert(r==0);
return TRUE;
}
#endif
......@@ -43,7 +43,7 @@ toku_sync_fetch_and_decrement_int32(volatile int32_t *a) {
//Vista has 64 bit atomic instruction functions.
//64 bit windows should also have it, but we're using neither right now.
#if TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA || defined(_WIN64)
#if TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA || TOKU_WINDOWS_64
#define TOKU_WINDOWS_HAS_ATOMIC_64 1
#else
#define TOKU_WINDOWS_HAS_ATOMIC_64 0
......
......@@ -12,9 +12,20 @@ extern "C" {
#define TOKU_WINDOWS 1
#define DEV_NULL_FILE "NUL"
# if defined(_WIN64)
# define TOKU_WINDOWS_32 0
# define TOKU_WINDOWS_64 1
# else
# define TOKU_WINDOWS_32 1
# define TOKU_WINDOWS_64 2
#endif
#else
#define TOKU_WINDOWS 0
#define TOKU_WINDOWS_32 0
#define TOKU_WINDOWS_64 0
#define DEV_NULL_FILE "/dev/null"
#endif
......
......@@ -23,7 +23,7 @@
static int
toku_malloc_init(void) {
int r = 0;
#if defined(_WIN32)
#if TOKU_WINDOWS_32
//Set the heap (malloc/free/realloc) to use the low fragmentation mode.
ULONG HeapFragValue = 2;
......@@ -194,12 +194,12 @@ toku_os_gettid(void) {
int
toku_os_get_max_process_data_size(uint64_t *maxdata) {
#if defined(_WIN32)
#if TOKU_WINDOWS_32
// the process gets 1/2 of the 32 bit address space.
// we are ignoring the 3GB feature for now.
*maxdata = 1ULL << 31;
return 0;
#elif defined(_WIN64)
#elif TOKU_WINDOWS_64
*maxdata = ~0ULL;
return 0;
#else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment