10 typedef HANDLE thread_t;
11 typedef CRITICAL_SECTION mutex_t;
13 static inline bool thread_create(thread_t *tid, void (*func)(void *), void *arg) {
14 *tid = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, NULL);
17 static inline void thread_destroy(thread_t *tid) {
18 WaitForSingleObject(tid, 0);
21 static inline void mutex_create(mutex_t *mutex) {
22 InitializeCriticalSection(mutex);
24 static inline void mutex_lock(mutex_t *mutex) {
25 EnterCriticalSection(mutex);
27 static inline void mutex_unlock(mutex_t *mutex) {
28 LeaveCriticalSection(mutex);
33 typedef pthread_t thread_t;
34 typedef pthread_mutex_t mutex_t;
36 static inline void thread_create(thread_t *tid, void (*func)(void *), void *arg) {
37 return !pthread_create(tid, NULL, (void *(*)(void *))func, arg);
39 static inline void thread_destroy(thread_t *tid) {
42 static inline void mutex_create(mutex_t *mutex) {
43 pthread_mutex_init(mutex, NULL);
45 static inline void mutex_lock(mutex_t *mutex) {
46 pthread_mutex_lock(mutex);
48 static inline void mutex_unlock(mutex_t *mutex) {
49 pthread_mutex_unlock(mutex);