aboutsummaryrefslogtreecommitdiff
path: root/C/Threads.h
diff options
context:
space:
mode:
Diffstat (limited to 'C/Threads.h')
-rw-r--r--C/Threads.h20
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
22023-04-02 : Igor Pavlov : Public domain */ 22024-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
23Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER
24#define _GNU_SOURCE
25Z7_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
176typedef struct _CEvent 185typedef 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);
199WRes Event_Close(CEvent *p); 208WRes Event_Close(CEvent *p);
200 209
201 210
202typedef struct _CSemaphore 211typedef struct
203{ 212{
204 int _created; 213 int _created;
205 UInt32 _count; 214 UInt32 _count;
@@ -219,7 +228,7 @@ WRes Semaphore_Wait(CSemaphore *p);
219WRes Semaphore_Close(CSemaphore *p); 228WRes Semaphore_Close(CSemaphore *p);
220 229
221 230
222typedef struct _CCriticalSection 231typedef 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);
230void CriticalSection_Leave(CCriticalSection *cs); 239void CriticalSection_Leave(CCriticalSection *cs);
231 240
232LONG InterlockedIncrement(LONG volatile *addend); 241LONG InterlockedIncrement(LONG volatile *addend);
242LONG InterlockedDecrement(LONG volatile *addend);
233 243
234#endif // _WIN32 244#endif // _WIN32
235 245