21 #include "../../SDL_internal.h"
23 #if SDL_THREAD_WINDOWS
29 #include "../SDL_thread_c.h"
30 #include "../SDL_systhread.h"
31 #include "SDL_systhread_c.h"
33 #ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD
37 #ifndef STACK_SIZE_PARAM_IS_A_RESERVATION
38 #define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000
42 #if (defined(__MINGW32__) && (__GNUC__ < 4))
44 unsigned (__stdcall *
func)(
void *),
void *arg,
45 unsigned,
unsigned *threadID);
48 #elif defined(__WATCOMC__)
50 #if __WATCOMC__ < 1240
83 if (pfnEndThread !=
NULL) {
90 RunThreadViaCreateThread(LPVOID
data)
95 static unsigned __stdcall
96 RunThreadViaBeginThreadEx(
void *
data)
101 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
107 #elif defined(__CYGWIN__) || defined(__WINRT__)
120 const DWORD
flags = thread->
stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0;
123 thread->
endfunc = pfnEndThread;
126 if (pfnBeginThread) {
127 unsigned threadid = 0;
129 ((
size_t) pfnBeginThread(
NULL, (
unsigned int) thread->
stacksize,
130 RunThreadViaBeginThreadEx,
131 thread,
flags, &threadid));
135 RunThreadViaCreateThread,
136 thread,
flags, &threadid);
139 return SDL_SetError(
"Not enough resources to create thread");
145 typedef struct tagTHREADNAME_INFO
155 typedef HRESULT (WINAPI *pfnSetThreadDescription)(HANDLE, PCWSTR);
162 static pfnSetThreadDescription pSetThreadDescription =
NULL;
166 kernel32 = LoadLibraryW(L
"kernel32.dll");
168 pSetThreadDescription = (pfnSetThreadDescription) GetProcAddress(
kernel32,
"SetThreadDescription");
172 if (pSetThreadDescription !=
NULL) {
175 pSetThreadDescription(GetCurrentThread(), strw);
185 if (IsDebuggerPresent()) {
197 inf.dwThreadID = (DWORD) -1;
201 RaiseException(0x406D1388, 0,
sizeof(inf) /
sizeof(ULONG), (
const ULONG_PTR*) &inf);
218 value = THREAD_PRIORITY_LOWEST;
220 value = THREAD_PRIORITY_HIGHEST;
222 value = THREAD_PRIORITY_TIME_CRITICAL;
224 value = THREAD_PRIORITY_NORMAL;
226 if (!SetThreadPriority(GetCurrentThread(),
value)) {
235 WaitForSingleObjectEx(thread->
handle, INFINITE,
FALSE);
236 CloseHandle(thread->
handle);
242 CloseHandle(thread->
handle);
#define SDL_GetHintBoolean
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
#define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING
Tell SDL not to name threads on Windows with the 0x406D1388 Exception. The 0x406D1388 Exception is a ...
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLuint const GLchar * name
GLsizei const GLfloat * value
void SDL_RunThread(SDL_Thread *thread)
void(__cdecl * pfnSDL_CurrentEndThread)(unsigned code)
unsigned long SDL_threadID
@ SDL_THREAD_PRIORITY_TIME_CRITICAL
@ SDL_THREAD_PRIORITY_LOW
@ SDL_THREAD_PRIORITY_HIGH
uintptr_t(__cdecl * pfnSDL_CurrentBeginThread)(void *, unsigned, unsigned(__stdcall *func)(void *), void *, unsigned, unsigned *)
#define WIN_UTF8ToString(S)
int WIN_SetError(const char *prefix)
void SDL_SYS_SetupThread(const char *name)
int SDL_SYS_CreateThread(SDL_Thread *thread)
void SDL_SYS_DetachThread(SDL_Thread *thread)
int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
void SDL_SYS_WaitThread(SDL_Thread *thread)
SDL_threadID SDL_ThreadID(void)
static void * RunThread(void *data)