diff options
Diffstat (limited to 'src/threading.h')
-rw-r--r-- | src/threading.h | 22 |
1 files changed, 15 insertions, 7 deletions
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 }; | |||
59 | */ | 59 | */ |
60 | 60 | ||
61 | #if THREADAPI == THREADAPI_WINDOWS | 61 | #if THREADAPI == THREADAPI_WINDOWS |
62 | #if defined ( PLATFORM_XBOX) | 62 | #if defined( PLATFORM_XBOX) |
63 | #include <xtl.h> | 63 | #include <xtl.h> |
64 | #else // !PLATFORM_XBOX | 64 | #else // !PLATFORM_XBOX |
65 | #define WIN32_LEAN_AND_MEAN | 65 | #define WIN32_LEAN_AND_MEAN |
66 | // 'SignalObjectAndWait' needs this (targets Windows 2000 and above) | 66 | // CONDITION_VARIABLE needs version 0x0600+ |
67 | #ifndef _WIN32_WINNT // already defined by TDSM-Mingw64, so avoid a warning in that case | 67 | // _WIN32_WINNT value is already defined by MinGW, but not by MSVC |
68 | #define _WIN32_WINNT 0x0400 | 68 | #ifndef _WIN32_WINNT |
69 | #define _WIN32_WINNT 0x0600 | ||
69 | #endif // _WIN32_WINNT | 70 | #endif // _WIN32_WINNT |
70 | #include <windows.h> | 71 | #include <windows.h> |
71 | #endif // !PLATFORM_XBOX | 72 | #endif // !PLATFORM_XBOX |
72 | #include <process.h> | 73 | #include <process.h> |
73 | 74 | ||
75 | /* | ||
76 | #define XSTR(x) STR(x) | ||
77 | #define STR(x) #x | ||
78 | #pragma message( "The value of _WIN32_WINNT: " XSTR(_WIN32_WINNT)) | ||
79 | */ | ||
80 | |||
74 | // MSDN: http://msdn2.microsoft.com/en-us/library/ms684254.aspx | 81 | // MSDN: http://msdn2.microsoft.com/en-us/library/ms684254.aspx |
75 | // | 82 | // |
76 | // CRITICAL_SECTION can be used for simple code protection. Mutexes are | 83 | // CRITICAL_SECTION can be used for simple code protection. Mutexes are |
77 | // needed for use with the SIGNAL system. | 84 | // needed for use with the SIGNAL system. |
78 | // | 85 | // |
79 | 86 | ||
80 | #if WINVER <= 0x0400 // Windows NT4: use a signal | 87 | #if _WIN32_WINNT < 0x0600 // CONDITION_VARIABLE aren't available, use a signal |
88 | |||
81 | typedef struct | 89 | typedef struct |
82 | { | 90 | { |
83 | CRITICAL_SECTION signalCS; | 91 | CRITICAL_SECTION signalCS; |
@@ -94,7 +102,7 @@ enum e_status { PENDING, RUNNING, WAITING, DONE, ERROR_ST, CANCELLED }; | |||
94 | void MUTEX_LOCK( MUTEX_T* ref); | 102 | void MUTEX_LOCK( MUTEX_T* ref); |
95 | void MUTEX_UNLOCK( MUTEX_T* ref); | 103 | void MUTEX_UNLOCK( MUTEX_T* ref); |
96 | 104 | ||
97 | #else // Vista and above: use a condition variable | 105 | #else // CONDITION_VARIABLE are available, use them |
98 | 106 | ||
99 | #define SIGNAL_T CONDITION_VARIABLE | 107 | #define SIGNAL_T CONDITION_VARIABLE |
100 | #define MUTEX_T CRITICAL_SECTION | 108 | #define MUTEX_T CRITICAL_SECTION |
@@ -103,7 +111,7 @@ enum e_status { PENDING, RUNNING, WAITING, DONE, ERROR_ST, CANCELLED }; | |||
103 | #define MUTEX_LOCK( ref) EnterCriticalSection( ref) | 111 | #define MUTEX_LOCK( ref) EnterCriticalSection( ref) |
104 | #define MUTEX_UNLOCK( ref) LeaveCriticalSection( ref) | 112 | #define MUTEX_UNLOCK( ref) LeaveCriticalSection( ref) |
105 | 113 | ||
106 | #endif // // Vista and above | 114 | #endif // CONDITION_VARIABLE are available |
107 | 115 | ||
108 | #define MUTEX_RECURSIVE_INIT(ref) MUTEX_INIT(ref) /* always recursive in Win32 */ | 116 | #define MUTEX_RECURSIVE_INIT(ref) MUTEX_INIT(ref) /* always recursive in Win32 */ |
109 | 117 | ||