]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - thread_sdl.c
d857445a1a4a07b4492418e8d288ace4e842cae0
[xonotic/darkplaces.git] / thread_sdl.c
1 #include "quakedef.h"
2 #include "thread.h"
3 #include <SDL.h>
4 #include <SDL_thread.h>
5
6 int Thread_Init(void)
7 {
8         return 0;
9 }
10
11 void Thread_Shutdown(void)
12 {
13 }
14
15 qboolean Thread_HasThreads(void)
16 {
17         return true;
18 }
19
20 void *_Thread_CreateMutex(const char *filename, int fileline)
21 {
22         void *mutex = SDL_CreateMutex();
23 #ifdef THREADDEBUG
24         printf("%p create %s:%i\n" , mutex, filename, fileline);
25 #endif
26         return mutex;
27 }
28
29 void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
30 {
31 #ifdef THREADDEBUG
32         printf("%p destroy %s:%i\n", mutex, filename, fileline);
33 #endif
34         SDL_DestroyMutex((SDL_mutex *)mutex);
35 }
36
37 int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
38 {
39 #ifdef THREADDEBUG
40         printf("%p lock %s:%i\n"   , mutex, filename, fileline);
41 #endif
42         return SDL_LockMutex((SDL_mutex *)mutex);
43 }
44
45 int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline)
46 {
47 #ifdef THREADDEBUG
48         printf("%p unlock %s:%i\n" , mutex, filename, fileline);
49 #endif
50         return SDL_UnlockMutex((SDL_mutex *)mutex);
51 }
52
53 void *Thread_CreateCond(void)
54 {
55         return SDL_CreateCond();
56 }
57
58 void Thread_DestroyCond(void *cond)
59 {
60         SDL_DestroyCond((SDL_cond *)cond);
61 }
62
63 int Thread_CondSignal(void *cond)
64 {
65         return SDL_CondSignal((SDL_cond *)cond);
66 }
67
68 int Thread_CondBroadcast(void *cond)
69 {
70         return SDL_CondBroadcast((SDL_cond *)cond);
71 }
72
73 int Thread_CondWait(void *cond, void *mutex)
74 {
75         return SDL_CondWait((SDL_cond *)cond, (SDL_mutex *)mutex);
76 }
77
78 void *Thread_CreateThread(int (*fn)(void *), void *data)
79 {
80         return SDL_CreateThread(fn, data);
81 }
82
83 int Thread_WaitThread(void *thread, int retval)
84 {
85         int status = retval;
86         SDL_WaitThread((SDL_Thread *)thread, &status);
87         return status;
88 }
89
90