00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef GMUTEX_H
00012 #define GMUTEX_H
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef WIN32
00026
00027 #include <windows.h>
00028
00029 typedef CRITICAL_SECTION GMutex;
00030
00031 #define gInitMutex(m) InitializeCriticalSection(m)
00032 #define gDestroyMutex(m) DeleteCriticalSection(m)
00033 #define gLockMutex(m) EnterCriticalSection(m)
00034 #define gUnlockMutex(m) LeaveCriticalSection(m)
00035
00036 #else // assume pthreads
00037
00038 #include <pthread.h>
00039
00040 typedef pthread_mutex_t GMutex;
00041
00042 #define gInitMutex(m) pthread_mutex_init(m, NULL)
00043 #define gDestroyMutex(m) pthread_mutex_destroy(m)
00044 #define gLockMutex(m) pthread_mutex_lock(m)
00045 #define gUnlockMutex(m) pthread_mutex_unlock(m)
00046
00047 #endif
00048
00049 #endif