SDL  2.0
SDL_thread.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../SDL_internal.h"
22 
23 /* System independent thread management routines for SDL */
24 
25 #include "SDL_assert.h"
26 #include "SDL_thread.h"
27 #include "SDL_thread_c.h"
28 #include "SDL_systhread.h"
29 #include "SDL_hints.h"
30 #include "../SDL_error_c.h"
31 
32 
35 {
36  static SDL_atomic_t SDL_tls_id;
37  return SDL_AtomicIncRef(&SDL_tls_id)+1;
38 }
39 
40 void *
42 {
43  SDL_TLSData *storage;
44 
45  storage = SDL_SYS_GetTLSData();
46  if (!storage || id == 0 || id > storage->limit) {
47  return NULL;
48  }
49  return storage->array[id-1].data;
50 }
51 
52 int
53 SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void *))
54 {
55  SDL_TLSData *storage;
56 
57  if (id == 0) {
58  return SDL_InvalidParamError("id");
59  }
60 
61  storage = SDL_SYS_GetTLSData();
62  if (!storage || (id > storage->limit)) {
63  unsigned int i, oldlimit, newlimit;
64 
65  oldlimit = storage ? storage->limit : 0;
66  newlimit = (id + TLS_ALLOC_CHUNKSIZE);
67  storage = (SDL_TLSData *)SDL_realloc(storage, sizeof(*storage)+(newlimit-1)*sizeof(storage->array[0]));
68  if (!storage) {
69  return SDL_OutOfMemory();
70  }
71  storage->limit = newlimit;
72  for (i = oldlimit; i < newlimit; ++i) {
73  storage->array[i].data = NULL;
74  storage->array[i].destructor = NULL;
75  }
76  if (SDL_SYS_SetTLSData(storage) != 0) {
77  return -1;
78  }
79  }
80 
81  storage->array[id-1].data = SDL_const_cast(void*, value);
82  storage->array[id-1].destructor = destructor;
83  return 0;
84 }
85 
86 static void
88 {
89  SDL_TLSData *storage;
90 
91  storage = SDL_SYS_GetTLSData();
92  if (storage) {
93  unsigned int i;
94  for (i = 0; i < storage->limit; ++i) {
95  if (storage->array[i].destructor) {
96  storage->array[i].destructor(storage->array[i].data);
97  }
98  }
100  SDL_free(storage);
101  }
102 }
103 
104 
105 /* This is a generic implementation of thread-local storage which doesn't
106  require additional OS support.
107 
108  It is not especially efficient and doesn't clean up thread-local storage
109  as threads exit. If there is a real OS that doesn't support thread-local
110  storage this implementation should be improved to be production quality.
111 */
112 
113 typedef struct SDL_TLSEntry {
117 } SDL_TLSEntry;
118 
121 
122 
123 SDL_TLSData *
125 {
127  SDL_TLSEntry *entry;
129 
130 #if !SDL_THREADS_DISABLED
131  if (!SDL_generic_TLS_mutex) {
132  static SDL_SpinLock tls_lock;
133  SDL_AtomicLock(&tls_lock);
134  if (!SDL_generic_TLS_mutex) {
138  if (!SDL_generic_TLS_mutex) {
139  SDL_AtomicUnlock(&tls_lock);
140  return NULL;
141  }
142  }
143  SDL_AtomicUnlock(&tls_lock);
144  }
145 #endif /* SDL_THREADS_DISABLED */
146 
149  for (entry = SDL_generic_TLS; entry; entry = entry->next) {
150  if (entry->thread == thread) {
151  storage = entry->storage;
152  break;
153  }
154  }
155 #if !SDL_THREADS_DISABLED
157 #endif
158 
159  return storage;
160 }
161 
162 int
164 {
166  SDL_TLSEntry *prev, *entry;
167 
168  /* SDL_Generic_GetTLSData() is always called first, so we can assume SDL_generic_TLS_mutex */
170  prev = NULL;
171  for (entry = SDL_generic_TLS; entry; entry = entry->next) {
172  if (entry->thread == thread) {
173  if (storage) {
174  entry->storage = storage;
175  } else {
176  if (prev) {
177  prev->next = entry->next;
178  } else {
179  SDL_generic_TLS = entry->next;
180  }
181  SDL_free(entry);
182  }
183  break;
184  }
185  prev = entry;
186  }
187  if (!entry) {
188  entry = (SDL_TLSEntry *)SDL_malloc(sizeof(*entry));
189  if (entry) {
190  entry->thread = thread;
191  entry->storage = storage;
192  entry->next = SDL_generic_TLS;
193  SDL_generic_TLS = entry;
194  }
195  }
197 
198  if (!entry) {
199  return SDL_OutOfMemory();
200  }
201  return 0;
202 }
203 
204 /* Routine to get the thread-specific error variable */
205 SDL_error *
207 {
208 #if SDL_THREADS_DISABLED
209  /* Non-thread-safe global error variable */
210  static SDL_error SDL_global_error;
211  return &SDL_global_error;
212 #else
213  static SDL_SpinLock tls_lock;
214  static SDL_bool tls_being_created;
215  static SDL_TLSID tls_errbuf;
216  static SDL_error SDL_global_errbuf;
217  const SDL_error *ALLOCATION_IN_PROGRESS = (SDL_error *)-1;
218  SDL_error *errbuf;
219 
220  /* tls_being_created is there simply to prevent recursion if SDL_TLSCreate() fails.
221  It also means it's possible for another thread to also use SDL_global_errbuf,
222  but that's very unlikely and hopefully won't cause issues.
223  */
224  if (!tls_errbuf && !tls_being_created) {
225  SDL_AtomicLock(&tls_lock);
226  if (!tls_errbuf) {
227  SDL_TLSID slot;
228  tls_being_created = SDL_TRUE;
229  slot = SDL_TLSCreate();
230  tls_being_created = SDL_FALSE;
232  tls_errbuf = slot;
233  }
234  SDL_AtomicUnlock(&tls_lock);
235  }
236  if (!tls_errbuf) {
237  return &SDL_global_errbuf;
238  }
239 
241  errbuf = (SDL_error *)SDL_TLSGet(tls_errbuf);
242  if (errbuf == ALLOCATION_IN_PROGRESS) {
243  return &SDL_global_errbuf;
244  }
245  if (!errbuf) {
246  /* Mark that we're in the middle of allocating our buffer */
247  SDL_TLSSet(tls_errbuf, ALLOCATION_IN_PROGRESS, NULL);
248  errbuf = (SDL_error *)SDL_malloc(sizeof(*errbuf));
249  if (!errbuf) {
250  SDL_TLSSet(tls_errbuf, NULL, NULL);
251  return &SDL_global_errbuf;
252  }
253  SDL_zerop(errbuf);
254  SDL_TLSSet(tls_errbuf, errbuf, SDL_free);
255  }
256  return errbuf;
257 #endif /* SDL_THREADS_DISABLED */
258 }
259 
260 
261 /* Arguments and callback to setup and run the user thread function */
262 typedef struct
263 {
264  int (SDLCALL * func) (void *);
265  void *data;
267  SDL_sem *wait;
268 } thread_args;
269 
270 void
272 {
273  thread_args *args = (thread_args *) data;
274  int (SDLCALL * userfunc) (void *) = args->func;
275  void *userdata = args->data;
276  SDL_Thread *thread = args->info;
277  int *statusloc = &thread->status;
278 
279  /* Perform any system-dependent setup - this function may not fail */
281 
282  /* Get the thread id */
283  thread->threadid = SDL_ThreadID();
284 
285  /* Wake up the parent thread */
286  SDL_SemPost(args->wait);
287 
288  /* Run the function */
289  *statusloc = userfunc(userdata);
290 
291  /* Clean up thread-local storage */
292  SDL_TLSCleanup();
293 
294  /* Mark us as ready to be joined (or detached) */
296  /* Clean up if something already detached us. */
298  if (thread->name) {
299  SDL_free(thread->name);
300  }
301  SDL_free(thread);
302  }
303  }
304 }
305 
306 #ifdef SDL_CreateThread
307 #undef SDL_CreateThread
308 #undef SDL_CreateThreadWithStackSize
309 #endif
310 #if SDL_DYNAMIC_API
311 #define SDL_CreateThread SDL_CreateThread_REAL
312 #define SDL_CreateThreadWithStackSize SDL_CreateThreadWithStackSize_REAL
313 #endif
314 
315 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
316 SDL_Thread *
317 SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
318  const char *name, const size_t stacksize, void *data,
319  pfnSDL_CurrentBeginThread pfnBeginThread,
320  pfnSDL_CurrentEndThread pfnEndThread)
321 #else
322 SDL_Thread *
324  const char *name, const size_t stacksize, void *data)
325 #endif
326 {
328  thread_args *args;
329  int ret;
330 
331  /* Allocate memory for the thread info structure */
332  thread = (SDL_Thread *) SDL_malloc(sizeof(*thread));
333  if (thread == NULL) {
334  SDL_OutOfMemory();
335  return (NULL);
336  }
337  SDL_zerop(thread);
338  thread->status = -1;
340 
341  /* Set up the arguments for the thread */
342  if (name != NULL) {
343  thread->name = SDL_strdup(name);
344  if (thread->name == NULL) {
345  SDL_OutOfMemory();
346  SDL_free(thread);
347  return (NULL);
348  }
349  }
350 
351  /* Set up the arguments for the thread */
352  args = (thread_args *) SDL_malloc(sizeof(*args));
353  if (args == NULL) {
354  SDL_OutOfMemory();
355  if (thread->name) {
356  SDL_free(thread->name);
357  }
358  SDL_free(thread);
359  return (NULL);
360  }
361  args->func = fn;
362  args->data = data;
363  args->info = thread;
364  args->wait = SDL_CreateSemaphore(0);
365  if (args->wait == NULL) {
366  if (thread->name) {
367  SDL_free(thread->name);
368  }
369  SDL_free(thread);
370  SDL_free(args);
371  return (NULL);
372  }
373 
374  thread->stacksize = stacksize;
375 
376  /* Create the thread and go! */
377 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
378  ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread);
379 #else
380  ret = SDL_SYS_CreateThread(thread, args);
381 #endif
382  if (ret >= 0) {
383  /* Wait for the thread function to use arguments */
384  SDL_SemWait(args->wait);
385  } else {
386  /* Oops, failed. Gotta free everything */
387  if (thread->name) {
388  SDL_free(thread->name);
389  }
390  SDL_free(thread);
391  thread = NULL;
392  }
393  SDL_DestroySemaphore(args->wait);
394  SDL_free(args);
395 
396  /* Everything is running now */
397  return (thread);
398 }
399 
400 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
402 SDL_CreateThread(int (SDLCALL * fn) (void *),
403  const char *name, void *data,
404  pfnSDL_CurrentBeginThread pfnBeginThread,
405  pfnSDL_CurrentEndThread pfnEndThread)
406 #else
408 SDL_CreateThread(int (SDLCALL * fn) (void *),
409  const char *name, void *data)
410 #endif
411 {
412  /* !!! FIXME: in 2.1, just make stackhint part of the usual API. */
413  const char *stackhint = SDL_GetHint(SDL_HINT_THREAD_STACK_SIZE);
414  size_t stacksize = 0;
415 
416  /* If the SDL_HINT_THREAD_STACK_SIZE exists, use it */
417  if (stackhint != NULL) {
418  char *endp = NULL;
419  const Sint64 hintval = SDL_strtoll(stackhint, &endp, 10);
420  if ((*stackhint != '\0') && (*endp == '\0')) { /* a valid number? */
421  if (hintval > 0) { /* reject bogus values. */
422  stacksize = (size_t) hintval;
423  }
424  }
425  }
426 
427 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
428  return SDL_CreateThreadWithStackSize(fn, name, stacksize, data, pfnBeginThread, pfnEndThread);
429 #else
430  return SDL_CreateThreadWithStackSize(fn, name, stacksize, data);
431 #endif
432 }
433 
434 SDL_Thread *
435 SDL_CreateThreadInternal(int (SDLCALL * fn) (void *), const char *name,
436  const size_t stacksize, void *data) {
437 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
438  return SDL_CreateThreadWithStackSize(fn, name, stacksize, data, NULL, NULL);
439 #else
440  return SDL_CreateThreadWithStackSize(fn, name, stacksize, data);
441 #endif
442 }
443 
446 {
448 
449  if (thread) {
450  id = thread->threadid;
451  } else {
452  id = SDL_ThreadID();
453  }
454  return id;
455 }
456 
457 const char *
459 {
460  if (thread) {
461  return thread->name;
462  } else {
463  return NULL;
464  }
465 }
466 
467 int
469 {
470  return SDL_SYS_SetThreadPriority(priority);
471 }
472 
473 void
475 {
476  if (thread) {
478  if (status) {
479  *status = thread->status;
480  }
481  if (thread->name) {
482  SDL_free(thread->name);
483  }
484  SDL_free(thread);
485  }
486 }
487 
488 void
490 {
491  if (!thread) {
492  return;
493  }
494 
495  /* Grab dibs if the state is alive+joinable. */
498  } else {
499  /* all other states are pretty final, see where we landed. */
500  const int thread_state = SDL_AtomicGet(&thread->state);
501  if ((thread_state == SDL_THREAD_STATE_DETACHED) || (thread_state == SDL_THREAD_STATE_CLEANED)) {
502  return; /* already detached (you shouldn't call this twice!) */
503  } else if (thread_state == SDL_THREAD_STATE_ZOMBIE) {
504  SDL_WaitThread(thread, NULL); /* already done, clean it up. */
505  } else {
506  SDL_assert(0 && "Unexpected thread state");
507  }
508  }
509 }
510 
511 /* vi: set ts=4 sw=4 expandtab: */
SDL_TLSData
Definition: SDL_thread_c.h:70
SDL_HINT_THREAD_STACK_SIZE
#define SDL_HINT_THREAD_STACK_SIZE
A string specifying SDL's threads stack size in bytes or "0" for the backend's default size.
Definition: SDL_hints.h:731
thread_args::func
int(* func)(void *)
Definition: SDL_thread.c:264
SDL_THREAD_STATE_DETACHED
@ SDL_THREAD_STATE_DETACHED
Definition: SDL_thread_c.h:48
SDL_DetachThread
void SDL_DetachThread(SDL_Thread *thread)
Definition: SDL_thread.c:489
DECLSPEC
#define DECLSPEC
Definition: SDL_internal.h:48
pfnSDL_CurrentEndThread
void(__cdecl * pfnSDL_CurrentEndThread)(unsigned code)
Definition: SDL_thread.h:99
Sint64
int64_t Sint64
Definition: SDL_stdinc.h:210
SDL_systhread.h
SDL_Generic_SetTLSData
int SDL_Generic_SetTLSData(SDL_TLSData *storage)
Definition: SDL_thread.c:163
SDL_THREAD_STATE_ALIVE
@ SDL_THREAD_STATE_ALIVE
Definition: SDL_thread_c.h:47
thread_args::data
void * data
Definition: SDL_thread.c:265
TLS_ALLOC_CHUNKSIZE
#define TLS_ALLOC_CHUNKSIZE
Definition: SDL_thread_c.h:79
SDL_TLSData::destructor
void(* destructor)(void *)
Definition: SDL_thread_c.h:74
SDL_CreateSemaphore
#define SDL_CreateSemaphore
Definition: SDL_dynapi_overrides.h:264
SDL_AtomicCAS
#define SDL_AtomicCAS
Definition: SDL_dynapi_overrides.h:66
SDL_LockMutex
#define SDL_LockMutex
Definition: SDL_dynapi_overrides.h:260
SDL_CreateThread
#define SDL_CreateThread
Definition: SDL_thread.c:311
NULL
#define NULL
Definition: begin_code.h:167
SDL_RunThread
void SDL_RunThread(void *data)
Definition: SDL_thread.c:271
SDL_MemoryBarrierRelease
#define SDL_MemoryBarrierRelease()
Definition: SDL_atomic.h:207
size_t
unsigned int size_t
Definition: SDL_config_windows.h:68
pfnSDL_CurrentBeginThread
uintptr_t(__cdecl * pfnSDL_CurrentBeginThread)(void *, unsigned, unsigned(__stdcall *func)(void *), void *, unsigned, unsigned *)
Definition: SDL_thread.h:97
SDL_zerop
#define SDL_zerop(x)
Definition: SDL_stdinc.h:419
SDL_AtomicLock
#define SDL_AtomicLock
Definition: SDL_dynapi_overrides.h:64
SDL_mutex
Definition: SDL_sysmutex.c:30
SDL_const_cast
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:139
SDL_TLSData::array
struct SDL_TLSData::@32 array[1]
mutex
static SDL_mutex * mutex
Definition: testlock.c:23
SDLCALL
#define SDLCALL
Definition: SDL_internal.h:49
SDL_SYS_SetupThread
void SDL_SYS_SetupThread(const char *name)
Definition: SDL_systhread.c:42
SDL_realloc
#define SDL_realloc
Definition: SDL_dynapi_overrides.h:376
SDL_InvalidParamError
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
SDL_AtomicIncRef
#define SDL_AtomicIncRef(a)
Increment an atomic variable used as a reference count.
Definition: SDL_atomic.h:252
SDL_error
Definition: SDL_error_c.h:34
SDL_CreateMutex
#define SDL_CreateMutex
Definition: SDL_dynapi_overrides.h:259
SDL_SYS_WaitThread
void SDL_SYS_WaitThread(SDL_Thread *thread)
Definition: SDL_systhread.c:60
SDL_Thread
Definition: SDL_thread_c.h:55
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
SDL_SYS_CreateThread
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
Definition: SDL_systhread.c:35
func
GLenum func
Definition: SDL_opengl_glext.h:660
SDL_THREAD_STATE_CLEANED
@ SDL_THREAD_STATE_CLEANED
Definition: SDL_thread_c.h:50
SDL_SemPost
#define SDL_SemPost
Definition: SDL_dynapi_overrides.h:269
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
SDL_SYS_SetTLSData
int SDL_SYS_SetTLSData(SDL_TLSData *data)
Definition: SDL_systls.c:33
SDL_TLSEntry::thread
SDL_threadID thread
Definition: SDL_thread.c:114
SDL_thread.h
SDL_AtomicUnlock
#define SDL_AtomicUnlock
Definition: SDL_dynapi_overrides.h:65
SDL_CreateThreadInternal
SDL_Thread * SDL_CreateThreadInternal(int(*fn)(void *), const char *name, const size_t stacksize, void *data)
Definition: SDL_thread.c:435
SDL_CreateThreadWithStackSize
#define SDL_CreateThreadWithStackSize
Definition: SDL_thread.c:312
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_TLSID
unsigned int SDL_TLSID
Definition: SDL_thread.h:52
name
GLuint const GLchar * name
Definition: SDL_opengl_glext.h:663
SDL_GetErrBuf
SDL_error * SDL_GetErrBuf(void)
Definition: SDL_thread.c:206
thread_args::info
SDL_Thread * info
Definition: SDL_thread.c:266
SDL_SYS_DetachThread
void SDL_SYS_DetachThread(SDL_Thread *thread)
Definition: SDL_systhread.c:66
SDL_assert.h
SDL_TLSCreate
SDL_TLSID SDL_TLSCreate()
Create an identifier that is globally visible to all threads but refers to data that is thread-specif...
Definition: SDL_thread.c:34
SDL_SYS_GetTLSData
SDL_TLSData * SDL_SYS_GetTLSData(void)
Definition: SDL_systls.c:27
SDL_SYS_SetThreadPriority
int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
Definition: SDL_systhread.c:54
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
SDL_GetThreadName
const char * SDL_GetThreadName(SDL_Thread *thread)
Definition: SDL_thread.c:458
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_thread_c.h
SDL_SpinLock
int SDL_SpinLock
Definition: SDL_atomic.h:89
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
id
GLuint id
Definition: SDL_opengl_glext.h:531
SDL_TLSEntry::storage
SDL_TLSData * storage
Definition: SDL_thread.c:115
SDL_threadID
unsigned long SDL_threadID
Definition: SDL_thread.h:49
SDL_SemWait
#define SDL_SemWait
Definition: SDL_dynapi_overrides.h:266
SDL_TLSData::data
void * data
Definition: SDL_thread_c.h:73
thread_args
Definition: SDL_thread.c:263
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:701
SDL_TLSData::limit
unsigned int limit
Definition: SDL_thread_c.h:71
SDL_MemoryBarrierAcquire
#define SDL_MemoryBarrierAcquire()
Definition: SDL_atomic.h:208
SDL_hints.h
SDL_atomic_t
A type representing an atomic integer value. It is a struct so people don't accidentally use numeric ...
Definition: SDL_atomic.h:216
SDL_Generic_GetTLSData
SDL_TLSData * SDL_Generic_GetTLSData(void)
Definition: SDL_thread.c:124
SDL_WaitThread
void SDL_WaitThread(SDL_Thread *thread, int *status)
Definition: SDL_thread.c:474
thread_args::wait
SDL_sem * wait
Definition: SDL_thread.c:267
SDL_strdup
#define SDL_strdup
Definition: SDL_dynapi_overrides.h:397
SDL_DestroySemaphore
#define SDL_DestroySemaphore
Definition: SDL_dynapi_overrides.h:265
SDL_TLSGet
void * SDL_TLSGet(SDL_TLSID id)
Get the value associated with a thread local storage ID for the current thread.
Definition: SDL_thread.c:41
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:162
SDL_TLSEntry::next
struct SDL_TLSEntry * next
Definition: SDL_thread.c:116
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
SDL_AtomicSet
#define SDL_AtomicSet
Definition: SDL_dynapi_overrides.h:67
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
SDL_AtomicGet
#define SDL_AtomicGet
Definition: SDL_dynapi_overrides.h:68
SDL_TLSCleanup
static void SDL_TLSCleanup()
Definition: SDL_thread.c:87
SDL_UnlockMutex
#define SDL_UnlockMutex
Definition: SDL_dynapi_overrides.h:262
SDL_ThreadPriority
SDL_ThreadPriority
Definition: SDL_thread.h:59
SDL_strtoll
#define SDL_strtoll
Definition: SDL_dynapi_overrides.h:414
SDL_ThreadID
#define SDL_ThreadID
Definition: SDL_dynapi_overrides.h:475
SDL_generic_TLS_mutex
static SDL_mutex * SDL_generic_TLS_mutex
Definition: SDL_thread.c:119
SDL_GetThreadID
SDL_threadID SDL_GetThreadID(SDL_Thread *thread)
Definition: SDL_thread.c:445
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_TLSSet
int SDL_TLSSet(SDL_TLSID id, const void *value, void(*destructor)(void *))
Set the value associated with a thread local storage ID for the current thread.
Definition: SDL_thread.c:53
SDL_SetThreadPriority
int SDL_SetThreadPriority(SDL_ThreadPriority priority)
Definition: SDL_thread.c:468
SDL_THREAD_STATE_ZOMBIE
@ SDL_THREAD_STATE_ZOMBIE
Definition: SDL_thread_c.h:49
SDL_generic_TLS
static SDL_TLSEntry * SDL_generic_TLS
Definition: SDL_thread.c:120
SDL_TLSEntry
Definition: SDL_thread.c:113