diff options
Diffstat (limited to 'src/threading.h')
-rw-r--r-- | src/threading.h | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/threading.h b/src/threading.h index 1b218b9..e559910 100644 --- a/src/threading.h +++ b/src/threading.h | |||
@@ -64,7 +64,7 @@ enum e_status { PENDING, RUNNING, WAITING, DONE, ERROR_ST, CANCELLED }; | |||
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 | // 'SignalObjectAndWait' needs this (targets Windows 2000 and above) |
67 | #define _WIN32_WINNT 0x0400 | 67 | //#define _WIN32_WINNT 0x0500 Let the compiler decide depending on the host OS |
68 | #include <windows.h> | 68 | #include <windows.h> |
69 | #endif // !PLATFORM_XBOX | 69 | #endif // !PLATFORM_XBOX |
70 | #include <process.h> | 70 | #include <process.h> |
@@ -74,17 +74,31 @@ enum e_status { PENDING, RUNNING, WAITING, DONE, ERROR_ST, CANCELLED }; | |||
74 | // CRITICAL_SECTION can be used for simple code protection. Mutexes are | 74 | // CRITICAL_SECTION can be used for simple code protection. Mutexes are |
75 | // needed for use with the SIGNAL system. | 75 | // needed for use with the SIGNAL system. |
76 | // | 76 | // |
77 | #define MUTEX_T HANDLE | 77 | |
78 | void MUTEX_INIT( MUTEX_T *ref ); | 78 | #if WINVER <= 0x0400 // Windows NT4: use a signal |
79 | |||
80 | #define SIGNAL_T HANDLE | ||
81 | #define MUTEX_T HANDLE | ||
82 | void MUTEX_INIT( MUTEX_T* ref); | ||
83 | void MUTEX_FREE( MUTEX_T* ref); | ||
84 | void MUTEX_LOCK( MUTEX_T* ref); | ||
85 | void MUTEX_UNLOCK( MUTEX_T* ref); | ||
86 | |||
87 | #else // Vista and above: use a condition variable | ||
88 | |||
89 | #define SIGNAL_T CONDITION_VARIABLE | ||
90 | #define MUTEX_T CRITICAL_SECTION | ||
91 | #define MUTEX_INIT( ref) InitializeCriticalSection( ref) | ||
92 | #define MUTEX_FREE( ref) DeleteCriticalSection( ref) | ||
93 | #define MUTEX_LOCK( ref) EnterCriticalSection( ref) | ||
94 | #define MUTEX_UNLOCK( ref) LeaveCriticalSection( ref) | ||
95 | |||
96 | #endif // // Vista and above | ||
97 | |||
79 | #define MUTEX_RECURSIVE_INIT(ref) MUTEX_INIT(ref) /* always recursive in Win32 */ | 98 | #define MUTEX_RECURSIVE_INIT(ref) MUTEX_INIT(ref) /* always recursive in Win32 */ |
80 | void MUTEX_FREE( MUTEX_T *ref ); | ||
81 | void MUTEX_LOCK( MUTEX_T *ref ); | ||
82 | void MUTEX_UNLOCK( MUTEX_T *ref ); | ||
83 | 99 | ||
84 | typedef unsigned int THREAD_RETURN_T; | 100 | typedef unsigned int THREAD_RETURN_T; |
85 | 101 | ||
86 | #define SIGNAL_T HANDLE | ||
87 | |||
88 | #define YIELD() Sleep(0) | 102 | #define YIELD() Sleep(0) |
89 | #define THREAD_CALLCONV __stdcall | 103 | #define THREAD_CALLCONV __stdcall |
90 | #else // THREADAPI == THREADAPI_PTHREAD | 104 | #else // THREADAPI == THREADAPI_PTHREAD |