From 761843cc7210e9e3f86d7c0d87559927b52d41bd Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sun, 25 Aug 2019 16:45:49 -0700 Subject: [PATCH] SDL2 thread IDs can be 64-bit --- sc2/src/libs/threads/sdl/sdlthreads.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sc2/src/libs/threads/sdl/sdlthreads.c b/sc2/src/libs/threads/sdl/sdlthreads.c index bbbd5ec44..118951dd7 100644 --- a/sc2/src/libs/threads/sdl/sdlthreads.c +++ b/sc2/src/libs/threads/sdl/sdlthreads.c @@ -29,6 +29,10 @@ #include #endif +#if SDL_MAJOR_VERSION == 1 +typedef Uint32 SDL_threadID; +#endif + typedef struct _thread { void *native; #ifdef NAMED_SYNCHRO @@ -70,7 +74,7 @@ SigUSR1Handler (int signr) { static void LocalStats (SDL_Thread *thread) { #if defined (WIN32) || !defined(SDL_PTHREADS) - fprintf (stderr, "Thread ID %u\n", SDL_GetThreadID (thread)); + fprintf (stderr, "Thread ID %08lx\n", (Uint64)SDL_GetThreadID (thread)); #else /* !defined (WIN32) && defined(SDL_PTHREADS) */ // This only works if SDL implements threads as processes pid_t pid; @@ -163,7 +167,7 @@ UnQueueThread (TrueThread thread) } static TrueThread -FindThreadInfo (Uint32 threadID) +FindThreadInfo (SDL_threadID threadID) { TrueThread ptr; @@ -336,7 +340,7 @@ GetMyThreadLocal_SDL (void) typedef struct _mutex { SDL_mutex *mutex; #ifdef TRACK_CONTENTION - Uint32 owner; + SDL_threadID owner; #endif #ifdef NAMED_SYNCHRO const char *name; @@ -518,7 +522,7 @@ ClearSemaphore_SDL (Semaphore s) typedef struct _recm { SDL_mutex *mutex; - Uint32 thread_id; + SDL_threadID thread_id; Uint32 locks; #ifdef NAMED_SYNCHRO const char *name; @@ -568,7 +572,7 @@ void LockRecursiveMutex_SDL (RecursiveMutex val) { RecM *mtx = (RecM *)val; - Uint32 thread_id = SDL_ThreadID(); + SDL_threadID thread_id = SDL_ThreadID(); if (!mtx->locks || mtx->thread_id != thread_id) { #ifdef TRACK_CONTENTION @@ -589,7 +593,7 @@ void UnlockRecursiveMutex_SDL (RecursiveMutex val) { RecM *mtx = (RecM *)val; - Uint32 thread_id = SDL_ThreadID(); + SDL_threadID thread_id = SDL_ThreadID(); if (!mtx->locks || mtx->thread_id != thread_id) { #ifdef NAMED_SYNCHRO