From f09d08be42737dd55ad6d75f6ba0385dc45354ef Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Wed, 26 Feb 2014 17:24:35 +0100 Subject: Fix some MinGW _WIN32_WINNT-related build issues --- src/threading.c | 10 +++++----- src/threading.h | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/threading.c b/src/threading.c index 5a3e64b..3e181ba 100644 --- a/src/threading.c +++ b/src/threading.c @@ -248,7 +248,7 @@ static void prepare_timeout( struct timespec *ts, time_d abs_secs ) { #if THREADAPI == THREADAPI_WINDOWS -#if WINVER <= 0x0400 // Windows NT4: Use Mutexes with Events +#if _WIN32_WINNT < 0x0600 // CONDITION_VARIABLE aren't available // void MUTEX_INIT( MUTEX_T *ref ) { *ref= CreateMutex( NULL /*security attr*/, FALSE /*not locked*/, NULL ); @@ -270,7 +270,7 @@ static void prepare_timeout( struct timespec *ts, time_d abs_secs ) { if (!ReleaseMutex(*ref)) FAIL( "ReleaseMutex", GetLastError() ); } -#endif // Windows NT4 +#endif // CONDITION_VARIABLE aren't available static int const gs_prio_remap[] = { @@ -384,7 +384,7 @@ bool_t THREAD_WAIT_IMPL( THREAD_T *ref, double secs) #endif // !__GNUC__ } -#if WINVER <= 0x0400 // Windows NT4 +#if _WIN32_WINNT < 0x0600 // CONDITION_VARIABLE aren't available void SIGNAL_INIT( SIGNAL_T* ref) { @@ -477,7 +477,7 @@ bool_t THREAD_WAIT_IMPL( THREAD_T *ref, double secs) FAIL( "WaitForSingleObject", GetLastError()); } -#else // Windows Vista and above: condition variables exist, use them +#else // CONDITION_VARIABLE are available, use them // void SIGNAL_INIT( SIGNAL_T *ref ) @@ -534,7 +534,7 @@ bool_t THREAD_WAIT_IMPL( THREAD_T *ref, double secs) WakeAllConditionVariable( ref); } -#endif // Windows Vista and above +#endif // CONDITION_VARIABLE are available #else // THREADAPI == THREADAPI_PTHREAD // PThread (Linux, OS X, ...) diff --git a/src/threading.h b/src/threading.h index 0698355..bfa9ab8 100644 --- a/src/threading.h +++ b/src/threading.h @@ -59,25 +59,33 @@ enum e_status { PENDING, RUNNING, WAITING, DONE, ERROR_ST, CANCELLED }; */ #if THREADAPI == THREADAPI_WINDOWS - #if defined ( PLATFORM_XBOX) + #if defined( PLATFORM_XBOX) #include #else // !PLATFORM_XBOX #define WIN32_LEAN_AND_MEAN - // 'SignalObjectAndWait' needs this (targets Windows 2000 and above) - #ifndef _WIN32_WINNT // already defined by TDSM-Mingw64, so avoid a warning in that case - #define _WIN32_WINNT 0x0400 + // CONDITION_VARIABLE needs version 0x0600+ + // _WIN32_WINNT value is already defined by MinGW, but not by MSVC + #ifndef _WIN32_WINNT + #define _WIN32_WINNT 0x0600 #endif // _WIN32_WINNT #include #endif // !PLATFORM_XBOX #include +/* +#define XSTR(x) STR(x) +#define STR(x) #x +#pragma message( "The value of _WIN32_WINNT: " XSTR(_WIN32_WINNT)) +*/ + // MSDN: http://msdn2.microsoft.com/en-us/library/ms684254.aspx // // CRITICAL_SECTION can be used for simple code protection. Mutexes are // needed for use with the SIGNAL system. // - #if WINVER <= 0x0400 // Windows NT4: use a signal + #if _WIN32_WINNT < 0x0600 // CONDITION_VARIABLE aren't available, use a signal + typedef struct { CRITICAL_SECTION signalCS; @@ -94,7 +102,7 @@ enum e_status { PENDING, RUNNING, WAITING, DONE, ERROR_ST, CANCELLED }; void MUTEX_LOCK( MUTEX_T* ref); void MUTEX_UNLOCK( MUTEX_T* ref); - #else // Vista and above: use a condition variable + #else // CONDITION_VARIABLE are available, use them #define SIGNAL_T CONDITION_VARIABLE #define MUTEX_T CRITICAL_SECTION @@ -103,7 +111,7 @@ enum e_status { PENDING, RUNNING, WAITING, DONE, ERROR_ST, CANCELLED }; #define MUTEX_LOCK( ref) EnterCriticalSection( ref) #define MUTEX_UNLOCK( ref) LeaveCriticalSection( ref) - #endif // // Vista and above + #endif // CONDITION_VARIABLE are available #define MUTEX_RECURSIVE_INIT(ref) MUTEX_INIT(ref) /* always recursive in Win32 */ -- cgit v1.2.3-55-g6feb