Path: blob/master/thirdparty/sdl/thread/SDL_thread_c.h
9898 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/20#include "SDL_internal.h"2122#ifndef SDL_thread_c_h_23#define SDL_thread_c_h_2425// Need the definitions of SYS_ThreadHandle26#ifdef SDL_THREADS_DISABLED27#include "generic/SDL_systhread_c.h"28#elif defined(SDL_THREAD_PTHREAD)29#include "pthread/SDL_systhread_c.h"30#elif defined(SDL_THREAD_WINDOWS)31#include "windows/SDL_systhread_c.h"32#elif defined(SDL_THREAD_PS2)33#include "ps2/SDL_systhread_c.h"34#elif defined(SDL_THREAD_PSP)35#include "psp/SDL_systhread_c.h"36#elif defined(SDL_THREAD_VITA)37#include "vita/SDL_systhread_c.h"38#elif defined(SDL_THREAD_N3DS)39#include "n3ds/SDL_systhread_c.h"40#else41#error Need thread implementation for this platform42#include "generic/SDL_systhread_c.h"43#endif44#include "../SDL_error_c.h"4546// This is the system-independent thread info structure47struct SDL_Thread48{49SDL_ThreadID threadid;50SYS_ThreadHandle handle;51int status;52SDL_AtomicInt state; /* SDL_ThreadState */53SDL_error errbuf;54char *name;55size_t stacksize; // 0 for default, >0 for user-specified stack size.56int(SDLCALL *userfunc)(void *);57void *userdata;58void *data;59SDL_FunctionPointer endfunc; // only used on some platforms.60};6162// This is the function called to run a thread63extern void SDL_RunThread(SDL_Thread *thread);6465// This is the system-independent thread local storage structure66typedef struct67{68int limit;69struct70{71void *data;72void(SDLCALL *destructor)(void *);73} array[1];74} SDL_TLSData;7576// This is how many TLS entries we allocate at once77#define TLS_ALLOC_CHUNKSIZE 47879extern void SDL_InitTLSData(void);80extern void SDL_QuitTLSData(void);8182/* Generic TLS support.83This is only intended as a fallback if getting real thread-local84storage fails or isn't supported on this platform.85*/86extern void SDL_Generic_InitTLSData(void);87extern SDL_TLSData *SDL_Generic_GetTLSData(void);88extern bool SDL_Generic_SetTLSData(SDL_TLSData *data);89extern void SDL_Generic_QuitTLSData(void);9091#endif // SDL_thread_c_h_929394