diff --git a/newbrt/Makefile b/newbrt/Makefile index bc8e294aad5..8c3f86a0a4a 100644 --- a/newbrt/Makefile +++ b/newbrt/Makefile @@ -117,7 +117,7 @@ log_print.c log_header.h: log_code.c #Needs to be done manually since it does not include newbrt. logformat$(BINSUF): logformat.c $(LIBPORTABILITY) - $(CC) $< $(BIN_FROM_O_FLAGS_NOLIB) $(LIBPORTABILITY) $(LINK_MUST_BE_LAST) + $(CC) $< $(BIN_FROM_O_FLAGS_NOLIB) $(ALWAYS_LINK) $(LINK_MUST_BE_LAST) libs: $(NEWBRT) $(NEWBRT_BUNDLE) diff --git a/newbrt/merger.c b/newbrt/merger.c index 32f47752ee7..ca7db8a9d37 100644 --- a/newbrt/merger.c +++ b/newbrt/merger.c @@ -4,15 +4,13 @@ /* See merger.h for a description of this module. */ +#include +#include "brttypes.h" #include "merger.h" #include #include #include -typedef unsigned char BOOL; -#define TRUE 1 -#define FALSE 0 - struct merger { int n_files; FILE **files; @@ -84,7 +82,7 @@ static int merge_fill_dbt (MERGER m, int i) } // Got something, so we should be able to get the rest. if (m->keys[i].ulen < keylen) { - REALLOC_N(keylen, m->keys[i].data); + m->keys[i].data = toku_xrealloc(m->keys[i].data, keylen); m->keys[i].ulen = keylen; } { @@ -97,7 +95,7 @@ static int merge_fill_dbt (MERGER m, int i) assert(n==1); } if (m->vals[i].ulen < vallen) { - REALLOC_N(vallen, m->vals[i].data); + m->vals[i].data = toku_xrealloc(m->vals[i].data, vallen); m->vals[i].ulen = vallen; } { diff --git a/newbrt/tests/cachetable-test.c b/newbrt/tests/cachetable-test.c index 00222c6f3e7..f622f1c66f5 100644 --- a/newbrt/tests/cachetable-test.c +++ b/newbrt/tests/cachetable-test.c @@ -381,7 +381,7 @@ static int add222_fetch (CACHEFILE cf, CACHEKEY key, u_int32_t fullhash, void ** return 0; } -#if !defined(_WIN32) +#if !TOKU_WINDOWS static void test_multi_filehandles (void) { CACHETABLE t; @@ -721,7 +721,7 @@ test_main (int argc, const char *argv[]) { test_mutex_init(); // run tests -#if !defined(_WIN32) +#if !TOKU_WINDOWS test_multi_filehandles(); #endif test_cachetable_create(); @@ -732,7 +732,7 @@ test_main (int argc, const char *argv[]) { for (i=0; i<1; i++) { test0(); test_nested_pin(); -#if !defined(_WIN32) +#if !TOKU_WINDOWS test_multi_filehandles (); #endif test_dirty(); diff --git a/src/Makefile b/src/Makefile index 341933171e2..2450559a8fd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -45,24 +45,23 @@ LIBRARIES+= \ $(LIBRARY_S) \ #Purposely here for \ at end of prev +ifeq ($(OS_CHOICE),windows) +#Does not support parallel builds for files in src. +.NOTPARALLEL:; +ifeq ($(DEBUG),0) +WINYDB = $(IPO_YDB) +else +WINYDB = $(NOIPO_YDB) +endif +LIBRARIES += $(WINYDB) +libtokudb.pdb : $(WINYDB); +endif + INSTALL_LIBRARIES= $(patsubst %,%.install,$(LIBRARIES)) ifeq ($(OS_CHOICE),windows) INSTALL_LIBRARIES += libtokudb.pdb.install endif -ifeq ($(OS_CHOICE),windows) -#Does not support parallel builds for files in src. -.NOTPARALLEL:; - ifeq ($(DEBUG),0) - WINYDB = $(IPO_YDB) - else - WINYDB = $(NOIPO_YDB) - endif - LIBRARIES += $(WINYDB) -libtokudb.pdb : $(WINYDB); -endif - - .PHONY:install_libs install.% build install local build_tests @@ -84,9 +83,12 @@ install: libs install_libs ; .PHONY: local libs buildlocktrees libs: $(LIBRARIES) ; $(IPO_YDB) $(NOIPO_YDB) $(LIBRARIES): | export.def -export.def: export.map + +#Generate export.def +#Take everything from export.map, add snprintf and vsnprintf, and then convert into export.def format. +export.def: export.map Makefile echo "EXPORTS" > $@ - cat export.map |sed -n "s/\([a-zA-Z_0-9][a-zA-Z_0-9]*\);/\t\1 @/g;/@/ P" |sed -n 'P;=' | sed '{;N;s/\n//;}' >> $@ + cat export.map | sed 's/global:$$/global:\n snprintf;\n usleep;/' | sed -n "s/\([a-zA-Z_0-9][a-zA-Z_0-9]*\);/\t\1 @/g;/@/ P" |sort | sed -n 'P;=' | sed '{;N;s/\n//;}' >> $@ echo "" >> $@ buildlocktrees: $(LOCKTREE) $(RANGETREE) ; @@ -133,6 +135,7 @@ strip: $(LIBRARY) strip $< clean: + rm -f export.def cd tests && $(MAKE) clean cd lock_tree && $(MAKE) clean cd range_tree && $(MAKE) clean diff --git a/src/elocks.c b/src/elocks.c index b4b23ef1b19..a7c643e8624 100644 --- a/src/elocks.c +++ b/src/elocks.c @@ -164,7 +164,7 @@ toku_ydb_lock(void) { t = MAX_SLEEP; (void) toku_sync_fetch_and_increment_uint64(&status.times_max_sleep_used); } -#if !TOKU_WINDOWS || TOKU_WINDOWS_HAS_FAST_ATOMIC_64 +#if !TOKU_WINDOWS || TOKU_WINDOWS_HAS_ATOMIC_64 (void) toku_sync_fetch_and_add_uint64(&status.total_sleep_time, t); #endif (void) toku_sync_fetch_and_increment_uint64(&status.total_sleepers); diff --git a/src/export.map b/src/export.map index 5b2cacf6f95..15fd5bee040 100644 --- a/src/export.map +++ b/src/export.map @@ -56,6 +56,9 @@ toku_os_full_write; toku_os_full_pwrite; + toku_os_get_max_process_data_size; + toku_os_get_phys_memory_size; + local: *; }; diff --git a/src/loader.c b/src/loader.c index fd79ccd5ffb..c80d6984363 100644 --- a/src/loader.c +++ b/src/loader.c @@ -11,6 +11,7 @@ * a REFERENCE IMPLEMENTATION of the loader */ +#include #include #include #include "ydb-internal.h" diff --git a/src/tests/checkpoint_stress.c b/src/tests/checkpoint_stress.c index 430d5fbb8da..2e76703f48d 100644 --- a/src/tests/checkpoint_stress.c +++ b/src/tests/checkpoint_stress.c @@ -188,7 +188,7 @@ random_acts(void * d) { } -#if IS_TDB && !defined(_WIN32) && !defined(_WIN64) +#if IS_TDB && !TOKU_WINDOWS return intothevoid; #endif } diff --git a/src/ydb_lib.c b/src/ydb_lib.c index 790bb58c968..498917f10e1 100644 --- a/src/ydb_lib.c +++ b/src/ydb_lib.c @@ -21,7 +21,7 @@ static void __attribute__((destructor)) libtokudb_destroy(void) { #endif -#if defined(_WIN32) || defined(_WIN64) +#if TOKU_WINDOWS #include #define UNUSED(x) x=x diff --git a/toku_include/Makefile.include b/toku_include/Makefile.include index 5792111b480..032dc584b77 100644 --- a/toku_include/Makefile.include +++ b/toku_include/Makefile.include @@ -218,28 +218,31 @@ ifeq ($(CC),icc) SYMBOLS= -g -debug all -inline-debug-info PORTABILITY=-diag-enable port-win AR=xiar + DISABLE_WARNING= ifneq ($(CYGWIN),) #Cygwin ICC_NOWARN=-Qdiag-disable: - SKIP_WARNING += $(ICC_NOWARN)869 # Don't complain about unused variables (since we defined __attribute__ to be nothing.) - SKIP_WARNING += $(ICC_NOWARN)593 # Don't complain about unused variables (since we defined __attribute__ to be nothing.) - SKIP_WARNING += $(ICC_NOWARN)11000 # Disable message about multi-file optimization - SKIP_WARNING += $(ICC_NOWARN)11000 # Disable message about single-file optimization - SKIP_WARNING += $(ICC_NOWARN)11005 # Disable message about creating object file - SKIP_WARNING += $(ICC_NOWARN)188 # Disable message about 0 used for enum - SKIP_WARNING += $(ICC_NOWARN)1011 # Disable message about missing return with an abort + DISABLE_WARNING +=869# Don't complain about unused variables (since we defined __attribute__ to be nothing.) + DISABLE_WARNING +=593# Don't complain about unused variables (since we defined __attribute__ to be nothing.) + DISABLE_WARNING +=11000# Disable message about multi-file optimization + DISABLE_WARNING +=11000# Disable message about single-file optimization + DISABLE_WARNING +=11005# Disable message about creating object file + DISABLE_WARNING +=188# Disable message about 0 used for enum + DISABLE_WARNING +=1011# Disable message about missing return with an abort else #Linux ICC_NOWARN=-diag-disable #Need the space endif - SKIP_WARNING += $(ICC_NOWARN)810 # Remove warnings about losing precision - SKIP_WARNING += $(ICC_NOWARN)94 # Allow arrays of length 0 - SKIP_WARNING += $(ICC_NOWARN)118 # Allow void functions to return void functions - SKIP_WARNING += $(ICC_NOWARN)177 # Don't complain about static variables that are not used. - #SKIP_WARNING += $(ICC_NOWARN)188 # Don't complain about enumerated type mixed with another type. - SKIP_WARNING += $(ICC_NOWARN)589 # Don't complain about goto into a block that skips initializing variables. GCC catches the actual uninitialized variables. - SKIP_WARNING += $(ICC_NOWARN)981 # Don't complain about "operands are evaluated in unspecified order". This seems to be generated whenever more than one argument to a function or operand is computed by function call. - SKIP_WARNING += $(ICC_NOWARN)1324 # Don't complain about rdtsc clobbering its registers more than once. + DISABLE_WARNING +=810# Remove warnings about losing precision + DISABLE_WARNING +=94# Allow arrays of length 0 + DISABLE_WARNING +=118# Allow void functions to return void functions + DISABLE_WARNING +=177# Don't complain about static variables that are not used. + #DISABLE_WARNING +=188# Don't complain about enumerated type mixed with another type. + DISABLE_WARNING +=589# Don't complain about goto into a block that skips initializing variables. GCC catches the actual uninitialized variables. + DISABLE_WARNING +=981# Don't complain about "operands are evaluated in unspecified order". This seems to be generated whenever more than one argument to a function or operand is computed by function call. + DISABLE_WARNING +=1324# Don't complain about rdtsc clobbering its registers more than once. + DISABLE_WARNING +=1786# Don't complain about 'read/write/other standards' being deprecated + SKIP_WARNING = $(ICC_NOWARN)$(shell sed 's/ /,/g' <<< "$(DISABLE_WARNING)" | sed 's/,//') endif ifneq ($(CC),icc) @@ -291,7 +294,6 @@ ifneq ($(CYGWIN),) WERROR += -Qdiag-error:167,266,810,592 # Workarounds for -WX not being complete on windows icc SYMBOLS= -Zi -debug:all -Qinline-debug-info PORTABILITY= - SKIP_WARNING += $(ICC_NOWARN)1786 # Don't complain about 'read/write/other standards' being deprecated PORTABILITY_HEADERS = $(TOKUROOT)windows AR=xilib DBG_AROPT=-qnoipo diff --git a/toku_include/toku_atomic.h b/toku_include/toku_atomic.h index ffd5eaf4209..fcdb64f51cb 100644 --- a/toku_include/toku_atomic.h +++ b/toku_include/toku_atomic.h @@ -19,20 +19,20 @@ toku_sync_fetch_and_decrement_int32(volatile int32_t *a) { } #define TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA 0 + //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 -#define TOKU_WINDOWS_HAS_FAST_ATOMIC_64 1 +#if TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA || defined(_WIN64) +#define TOKU_WINDOWS_HAS_ATOMIC_64 1 #else -#define TOKU_WINDOWS_HAS_FAST_ATOMIC_64 0 +#define TOKU_WINDOWS_HAS_ATOMIC_64 0 #endif static inline uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) { -#if TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA - //Need Vista or later for this function to exist. +#if TOKU_WINDOWS_HAS_ATOMIC_64 return _InterlockedExchangeAdd64((int64_t*)a, b); #else //Temporarily just use 32 bit atomic instructions (treat the values as 32 @@ -44,8 +44,7 @@ toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) { static inline uint64_t toku_sync_fetch_and_increment_uint64(volatile uint64_t *a) { -#if TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA - //Need Vista or later for this function to exist. +#if TOKU_WINDOWS_HAS_ATOMIC_64 return _InterlockedIncrement64((int64_t*)a); #else //Temporarily just use 32 bit atomic instructions (treat the values as 32 diff --git a/toku_include/toku_os.h b/toku_include/toku_os.h index a6e70d45314..92d2f3fd108 100644 --- a/toku_include/toku_os.h +++ b/toku_include/toku_os.h @@ -23,7 +23,7 @@ int toku_os_get_number_active_processors(void); int toku_os_get_pagesize(void); // Returns: the size of physical memory (in bytes) -uint64_t toku_os_get_phys_memory_size(void); +uint64_t toku_os_get_phys_memory_size(void) __attribute__((__visibility__("default"))); // Returns the processor frequency in Hz // Returns 0 if success @@ -58,7 +58,7 @@ int toku_os_get_max_rss(int64_t *maxrss); // Get the maximum size of the process data size (in bytes) // Success: returns 0 and sets *maxdata to the data size // Fail: returns an error number -int toku_os_get_max_process_data_size(uint64_t *maxdata); +int toku_os_get_max_process_data_size(uint64_t *maxdata) __attribute__((__visibility__("default"))); int toku_os_initialize_settings(int verbosity) __attribute__((__visibility__("default"))); @@ -67,7 +67,7 @@ int toku_os_initialize_settings(int verbosity) __attribute__((__visibility__("d // int toku_os_is_absolute_name(const char* path) __attribute__((__visibility__("default"))); -#if defined(TOKU_WINDOWS) && TOKU_WINDOWS +#if TOKU_WINDOWS #include #include //Test if st_mode (from stat) is a directory diff --git a/utils/tokudb_common_funcs.h b/utils/tokudb_common_funcs.h index fdda49c5d14..c6a84198cdf 100644 --- a/utils/tokudb_common_funcs.h +++ b/utils/tokudb_common_funcs.h @@ -239,14 +239,14 @@ resend_signals(void) { } #include -#if IS_TDB && !defined(_WIN32) && !defined(_WIN64) && TDB_IS_STATIC +#if IS_TDB && !TOKU_WINDOWS && TDB_IS_STATIC #include #endif static int test_main (int argc, char *argv[]); int main(int argc, char *argv[]) { int r; -#if IS_TDB && !defined(_WIN32) && !defined(_WIN64) && TDB_IS_STATIC +#if IS_TDB && !TOKU_WINDOWS && TDB_IS_STATIC toku_ydb_init(); #endif #if !IS_TDB && DB_VERSION_MINOR==4 && DB_VERSION_MINOR == 7 @@ -255,7 +255,7 @@ main(int argc, char *argv[]) { r = db_env_set_func_realloc(toku_realloc); assert(r==0); #endif r = test_main(argc, argv); -#if IS_TDB && !defined(_WIN32) && !defined(_WIN64) && TDB_IS_STATIC +#if IS_TDB && !TOKU_WINDOWS && TDB_IS_STATIC toku_ydb_destroy(); #endif return r; diff --git a/utils/tokudb_gen.c b/utils/tokudb_gen.c index bed48961d1d..2211ba568e0 100644 --- a/utils/tokudb_gen.c +++ b/utils/tokudb_gen.c @@ -171,7 +171,7 @@ static int test_main (int argc, char *argv[]) { } sort_delimiter[0] = (char)temp; sort_delimiter[1] = '\0'; -#if defined(TOKU_WINDOWS) && TOKU_WINDOWS +#if TOKU_WINDOWS if (!strcmp(sort_delimiter, "\n")) { strcpy(sort_delimiter, "\r\n"); } diff --git a/windows/file.c b/windows/file.c index 7c943722ac3..3e4c3ae361f 100644 --- a/windows/file.c +++ b/windows/file.c @@ -194,14 +194,14 @@ static int (*t_fsync)(int) = 0; static uint64_t toku_fsync_count; static uint64_t toku_fsync_time; -#if !TOKU_WINDOWS_HAS_FAST_ATOMIC_64 +#if !TOKU_WINDOWS_HAS_ATOMIC_64 static toku_pthread_mutex_t fsync_lock; #endif int toku_fsync_init(void) { int r = 0; -#if !TOKU_WINDOWS_HAS_FAST_ATOMIC_64 +#if !TOKU_WINDOWS_HAS_ATOMIC_64 r = toku_pthread_mutex_init(&fsync_lock, NULL); assert(r == 0); #endif return r; @@ -210,7 +210,7 @@ toku_fsync_init(void) { int toku_fsync_destroy(void) { int r = 0; -#if !TOKU_WINDOWS_HAS_FAST_ATOMIC_64 +#if !TOKU_WINDOWS_HAS_ATOMIC_64 r = toku_pthread_mutex_destroy(&fsync_lock); assert(r == 0); #endif return r; @@ -240,7 +240,7 @@ toku_file_fsync(int fd) { if (r) assert(errno==EINTR); } -#if TOKU_WINDOWS_HAS_FAST_ATOMIC_64 +#if TOKU_WINDOWS_HAS_ATOMIC_64 toku_sync_fetch_and_increment_uint64(&toku_fsync_count); toku_sync_fetch_and_add_uint64(&toku_fsync_time, get_tnow() - tstart); #else diff --git a/windows/pthread.h b/windows/pthread.h index 6b848dc7031..0bd34137313 100644 --- a/windows/pthread.h +++ b/windows/pthread.h @@ -37,8 +37,8 @@ * See the README file for an explanation of the pthreads-win32 version * numbering scheme and how the DLL is named etc. */ -#define PTW32_VERSION 2,8,0,0 -#define PTW32_VERSION_STRING "2, 8, 0, 0\0" +#define PTW32_VERSION 2,9,0,0 +#define PTW32_VERSION_STRING "2, 9, 0, 0\0" /* There are three implementations of cancel cleanup. * Note that pthread.h is included in both application @@ -104,7 +104,7 @@ #define PTW32_LEVEL_MAX 3 -#if !defined(PTW32_LEVEL) +#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL) #define PTW32_LEVEL PTW32_LEVEL_MAX /* Include everything */ #endif @@ -210,9 +210,6 @@ typedef unsigned long DWORD_PTR; * ----------------- */ -//IF YOU GET AN ERROR on HAVE_CONFIG_H: -//You used #include "toku_portability.h" <-- WRONG -//instead of #include <-- CORRECT #if HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ @@ -308,7 +305,7 @@ enum { #ifndef HAVE_STRUCT_TIMESPEC #define HAVE_STRUCT_TIMESPEC 1 struct timespec { - long tv_sec; + time_t tv_sec; long tv_nsec; }; #endif /* HAVE_STRUCT_TIMESPEC */ @@ -902,13 +899,13 @@ PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, int); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (pthread_attr_t *, +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *, int *); PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, int inheritsched); -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(pthread_attr_t * attr, +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr, int * inheritsched); PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, @@ -987,7 +984,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t int pshared); PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind); /* * Barrier Attribute Functions @@ -1187,6 +1184,10 @@ PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); * Returns the Win32 HANDLE for the POSIX thread. */ PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); +/* + * Returns the win32 thread ID for POSIX thread. + */ +PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); /* @@ -1248,13 +1249,19 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, ( strcpy( (_buf), ctime( (_clock) ) ), \ (_buf) ) +/* + * gmtime(tm) and localtime(tm) return 0 if tm represents + * a time prior to 1/1/1970. + */ #define gmtime_r( _clock, _result ) \ - ( *(_result) = *gmtime( (_clock) ), \ - (_result) ) + ( gmtime( (_clock) ) \ + ? (*(_result) = *gmtime( (_clock) ), (_result) ) \ + : (0) ) #define localtime_r( _clock, _result ) \ - ( *(_result) = *localtime( (_clock) ), \ - (_result) ) + ( localtime( (_clock) ) \ + ? (*(_result) = *localtime( (_clock) ), (_result) ) \ + : (0) ) #define rand_r( _seed ) \ ( _seed == _seed? rand() : rand() ) diff --git a/windows/sched.h b/windows/sched.h index dfb8e934af4..e3e7a00081c 100644 --- a/windows/sched.h +++ b/windows/sched.h @@ -60,7 +60,7 @@ #define PTW32_LEVEL_MAX 3 -#if !defined(PTW32_LEVEL) +#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL) #define PTW32_LEVEL PTW32_LEVEL_MAX /* Include everything */ #endif @@ -114,12 +114,14 @@ #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ #if defined(__MINGW32__) || defined(_UWIN) -#if PTW32_LEVEL >= PTW32_LEVEL_MAX +# if PTW32_LEVEL >= PTW32_LEVEL_MAX /* For pid_t */ # include /* Required by Unix 98 */ # include -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ +# else + typedef int pid_t; +# endif #else typedef int pid_t; #endif diff --git a/windows/scripts/amd64/Cygwin.bat b/windows/scripts/amd64/Cygwin.bat new file mode 100755 index 00000000000..73e7241e474 --- /dev/null +++ b/windows/scripts/amd64/Cygwin.bat @@ -0,0 +1,8 @@ +@echo off + +call "C:\Program Files (x86)\Intel\Compiler\C++\10.1.032\EM64T\Bin\ICLVars.bat" +C: +chdir C:\cygwin\bin + +bash --login -i %* + diff --git a/windows/scripts/install_amd64.sh b/windows/scripts/install_amd64.sh new file mode 100755 index 00000000000..283d07b25f2 --- /dev/null +++ b/windows/scripts/install_amd64.sh @@ -0,0 +1,68 @@ +#!/usr/bin/bash + +#Install BDB +echo Installing BDB if necessary ... +if ! test -d /usr/local/BerkeleyDB.4.6 ; then + ( + echo "BDB is missing. Downloading from svn" && + cd /usr/local && + svn co -q https://svn.tokutek.com/tokudb/berkeleydb/windows/amd64/BerkeleyDB.4.6 + ) || { echo Failed; exit 1; } +fi +if ! grep 'export BDB=' ~/.bashrc > /dev/null; then + echo "Adding 'export BDB=/usr/local/BerkeleyDB.4.6' to ~/.bashrc" + echo 'export BDB=/usr/local/BerkeleyDB.4.6' >> ~/.bashrc +fi +if ! grep 'export BDBDIR=' ~/.bashrc > /dev/null; then + echo "Adding 'export BDBDIR=C:/cygwin/usr/local/BerkeleyDB.4.6'' to ~/.bashrc" + echo 'export BDBDIR=C:/cygwin/usr/local/BerkeleyDB.4.6' >> ~/.bashrc +fi +echo Done installing BDB. +echo + + +#Install licenses. +if ! test -e ../licenses/install_licenses_amd64.bat; then + echo Missing ../licenses directory. + exit 1 +fi +echo Installing licenses... +(cd ../licenses && cmd /c install_licenses_amd64.bat) +echo Done installing licenses. +echo + + +#install icc integration +( + cd amd64 && + if ! diff -q Cygwin.bat /cygdrive/c/cygwin/Cygwin.bat > /dev/null; then + cp Cygwin.bat /cygdrive/c/cygwin/ + fi +) +if ! grep 'export CC=' ~/.bashrc > /dev/null; then + echo "Adding 'export CC=icc' to ~/.bashrc" + echo 'export CC=icc' >> ~/.bashrc +fi +if ! grep 'export CYGWIN=' ~/.bashrc > /dev/null; then + echo "Adding 'export CYGWIN=CYGWIN' to ~/.bashrc" + echo 'export CYGWIN=CYGWIN' >> ~/.bashrc +fi + +#cygwin link is in the way +if test -e /usr/bin/link; then + mv /usr/bin/link /usr/bin/link_DISABLED +fi +#cygwin cmake is in the way +if test -e /usr/bin/cmake; then + mv /usr/bin/cmake /usr/bin/cmake_DISABLED +fi + +#Set up aliases +( cd amd64/symlinks && cp -d * /usr/local/bin/ ) + +echo You can now install the intel compiler. +echo You must restart cygwin after intel compiler is installed. +echo If the intel compiler is already installed, just restart cygwin. + + + diff --git a/windows/scripts/makebdb.bash b/windows/scripts/makebdb.bash deleted file mode 100755 index bf5525efb5b..00000000000 --- a/windows/scripts/makebdb.bash +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -mkdir -p /usr/local/BerkeleyDB.$1/bin -mkdir -p /usr/local/BerkeleyDB.$1/lib -ln -s /usr/bin/db$1_load.exe /usr/local/BerkeleyDB.$1/bin/db_load -ln -s /usr/bin/db$1_dump.exe /usr/local/BerkeleyDB.$1/bin/db_dump -ln -s /usr/include/db /usr/local/BerkeleyDB.$1/include -ln -s /usr/lib/libdb-.a /usr/local/BerkeleyDB.$1/lib/libdb.a -ln -s /usr/lib/libdb-.dll.a /usr/local/BerkeleyDB.$1/lib/libdb.dll.a -ln -s /usr/lib/libdb-.la /usr/local/BerkeleyDB.$1/lib/libdb.la -ln -s /usr/lib/libdb_cxx-.la /usr/local/BerkeleyDB.$1/lib/libdb_cxx.la -ln -s /usr/lib/libdb_cxx-.a /usr/local/BerkeleyDB.$1/lib/libdb_cxx.a -ln -s /usr/lib/libdb_cxx-.dll.a /usr/local/BerkeleyDB.$1/lib/libdb_cxx.dll.a diff --git a/windows/semaphore.h b/windows/semaphore.h deleted file mode 100644 index a3330a6388d..00000000000 --- a/windows/semaphore.h +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Module: semaphore.h - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * The current list of contributors is contained - * in the file CONTRIBUTORS included with the source - * code distribution. The list can also be seen at the - * following World Wide Web location: - * http://sources.redhat.com/pthreads-win32/contributors.html - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ -#if !defined( SEMAPHORE_H ) -#define SEMAPHORE_H - -#undef PTW32_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_LEVEL_MAX 3 - -#if !defined(PTW32_LEVEL) -#define PTW32_LEVEL PTW32_LEVEL_MAX -/* Include everything */ -#endif - -#if __GNUC__ && ! defined (__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the DLL code, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the DLL, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#ifndef PTW32_STATIC_LIB -# ifdef PTW32_BUILD -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#ifndef PTW32_CONFIG_H -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#ifdef NEED_ERRNO -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -#define _POSIX_SEMAPHORES - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#ifndef HAVE_MODE_T -typedef unsigned int mode_t; -#endif - - -typedef struct sem_t_ * sem_t; - -PTW32_DLLPORT int __cdecl sem_init (sem_t * sem, - int pshared, - unsigned int value); - -PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem, - const struct timespec * abstime); - -PTW32_DLLPORT int __cdecl sem_post (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem, - int count); - -PTW32_DLLPORT int __cdecl sem_open (const char * name, - int oflag, - mode_t mode, - unsigned int value); - -PTW32_DLLPORT int __cdecl sem_close (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_unlink (const char * name); - -PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem, - int * sval); - -#ifdef __cplusplus -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX - -#endif /* !SEMAPHORE_H */ diff --git a/windows/tests/Makefile b/windows/tests/Makefile index 6908b65decd..dc4d10d21c0 100644 --- a/windows/tests/Makefile +++ b/windows/tests/Makefile @@ -24,9 +24,9 @@ check: $(BINS) $(RUNTARGETS); %.tdbrun: %$(BINSUF) $(PTHREAD_LOCAL) mkdir -p dir.$* ifeq ($(VGRIND),) - cd dir.$* && ../$< $(SUMMARIZE_CMD) + cd dir.$* && ../$< $(VERBVERBOSE) $(SUMMARIZE_CMD) else - cd dir.$* && .$(VGRIND) --log-file=$<.valgrind ../$<; \ + cd dir.$* && .$(VGRIND) --log-file=$<.valgrind ../$< $(VERBVERBOSE); \ if [ $$? = 0 ] ; then \ grep "LEAK SUMMARY" dir.$*/$<.valgrind >/dev/null 2>&1; \ if [ $$? = 0 ] ; then cat dir.$*/$<.valgrind; test 0 = 1; fi \ diff --git a/windows/tests/test-ftruncate.c b/windows/tests/test-ftruncate.c index 32dcf822dca..a32af9b07aa 100644 --- a/windows/tests/test-ftruncate.c +++ b/windows/tests/test-ftruncate.c @@ -8,7 +8,7 @@ #include #include -#if 0 && defined _WIN32 +#if 0 && TOKU_WINDOWS #include static int ftruncate(int fd, uint64_t offset) { HANDLE h = (HANDLE) _get_osfhandle(fd); @@ -38,8 +38,7 @@ int test_main(int argc, char *argv[]) { for (i=0; i<32; i++) { char junk[4096]; memset(junk, 0, sizeof junk); - r = write(fd, junk, sizeof junk); - assert(r == sizeof junk); + toku_os_full_write(fd, junk, sizeof junk); } toku_struct_stat filestat; diff --git a/windows/tests/test-open-rename.c b/windows/tests/test-open-rename.c index 5528d089e4d..d3a4b2d5a5e 100644 --- a/windows/tests/test-open-rename.c +++ b/windows/tests/test-open-rename.c @@ -4,7 +4,7 @@ #include #include #include -#ifdef _WIN32 +#if TOKU_WINDOWS #include #endif #include @@ -37,7 +37,7 @@ int test_main(int argc, char *argv[]) { r = close(fd); assert(r == 0); #endif -#if defined(_WIN32) +#if TOKU_WINDOWS assert(r == -1); r = close(fd); diff --git a/windows/tests/test-open-unlink.c b/windows/tests/test-open-unlink.c index 6d8228e1aac..0e5fcd313ab 100644 --- a/windows/tests/test-open-unlink.c +++ b/windows/tests/test-open-unlink.c @@ -4,7 +4,7 @@ #include #include #include -#ifdef _WIN32 +#if TOKU_WINDOWS #include #endif #include @@ -35,7 +35,7 @@ int test_main(int argc, char *argv[]) { r = close(fd); assert(r == 0); #endif -#if defined(_WIN32) +#if TOKU_WINDOWS assert(r == -1); r = close(fd); diff --git a/windows/tests/test-usleep-ws.c b/windows/tests/test-usleep-ws.c index b6bd40c49e3..4b36519cbb2 100644 --- a/windows/tests/test-usleep-ws.c +++ b/windows/tests/test-usleep-ws.c @@ -33,7 +33,7 @@ int test_main(int argc, char *argv[]) { WSAStartup(MAKEWORD(1, 0), &wsadata); s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); - printf("s=%u\n", s); + printf("s=%"PRIu64"\n", s); for (i=0; i<1000; i++) { if (verbose) { diff --git a/windows/tests/test.h b/windows/tests/test.h index e63b82af9b3..013a8519b51 100644 --- a/windows/tests/test.h +++ b/windows/tests/test.h @@ -4,9 +4,11 @@ int test_main(int argc, char *argv[]); int main(int argc, char *argv[]) { - toku_portability_init(); + int ri = toku_portability_init(); + assert(ri==0); int r = test_main(argc, argv); - toku_portability_destroy(); + int rd = toku_portability_destroy(); + assert(rd==0); return r; } diff --git a/windows/toku_htonl.h b/windows/toku_htonl.h index ede8c70508e..35539197afa 100644 --- a/windows/toku_htonl.h +++ b/windows/toku_htonl.h @@ -1,7 +1,7 @@ #ifndef _TOKU_HTONL_H #define _TOKU_HTONL_H -#if !defined(_WIN32) +#if !TOKU_WINDOWS #error #endif diff --git a/windows/windows.c b/windows/windows.c index 31cef7d4aea..e7417bec26b 100644 --- a/windows/windows.c +++ b/windows/windows.c @@ -23,6 +23,7 @@ static int toku_malloc_init(void) { int r = 0; +#if defined(_WIN32) //Set the heap (malloc/free/realloc) to use the low fragmentation mode. ULONG HeapFragValue = 2; @@ -34,6 +35,7 @@ toku_malloc_init(void) { //if (success==0) //Do some error output if necessary. if (!success) r = GetLastError(); +#endif return r; } @@ -174,19 +176,18 @@ toku_os_gettid(void) { int toku_os_get_max_process_data_size(uint64_t *maxdata) { -#ifdef _WIN32 +#if defined(_WIN32) // the process gets 1/2 of the 32 bit address space. // we are ignoring the 3GB feature for now. *maxdata = 1ULL << 31; return 0; -#else -#ifdef _WIN64 +#elif defined(_WIN64) *maxdata = ~0ULL; return 0; #else +#error return EINVAL; #endif -#endif } int