00001 #ifdef _WIN32 00002 00003 #include <windows.h> 00004 00005 #define MAX_SEM_COUNT 1024 // What are the tradeoffs with this value? 00006 00007 void* naNewLock() 00008 { 00009 LPCRITICAL_SECTION lock = malloc(sizeof(CRITICAL_SECTION)); 00010 InitializeCriticalSection(lock); 00011 return lock; 00012 } 00013 00014 void naLock(void* lock) { EnterCriticalSection((LPCRITICAL_SECTION)lock); } 00015 void naUnlock(void* lock) { LeaveCriticalSection((LPCRITICAL_SECTION)lock); } 00016 void naFreeLock(void* lock) { free(lock); } 00017 void* naNewSem() { return CreateSemaphore(0, 0, MAX_SEM_COUNT, 0); } 00018 void naSemDown(void* sem) { WaitForSingleObject((HANDLE)sem, INFINITE); } 00019 void naSemUp(void* sem, int count) { ReleaseSemaphore(sem, count, 0); } 00020 void naFreeSem(void* sem) { ReleaseSemaphore(sem, 1, 0); } 00021 00022 #endif 00023 00024 extern int GccWarningWorkaround_IsoCForbidsAnEmptySourceFile;