5 typedef HANDLE thread_t;
6 typedef CRITICAL_SECTION mutex_t;
8 static inline bool thread_create(thread_t *tid, void (*func)(void *), void *arg) {
9 *tid = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, NULL);
12 static inline void thread_destroy(thread_t *tid) {
13 WaitForSingleObject(tid, 0);
16 static inline void mutex_create(mutex_t *mutex) {
17 InitializeCriticalSection(mutex);
19 static inline void mutex_lock(mutex_t *mutex) {
20 EnterCriticalSection(mutex);
22 static inline void mutex_unlock(mutex_t *mutex) {
23 LeaveCriticalSection(mutex);
28 typedef pthread_t thread_t;
29 typedef pthread_mutex_t mutex_t;
31 static inline bool thread_create(thread_t *tid, void (*func)(void *), void *arg) {
36 pthread_sigmask(SIG_SETMASK, &block, &old);
37 result = pthread_create(tid, NULL, (void *(*)(void *))func, arg);
38 pthread_sigmask(SIG_SETMASK, &old, NULL);
41 static inline void thread_destroy(thread_t *tid) {
43 pthread_join(*tid, NULL);
45 static inline void mutex_create(mutex_t *mutex) {
46 pthread_mutex_init(mutex, NULL);
49 #define mutex_lock(m) logger(LOG_DEBUG, "mutex_lock() at " __FILE__ " line %d", __LINE__); pthread_mutex_lock(m)
50 #define mutex_unlock(m) logger(LOG_DEBUG, "mutex_unlock() at " __FILE__ " line %d", __LINE__); pthread_mutex_unlock(m)
52 static inline void mutex_lock(mutex_t *mutex) {
53 pthread_mutex_lock(mutex);
55 static inline void mutex_unlock(mutex_t *mutex) {
56 pthread_mutex_unlock(mutex);