3#ifndef __GSPLATFORMTHREAD_H__
4#define __GSPLATFORMTHREAD_H__
19 typedef CRITICAL_SECTION GSICriticalSection;
20 typedef HANDLE GSISemaphoreID;
21 typedef HANDLE GSIThreadID;
22 typedef DWORD (WINAPI *GSThreadFunc)(
void *arg);
25 typedef int GSIThreadID;
26 typedef int GSISemaphoreID;
30 GSISemaphoreID mSemaphore;
31 GSIThreadID mOwnerThread;
35 typedef void (*GSThreadFunc)(
void *arg);
38 typedef OSMutex GSICriticalSection;
50 typedef void (*GSThreadFunc)(
void *arg);
52#elif defined(_REVOLUTION)
53 typedef OSMutex GSICriticalSection;
54 typedef OSSemaphore GSISemaphoreID;
60 typedef void *(*GSThreadFunc)(
void *arg);
64 #define GSI_NO_THREADS
65 typedef int GSIThreadID;
66 typedef int GSISemaphoreID;
70 GSISemaphoreID mSemaphore;
71 GSIThreadID mOwnerThread;
75 typedef void (*GSThreadFunc)(
void *arg);
79 #define GSI_NO_THREADS
80 typedef int GSIThreadID;
81 typedef int GSISemaphoreID;
85 GSISemaphoreID mSemaphore;
86 GSIThreadID mOwnerThread;
90 typedef void (*GSThreadFunc)(
void *arg);
93 #if defined(__OpenBSD__)
97 typedef pthread_mutex_t GSICriticalSection;
100 pthread_mutex_t mLock;
109 typedef void (*GSThreadFunc)(
void *arg);
112 #define GSI_NO_THREADS
116 #define GSI_INFINITE INFINITE
118 #define GSI_INFINITE (gsi_u32)(-1)
122#if !defined(GSI_NO_THREADS)
125 #define gsiInterlockedIncrement(a) InterlockedIncrement((long*)a)
126 #define gsiInterlockedDecrement(a) InterlockedDecrement((long*)a)
128 gsi_u32 gsiInterlockedIncrement(gsi_u32* num);
129 gsi_u32 gsiInterlockedDecrement(gsi_u32* num);
132 #elif defined(_NITRO)
133 gsi_u32 gsiInterlockedIncrement(gsi_u32* num);
134 gsi_u32 gsiInterlockedDecrement(gsi_u32* num);
135 #elif defined(_REVOLUTION)
136 gsi_u32 gsiInterlockedIncrement(gsi_u32* num);
137 gsi_u32 gsiInterlockedDecrement(gsi_u32* num);
139 gsi_u32 gsiInterlockedIncrement(gsi_u32* num);
140 gsi_u32 gsiInterlockedDecrement(gsi_u32* num);
145 #define gsiInterlockedIncrement(a) (++(*a))
146 #define gsiInterlockedDecrement(a) (--(*a))
153#if !defined(GSI_NO_THREADS)
154 int gsiStartThread(GSThreadFunc aThreadFunc, gsi_u32 theStackSize,
void *arg, GSIThreadID* theThreadIdOut);
155 void gsiCancelThread(GSIThreadID theThreadID);
156 void gsiExitThread(GSIThreadID theThreadID);
157 void gsiCleanupThread(GSIThreadID theThreadID);
160 gsi_u32 gsiHasThreadShutdown(GSIThreadID theThreadID);
163 void gsiInitializeCriticalSection(GSICriticalSection *theCrit);
164 void gsiEnterCriticalSection(GSICriticalSection *theCrit);
165 void gsiLeaveCriticalSection(GSICriticalSection *theCrit);
166 void gsiDeleteCriticalSection(GSICriticalSection *theCrit);
169 GSISemaphoreID gsiCreateSemaphore(gsi_i32 theInitialCount, gsi_i32 theMaxCount,
char* theName);
170 gsi_u32 gsiWaitForSemaphore(GSISemaphoreID theSemaphore, gsi_u32 theTimeoutMs);
171 void gsiReleaseSemaphore(GSISemaphoreID theSemaphore, gsi_i32 theReleaseCount);
172 void gsiCloseSemaphore(GSISemaphoreID theSemaphore);
176 #define gsiStartThread(a, b, c, d) (-1)
177 #define gsiCancelThread(a)
178 #define gsiExitThread(a)
179 #define gsiCleanupThread(a)
181 #define gsiHasThreadShutdown(a) (1)
183 #define gsiInitializeCriticalSection(a)
184 #define gsiEnterCriticalSection(a)
185 #define gsiLeaveCriticalSection(a)
186 #define gsiDeleteCriticalSection(a)
188 #define gsiCreateSemaphore(a,b,c) (-1)
189 #define gsiWaitForSemaphore(a,b) (0)
190 #define gsiReleaseSemaphore(a,b)
191 #define gsiCloseSemaphore(a)