]> git.mxchange.org Git - simgear.git/blob - simgear/nasal/thread-win32.c
Olaf Flebbe:
[simgear.git] / simgear / nasal / thread-win32.c
1 #ifdef _WIN32
2
3 #include <windows.h>
4
5 #define MAX_SEM_COUNT 1024 // What are the tradeoffs with this value?
6
7 void* naNewLock()
8 {
9     LPCRITICAL_SECTION lock = malloc(sizeof(CRITICAL_SECTION));
10     InitializeCriticalSection(lock);
11     return lock;
12 }
13
14 void  naLock(void* lock)   { EnterCriticalSection((LPCRITICAL_SECTION)lock); }
15 void  naUnlock(void* lock) { LeaveCriticalSection((LPCRITICAL_SECTION)lock); }
16 void* naNewSem()           { return CreateSemaphore(0, 0, MAX_SEM_COUNT, 0); }
17 void  naSemDown(void* sem) { WaitForSingleObject((HANDLE)sem, INFINITE); }
18 void  naSemUpAll(void* sem, int count) { ReleaseSemaphore(sem, count, 0); }
19
20 #endif
21
22 extern int GccWarningWorkaround_IsoCForbidsAnEmptySourceFile;