]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - thread_sdl.c
cl_minfps: apply r_refdef.view.quality to reliefmapping LOD distance if reliefmapping...
[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         Sys_PrintfToTerminal("%p mutex 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         Sys_PrintfToTerminal("%p mutex 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         Sys_PrintfToTerminal("%p mutex 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         Sys_PrintfToTerminal("%p mutex unlock %s:%i\n" , mutex, filename, fileline);
49 #endif
50         return SDL_UnlockMutex((SDL_mutex *)mutex);
51 }
52
53 void *_Thread_CreateCond(const char *filename, int fileline)
54 {
55         void *cond = (void *)SDL_CreateCond();
56 #ifdef THREADDEBUG
57         Sys_PrintfToTerminal("%p cond create %s:%i\n"   , cond, filename, fileline);
58 #endif
59         return cond;
60 }
61
62 void _Thread_DestroyCond(void *cond, const char *filename, int fileline)
63 {
64 #ifdef THREADDEBUG
65         Sys_PrintfToTerminal("%p cond destroy %s:%i\n"   , cond, filename, fileline);
66 #endif
67         SDL_DestroyCond((SDL_cond *)cond);
68 }
69
70 int _Thread_CondSignal(void *cond, const char *filename, int fileline)
71 {
72 #ifdef THREADDEBUG
73         Sys_PrintfToTerminal("%p cond signal %s:%i\n"   , cond, filename, fileline);
74 #endif
75         return SDL_CondSignal((SDL_cond *)cond);
76 }
77
78 int _Thread_CondBroadcast(void *cond, const char *filename, int fileline)
79 {
80 #ifdef THREADDEBUG
81         Sys_PrintfToTerminal("%p cond broadcast %s:%i\n"   , cond, filename, fileline);
82 #endif
83         return SDL_CondBroadcast((SDL_cond *)cond);
84 }
85
86 int _Thread_CondWait(void *cond, void *mutex, const char *filename, int fileline)
87 {
88 #ifdef THREADDEBUG
89         Sys_PrintfToTerminal("%p cond wait %s:%i\n"   , cond, filename, fileline);
90 #endif
91         return SDL_CondWait((SDL_cond *)cond, (SDL_mutex *)mutex);
92 }
93
94 void *_Thread_CreateThread(int (*fn)(void *), void *data, const char *filename, int fileline)
95 {
96         void *thread = (void *)SDL_CreateThread(fn, data);
97 #ifdef THREADDEBUG
98         Sys_PrintfToTerminal("%p thread create %s:%i\n"   , thread, filename, fileline);
99 #endif
100         return thread;
101 }
102
103 int _Thread_WaitThread(void *thread, int retval, const char *filename, int fileline)
104 {
105         int status = retval;
106 #ifdef THREADDEBUG
107         Sys_PrintfToTerminal("%p thread wait %s:%i\n"   , thread, filename, fileline);
108 #endif
109         SDL_WaitThread((SDL_Thread *)thread, &status);
110         return status;
111 }
112
113