SDL_thread_c.h
Go to the documentation of this file.
/*
Simple DirectMedia Layer
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
#ifndef _SDL_thread_c_h
#define _SDL_thread_c_h
#include "SDL_thread.h"
/* Need the definitions of SYS_ThreadHandle */
#if SDL_THREADS_DISABLED
#include "generic/SDL_systhread_c.h"
#elif SDL_THREAD_PTHREAD
#include "pthread/SDL_systhread_c.h"
#elif SDL_THREAD_WINDOWS
#include "windows/SDL_systhread_c.h"
#elif SDL_THREAD_PSP
#include "psp/SDL_systhread_c.h"
#elif SDL_THREAD_STDCPP
#include "stdcpp/SDL_systhread_c.h"
#else
#error Need thread implementation for this platform
#include "generic/SDL_systhread_c.h"
#endif
#include "../SDL_error_c.h"
typedef enum SDL_ThreadState
{
SDL_THREAD_STATE_ALIVE,
SDL_THREAD_STATE_DETACHED,
SDL_THREAD_STATE_ZOMBIE,
SDL_THREAD_STATE_CLEANED,
} SDL_ThreadState;
/* This is the system-independent thread info structure */
struct SDL_Thread
{
SDL_threadID threadid;
SYS_ThreadHandle handle;
int status;
SDL_atomic_t state; /* SDL_THREAD_STATE_* */
SDL_error errbuf;
char *name;
void *data;
};
/* This is the function called to run a thread */
extern void SDL_RunThread(void *data);
/* This is the system-independent thread local storage structure */
typedef struct {
unsigned int limit;
struct {
void *data;
void (*destructor)(void*);
} array[1];
} SDL_TLSData;
/* This is how many TLS entries we allocate at once */
#define TLS_ALLOC_CHUNKSIZE 4
/* Get cross-platform, slow, thread local storage for this thread.
This is only intended as a fallback if getting real thread-local
storage fails or isn't supported on this platform.
*/
extern SDL_TLSData *SDL_Generic_GetTLSData();
/* Set cross-platform, slow, thread local storage for this thread.
This is only intended as a fallback if getting real thread-local
storage fails or isn't supported on this platform.
*/
extern int SDL_Generic_SetTLSData(SDL_TLSData *data);
#endif /* _SDL_thread_c_h */
/* vi: set ts=4 sw=4 expandtab: */
SDL_Thread::state
SDL_atomic_t state
Definition: SDL_thread_c.h:59
SDL_Generic_GetTLSData
SDL_TLSData * SDL_Generic_GetTLSData()
Definition: SDL_thread.c:123
SDL_systhread_c.h
SDL_THREAD_STATE_ZOMBIE
Definition: SDL_thread_c.h:49
SDL_Thread::name
char * name
Definition: SDL_thread_c.h:61
SDL_systhread_c.h
SDL_atomic_t
A type representing an atomic integer value. It is a struct so people don&#39;t accidentally use numeric ...
Definition: SDL_atomic.h:189
SDL_TLSData::data
void * data
Definition: SDL_thread_c.h:72
SDL_THREAD_STATE_DETACHED
Definition: SDL_thread_c.h:48
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
SYS_ThreadHandle
int SYS_ThreadHandle
Definition: SDL_systhread_c.h:24
SDL_TLSData
Definition: SDL_thread_c.h:69
SDL_TLSData::limit
unsigned int limit
Definition: SDL_thread_c.h:70
SDL_error
Definition: SDL_error_c.h:33
SDL_Thread::errbuf
SDL_error errbuf
Definition: SDL_thread_c.h:60
SDL_Thread::threadid
SDL_threadID threadid
Definition: SDL_thread_c.h:56
SDL_RunThread
void SDL_RunThread(void *data)
Definition: SDL_thread.c:264
SDL_Thread::status
int status
Definition: SDL_thread_c.h:58
SDL_thread.h
SDL_THREAD_STATE_CLEANED
Definition: SDL_thread_c.h:50
SDL_Thread::data
void * data
Definition: SDL_thread_c.h:62
SDL_systhread_c.h
SDL_THREAD_STATE_ALIVE
Definition: SDL_thread_c.h:47
SDL_systhread_c.h
SDL_systhread_c.h
SDL_Thread::handle
SYS_ThreadHandle handle
Definition: SDL_thread_c.h:57
void
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
Definition: SDL_dynapi_procs.h:93
SDL_Generic_SetTLSData
int SDL_Generic_SetTLSData(SDL_TLSData *data)
Definition: SDL_thread.c:162
SDL_Thread
Definition: SDL_thread_c.h:54
array
GLenum array
Definition: SDL_opengl_glext.h:6300
SDL_ThreadState
SDL_ThreadState
Definition: SDL_thread_c.h:45
SDL_threadID
unsigned long SDL_threadID
Definition: SDL_thread.h:49