diff options
Diffstat (limited to 'C/Threads.h')
-rw-r--r-- | C/Threads.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/C/Threads.h b/C/Threads.h index 4028464..c1484a2 100644 --- a/C/Threads.h +++ b/C/Threads.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* Threads.h -- multithreading library | 1 | /* Threads.h -- multithreading library |
2 | 2023-04-02 : Igor Pavlov : Public domain */ | 2 | 2024-03-28 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #ifndef ZIP7_INC_THREADS_H | 4 | #ifndef ZIP7_INC_THREADS_H |
5 | #define ZIP7_INC_THREADS_H | 5 | #define ZIP7_INC_THREADS_H |
@@ -9,12 +9,21 @@ | |||
9 | 9 | ||
10 | #else | 10 | #else |
11 | 11 | ||
12 | #include "Compiler.h" | ||
13 | |||
14 | // #define Z7_AFFINITY_DISABLE | ||
12 | #if defined(__linux__) | 15 | #if defined(__linux__) |
13 | #if !defined(__APPLE__) && !defined(_AIX) && !defined(__ANDROID__) | 16 | #if !defined(__APPLE__) && !defined(_AIX) && !defined(__ANDROID__) |
14 | #ifndef Z7_AFFINITY_DISABLE | 17 | #ifndef Z7_AFFINITY_DISABLE |
15 | #define Z7_AFFINITY_SUPPORTED | 18 | #define Z7_AFFINITY_SUPPORTED |
16 | // #pragma message(" ==== Z7_AFFINITY_SUPPORTED") | 19 | // #pragma message(" ==== Z7_AFFINITY_SUPPORTED") |
17 | // #define _GNU_SOURCE | 20 | #if !defined(_GNU_SOURCE) |
21 | // #pragma message(" ==== _GNU_SOURCE set") | ||
22 | // we need _GNU_SOURCE for cpu_set_t, if we compile for MUSL | ||
23 | Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER | ||
24 | #define _GNU_SOURCE | ||
25 | Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER | ||
26 | #endif | ||
18 | #endif | 27 | #endif |
19 | #endif | 28 | #endif |
20 | #endif | 29 | #endif |
@@ -173,7 +182,7 @@ WRes CriticalSection_Init(CCriticalSection *p); | |||
173 | 182 | ||
174 | #else // _WIN32 | 183 | #else // _WIN32 |
175 | 184 | ||
176 | typedef struct _CEvent | 185 | typedef struct |
177 | { | 186 | { |
178 | int _created; | 187 | int _created; |
179 | int _manual_reset; | 188 | int _manual_reset; |
@@ -199,7 +208,7 @@ WRes Event_Wait(CEvent *p); | |||
199 | WRes Event_Close(CEvent *p); | 208 | WRes Event_Close(CEvent *p); |
200 | 209 | ||
201 | 210 | ||
202 | typedef struct _CSemaphore | 211 | typedef struct |
203 | { | 212 | { |
204 | int _created; | 213 | int _created; |
205 | UInt32 _count; | 214 | UInt32 _count; |
@@ -219,7 +228,7 @@ WRes Semaphore_Wait(CSemaphore *p); | |||
219 | WRes Semaphore_Close(CSemaphore *p); | 228 | WRes Semaphore_Close(CSemaphore *p); |
220 | 229 | ||
221 | 230 | ||
222 | typedef struct _CCriticalSection | 231 | typedef struct |
223 | { | 232 | { |
224 | pthread_mutex_t _mutex; | 233 | pthread_mutex_t _mutex; |
225 | } CCriticalSection; | 234 | } CCriticalSection; |
@@ -230,6 +239,7 @@ void CriticalSection_Enter(CCriticalSection *cs); | |||
230 | void CriticalSection_Leave(CCriticalSection *cs); | 239 | void CriticalSection_Leave(CCriticalSection *cs); |
231 | 240 | ||
232 | LONG InterlockedIncrement(LONG volatile *addend); | 241 | LONG InterlockedIncrement(LONG volatile *addend); |
242 | LONG InterlockedDecrement(LONG volatile *addend); | ||
233 | 243 | ||
234 | #endif // _WIN32 | 244 | #endif // _WIN32 |
235 | 245 | ||