21 #include "../../SDL_internal.h" 23 #if SDL_THREAD_WINDOWS 28 #include "../SDL_thread_c.h" 29 #include "../SDL_systhread.h" 30 #include "SDL_systhread_c.h" 32 #ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD 37 #if (defined(__MINGW32__) && (__GNUC__ < 4)) 38 typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (
void *, unsigned,
39 unsigned (__stdcall *
func)(
void *),
void *arg,
40 unsigned,
unsigned *threadID);
41 typedef void (__cdecl *pfnSDL_CurrentEndThread)(
unsigned code);
43 #elif defined(__WATCOMC__) 45 #if __WATCOMC__ < 1240 48 typedef unsigned long (__watcall * pfnSDL_CurrentBeginThread) (
void *,
58 typedef void (__watcall * pfnSDL_CurrentEndThread) (
unsigned code);
61 typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (
void *, unsigned,
67 typedef void (__cdecl * pfnSDL_CurrentEndThread) (
unsigned code);
72 typedef struct ThreadStartParms
75 pfnSDL_CurrentEndThread pfnCurrentEndThread;
76 } tThreadStartParms, *pThreadStartParms;
81 pThreadStartParms pThreadParms = (pThreadStartParms) data;
82 pfnSDL_CurrentEndThread pfnEndThread = pThreadParms->pfnCurrentEndThread;
83 void *args = pThreadParms->args;
86 if (pfnEndThread !=
NULL)
92 RunThreadViaCreateThread(LPVOID data)
97 static unsigned __stdcall
98 RunThreadViaBeginThreadEx(
void *data)
103 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD 106 pfnSDL_CurrentBeginThread pfnBeginThread,
107 pfnSDL_CurrentEndThread pfnEndThread)
109 #elif defined(__CYGWIN__) || defined(__WINRT__) 113 pfnSDL_CurrentBeginThread pfnBeginThread =
NULL;
114 pfnSDL_CurrentEndThread pfnEndThread =
NULL;
119 pfnSDL_CurrentBeginThread pfnBeginThread = (pfnSDL_CurrentBeginThread)_beginthreadex;
120 pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)_endthreadex;
122 pThreadStartParms pThreadParms =
123 (pThreadStartParms)
SDL_malloc(
sizeof(tThreadStartParms));
128 pThreadParms->pfnCurrentEndThread = pfnEndThread;
130 pThreadParms->args = args;
132 if (pfnBeginThread) {
133 unsigned threadid = 0;
135 ((
size_t) pfnBeginThread(
NULL, 0, RunThreadViaBeginThreadEx,
136 pThreadParms, 0, &threadid));
139 thread->
handle = CreateThread(
NULL, 0, RunThreadViaCreateThread,
140 pThreadParms, 0, &threadid);
143 return SDL_SetError(
"Not enough resources to create thread");
150 #pragma warning(disable : 4733) 152 typedef struct tagTHREADNAME_INFO
161 static EXCEPTION_DISPOSITION
162 ignore_exception(
void *
a,
void *
b,
void *
c,
void *
d)
164 return ExceptionContinueExecution;
174 #if (defined(_MSC_VER) && defined(_M_IX86)) 179 INT_PTR handler = (INT_PTR) ignore_exception;
184 inf.dwThreadID = (DWORD) -1;
194 RaiseException(0x406D1388, 0,
sizeof(inf)/
sizeof(DWORD), (DWORD*)&inf);
218 value = THREAD_PRIORITY_LOWEST;
220 value = THREAD_PRIORITY_HIGHEST;
222 value = THREAD_PRIORITY_NORMAL;
224 if (!SetThreadPriority(GetCurrentThread(), value)) {
234 WaitForSingleObjectEx(thread->
handle, INFINITE,
FALSE);
236 WaitForSingleObject(thread->
handle, INFINITE);
238 CloseHandle(thread->
handle);
244 CloseHandle(thread->
handle);
static void * RunThread(void *data)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLuint const GLchar * name
SDL_threadID SDL_ThreadID(void)
void SDL_SYS_WaitThread(SDL_Thread *thread)
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 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
GLsizei const GLfloat * value
int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
void SDL_SYS_DetachThread(SDL_Thread *thread)
#define SDL_OutOfMemory()
int WIN_SetError(const char *prefix)
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
void SDL_RunThread(void *data)
void SDL_SYS_SetupThread(const char *name)
GLboolean GLboolean GLboolean GLboolean a
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
GLboolean GLboolean GLboolean b
unsigned long SDL_threadID