From 670e38ff50b1bb80fc2c8d3f7501952f96db0b92 Mon Sep 17 00:00:00 2001 From: Pieter Willem Jordaan Date: Tue, 29 Nov 2011 16:17:50 +0200 Subject: [PATCH] Make mingw work. Make boost 4.48 work Signed-off-by: Pieter Willem Jordaan --- SConstruct | 10 +++++----- bson/util/misc.h | 25 +++++++++++++++++++++---- client/mongo_client_lib.cpp | 10 ++++++++++ db/nonce.cpp | 4 ++++ util/text.cpp | 2 +- util/time_support.h | 7 +++++++ util/util.cpp | 2 +- 7 files changed, 49 insertions(+), 11 deletions(-) diff --git a/SConstruct b/SConstruct index 0fd9447..ef686c1 100644 --- a/SConstruct +++ b/SConstruct @@ -579,7 +579,7 @@ elif "win32" == os.sys.platform: [ "v7.1", "v7.0A", "v7.0", "v6.1", "v6.0a", "v6.0" ] ) print( "Windows SDK Root '" + winSDKHome + "'" ) - env.Append( CPPPATH=[ boostDir , winSDKHome + "/Include" ] ) + env.Append( CPPPATH=[ boostDir + "/include/boost-1_48" , winSDKHome + "/Include" ] ) # consider adding /MP build with multiple processes option. @@ -623,10 +623,10 @@ elif "win32" == os.sys.platform: if debugLogging: env.Append( CPPDEFINES=[ "_DEBUG" ] ) - if force64 and os.path.exists( boostDir + "/lib/vs2010_64" ): - env.Append( LIBPATH=[ boostDir + "/lib/vs2010_64" ] ) - elif not force64 and os.path.exists( boostDir + "/lib/vs2010_32" ): - env.Append( LIBPATH=[ boostDir + "/lib/vs2010_32" ] ) + if force64 and os.path.exists( boostDir + "/lib" ): + env.Append( LIBPATH=[ boostDir + "/lib" ] ) + elif not force64 and os.path.exists( boostDir + "/lib" ): + env.Append( LIBPATH=[ boostDir + "/lib" ] ) else: env.Append( LIBPATH=[ boostDir + "/Lib" ] ) diff --git a/bson/util/misc.h b/bson/util/misc.h index 33764e3..b57695c 100644 --- a/bson/util/misc.h +++ b/bson/util/misc.h @@ -27,9 +27,14 @@ namespace mongo { inline void time_t_to_String(time_t t, char *buf) { #if defined(_WIN32) - ctime_s(buf, 32, &t); + #if defined(_MSC_VER) + ctime_s(buf, sizeof(buf), &t); + #else + _ctime64_s(buf, 32, &t); + #endif //_MSC_VER #else ctime_r(&t, buf); +#endiftime_r(&t, buf); #endif buf[24] = 0; // don't want the \n } @@ -37,7 +42,11 @@ namespace mongo { inline string time_t_to_String(time_t t = time(0) ) { char buf[64]; #if defined(_WIN32) - ctime_s(buf, sizeof(buf), &t); + #if defined(_MSC_VER) + ctime_s(buf, sizeof(buf), &t); + #else + _ctime64_s(buf, sizeof(buf), &t); + #endif //_MSC_VER #else ctime_r(&t, buf); #endif @@ -48,7 +57,11 @@ namespace mongo { inline string time_t_to_String_no_year(time_t t) { char buf[64]; #if defined(_WIN32) - ctime_s(buf, sizeof(buf), &t); + #if defined(_MSC_VER) + ctime_s(buf, sizeof(buf), &t); + #else + _ctime64_s(buf, sizeof(buf), &t); + #endif //_MSC_VER #else ctime_r(&t, buf); #endif @@ -59,7 +72,11 @@ namespace mongo { inline string time_t_to_String_short(time_t t) { char buf[64]; #if defined(_WIN32) - ctime_s(buf, sizeof(buf), &t); + #if defined(_MSC_VER) + ctime_s(buf, sizeof(buf), &t); + #else + _ctime64_s(buf, sizeof(buf), &t); + #endif //_MSC_VER #else ctime_r(&t, buf); #endif diff --git a/client/mongo_client_lib.cpp b/client/mongo_client_lib.cpp index 58e3f6c..2964273 100644 --- a/client/mongo_client_lib.cpp +++ b/client/mongo_client_lib.cpp @@ -80,3 +80,13 @@ extern "C" { #include "../util/md5.c" } +int CALLBACK WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow +) +{ +return 0; +} + diff --git a/db/nonce.cpp b/db/nonce.cpp index 379e88f..af75960 100644 --- a/db/nonce.cpp +++ b/db/nonce.cpp @@ -59,10 +59,14 @@ namespace mongo { _devrandom->read((char*)&n, sizeof(n)); massert(10355 , "devrandom failed", !_devrandom->fail()); #elif defined(_WIN32) + #if defined (_MSC_VER) unsigned a=0, b=0; assert( rand_s(&a) == 0 ); assert( rand_s(&b) == 0 ); n = (((unsigned long long)a)<<32) | b; + #else + n = (((unsigned long long)rand())<<32) | rand(); + #endif // _MSC_VER #else n = (((unsigned long long)random())<<32) | random(); #endif diff --git a/util/text.cpp b/util/text.cpp index 51a2556..6a4cfc2 100644 --- a/util/text.cpp +++ b/util/text.cpp @@ -91,7 +91,7 @@ namespace mongo { } throw boost::system::system_error( - ::GetLastError(), boost::system::system_category); + ::GetLastError(), boost::system::system_category()); } #if defined(_UNICODE) diff --git a/util/time_support.h b/util/time_support.h index ca17807..bd0a8f6 100644 --- a/util/time_support.h +++ b/util/time_support.h @@ -28,10 +28,17 @@ namespace mongo { inline void time_t_to_Struct(time_t t, struct tm * buf , bool local = false ) { #if defined(_WIN32) + #if defined(_MSC_VER) if ( local ) localtime_s( buf , &t ); else gmtime_s(buf, &t); + #else + if ( local ) + localtime_s( buf , &t ); + else + _gmtime64_s(buf, &t); + #endif //_MSC_VER #else if ( local ) localtime_r(&t, buf); diff --git a/util/util.cpp b/util/util.cpp index 356c640..b6bb27e 100644 --- a/util/util.cpp +++ b/util/util.cpp @@ -78,7 +78,7 @@ namespace mongo { return 0; } -#if defined(_WIN32) +#if defined(_WIN32) && defined(_MSC_VER) #define MS_VC_EXCEPTION 0x406D1388 #pragma pack(push,8) typedef struct tagTHREADNAME_INFO { -- 1.7.7.GIT