@@ -51,6 +51,13 @@ If you have questions concerning this license or the applicable additional terms
5151 #define SDL_CondSignal SDL_SignalCondition
5252#endif
5353
54+ #if SDL_MAJOR_VERSION < 3
55+ // in SDL3 SDL_ThreadID is the type (that's called SDL_threadID with lowercase-t in SDL2),
56+ // in SDL1.2 and SDL2 SDL_ThreadID() is a function that returns the current thread's ID...
57+ // So use SDL_GetCurrentThreadID() in all cases to avoid this clash
58+ #define SDL_GetCurrentThreadID SDL_ThreadID
59+ #endif
60+
5461#if __cplusplus >= 201103
5562 // xthreadinfo::threadId doesn't use SDL_threadID directly so we don't drag SDL headers into sys_public.h
5663 // but we should still make sure that the type fits (in SDL1.2 it's Uint32, in SDL2 it's unsigned long)
@@ -83,7 +90,7 @@ Sys_InitThreads
8390==================
8491*/
8592void Sys_InitThreads () {
86- mainThreadID = SDL_ThreadID ();
93+ mainThreadID = SDL_GetCurrentThreadID ();
8794 mainThreadIDset = true ;
8895
8996 // critical sections
@@ -326,7 +333,7 @@ const char *Sys_GetThreadName(int *index) {
326333
327334 Sys_EnterCriticalSection ();
328335
329- SDL_threadID id = SDL_ThreadID ();
336+ SDL_threadID id = SDL_GetCurrentThreadID ();
330337
331338 for (int i = 0 ; i < thread_count; i++) {
332339 if (id == thread[i]->threadId ) {
@@ -358,7 +365,7 @@ returns true if the current thread is the main thread
358365*/
359366bool Sys_IsMainThread () {
360367 if ( mainThreadIDset )
361- return SDL_ThreadID () == mainThreadID;
368+ return SDL_GetCurrentThreadID () == mainThreadID;
362369 // if this is called before mainThreadID is set, we haven't created
363370 // any threads yet so it should be the main thread
364371 return true ;
0 commit comments