11 void Thread_Shutdown(void)
15 qboolean Thread_HasThreads(void)
20 void *Thread_CreateMutex(void)
22 pthread_mutex_t *mutexp = (pthread_mutex_t *) Z_Malloc(sizeof(pthread_mutex_t));
23 pthread_mutex_init(mutexp, NULL);
27 void Thread_DestroyMutex(void *mutex)
29 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
30 pthread_mutex_destroy(mutexp);
34 int Thread_LockMutex(void *mutex)
36 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
37 return pthread_mutex_lock(mutexp);
40 int Thread_UnlockMutex(void *mutex)
42 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
43 return pthread_mutex_unlock(mutexp);
46 void *Thread_CreateCond(void)
48 pthread_cond_t *condp = (pthread_cond_t *) Z_Malloc(sizeof(pthread_cond_t));
49 pthread_cond_init(condp, NULL);
53 void Thread_DestroyCond(void *cond)
55 pthread_cond_t *condp = (pthread_cond_t *) cond;
56 pthread_cond_destroy(condp);
60 int Thread_CondSignal(void *cond)
62 pthread_cond_t *condp = (pthread_cond_t *) cond;
63 return pthread_cond_signal(condp);
66 int Thread_CondBroadcast(void *cond)
68 pthread_cond_t *condp = (pthread_cond_t *) cond;
69 return pthread_cond_broadcast(condp);
72 int Thread_CondWait(void *cond, void *mutex)
74 pthread_cond_t *condp = (pthread_cond_t *) cond;
75 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
76 return pthread_cond_wait(condp, mutexp);
79 void *Thread_CreateThread(int (*fn)(void *), void *data)
81 pthread_t *threadp = (pthread_t *) Z_Malloc(sizeof(pthread_t));
82 int r = pthread_create(threadp, NULL, (void * (*) (void *)) fn, data);
91 int Thread_WaitThread(void *thread, int retval)
93 pthread_t *threadp = (pthread_t *) thread;
94 void *status = (void *) (intptr_t) retval;
95 pthread_join(*threadp, &status);
97 return (int) (intptr_t) status;