00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef __HPGS_MUTEX_H__
00035 #define __HPGS_MUTEX_H__
00036
00037 #ifndef __HPGS_H
00038 #include <hpgs.h>
00039 #endif
00040
00041 #ifdef WIN32
00042 #include <windows.h>
00043 typedef CRITICAL_SECTION hpgs_mutex_t;
00044 #else
00045 #include <pthread.h>
00046 typedef pthread_mutex_t hpgs_mutex_t;
00047 #endif
00048
00049 static void hpgs_mutex_init(hpgs_mutex_t *m);
00050 static void hpgs_mutex_destroy(hpgs_mutex_t *m);
00051 static void hpgs_mutex_lock(hpgs_mutex_t *m);
00052 static void hpgs_mutex_unlock(hpgs_mutex_t *m);
00053
00054 #ifdef WIN32
00055
00056 __inline__ void hpgs_mutex_init(hpgs_mutex_t *m)
00057 { InitializeCriticalSection(m); }
00058
00059 __inline__ void hpgs_mutex_destroy(hpgs_mutex_t *m)
00060 { DeleteCriticalSection(m); }
00061
00062 __inline__ void hpgs_mutex_lock(hpgs_mutex_t *m)
00063 { EnterCriticalSection(m); }
00064
00065 __inline__ void hpgs_mutex_unlock(hpgs_mutex_t *m)
00066 { LeaveCriticalSection(m); }
00067
00068 #else
00069
00070 __inline__ void hpgs_mutex_init(hpgs_mutex_t *m)
00071 { pthread_mutex_init(m,0); }
00072
00073 __inline__ void hpgs_mutex_destroy(hpgs_mutex_t *m)
00074 { pthread_mutex_destroy(m); }
00075
00076 __inline__ void hpgs_mutex_lock(hpgs_mutex_t *m)
00077 { pthread_mutex_lock(m); }
00078
00079 __inline__ void hpgs_mutex_unlock(hpgs_mutex_t *m)
00080 { pthread_mutex_unlock(m); }
00081
00082 #endif
00083
00084 #endif