sdl2-compat: Updated to SDL3's reworking of SDL_CreateThread*.

From dad441566eff37eed71ee4405f6b3379be0216bf Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 21 May 2024 01:00:40 -0400
Subject: [PATCH] Updated to SDL3's reworking of SDL_CreateThread*.

---
 src/sdl2_compat.c          |  8 ++++----
 src/sdl3_include_wrapper.h | 13 +++++++++++--
 src/sdl3_syms.h            |  8 +-------
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index e466eb8..70fcfad 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -8194,15 +8194,15 @@ SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id)
 
 SDL_DECLSPEC SDL_Thread *SDLCALL
 SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
-                 pfnSDL_CurrentBeginThread pfnBeginThread,
-                 pfnSDL_CurrentEndThread pfnEndThread)
+                 SDL_BeginThreadEx pfnBeginThread,
+                 SDL_EndThreadEx pfnEndThread)
 {
     size_t stacksize = 0;
     const char *hint = SDL3_GetHint("SDL_THREAD_STACK_SIZE");
     if (hint) {
         stacksize = (size_t)SDL3_strtoul(hint, NULL, 0);
     }
-    return SDL3_CreateThreadWithStackSize(fn, name, stacksize, data, pfnBeginThread, pfnEndThread);
+    return SDL3_CreateThreadWithStackSizeRuntime(fn, name, stacksize, data, (SDL_BeginThreadEx) pfnBeginThread, (SDL_EndThreadEx) pfnEndThread);
 }
 
 #else
@@ -8215,7 +8215,7 @@ SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data)
     if (hint) {
         stacksize = (size_t)SDL3_strtoul(hint, NULL, 0);
     }
-    return SDL3_CreateThreadWithStackSize(fn, name, stacksize, data);
+    return SDL3_CreateThreadWithStackSizeRuntime(fn, name, stacksize, data, NULL, NULL);
 }
 
 #endif /* (SDL_PLATFORM_WIN32 || SDL_PLATFORM_GDK) && !SDL_PLATFORM_WINRT */
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index bc94875..e055acf 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -116,8 +116,8 @@
 #define SDL_CreateTexture IGNORE_THIS_VERSION_OF_SDL_CreateTexture
 #define SDL_CreateTextureFromSurface IGNORE_THIS_VERSION_OF_SDL_CreateTextureFromSurface
 #define SDL_CreateTextureWithProperties IGNORE_THIS_VERSION_OF_SDL_CreateTextureWithProperties
-#define SDL_CreateThread IGNORE_THIS_VERSION_OF_SDL_CreateThread
-#define SDL_CreateThreadWithStackSize IGNORE_THIS_VERSION_OF_SDL_CreateThreadWithStackSize
+#define SDL_CreateThreadRuntime IGNORE_THIS_VERSION_OF_SDL_CreateThreadRuntime
+#define SDL_CreateThreadWithStackSizeRuntime IGNORE_THIS_VERSION_OF_SDL_CreateThreadWithStackSizeRuntime
 #define SDL_CreateWindow IGNORE_THIS_VERSION_OF_SDL_CreateWindow
 #define SDL_CreateWindowAndRenderer IGNORE_THIS_VERSION_OF_SDL_CreateWindowAndRenderer
 #define SDL_CreateWindowWithProperties IGNORE_THIS_VERSION_OF_SDL_CreateWindowWithProperties
@@ -1398,6 +1398,15 @@
 #undef SDL_CreateTextureWithProperties
 #endif
 
+#ifdef SDL_CreateThreadRuntime
+#undef SDL_CreateThreadRuntime
+#endif
+
+#ifdef SDL_CreateThreadWithStackSizeRuntime
+#undef SDL_CreateThreadWithStackSizeRuntime
+#endif
+
+/* dump the macro CreateThread versions, too. */
 #ifdef SDL_CreateThread
 #undef SDL_CreateThread
 #endif
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index dff5b49..c0bcdd5 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -45,13 +45,7 @@ SDL3_SYM_VARARGS(void,LogCritical,(int a, SDL_PRINTF_FORMAT_STRING const char *b
 SDL3_SYM_VARARGS(void,LogMessage,(int a, SDL_LogPriority b, SDL_PRINTF_FORMAT_STRING const char *c, ...))
 SDL3_SYM_VARARGS(int,sscanf,(const char *a, SDL_SCANF_FORMAT_STRING const char *b, ...))
 SDL3_SYM_VARARGS(int,snprintf,(SDL_OUT_Z_CAP(b) char *a, size_t b, SDL_PRINTF_FORMAT_STRING const char *c, ...))
-
-#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && !defined(SDL_PLATFORM_WINRT)
-SDL3_SYM_PASSTHROUGH(SDL_Thread*,CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d,
-                                                              pfnSDL_CurrentBeginThread e, pfnSDL_CurrentEndThread f),(a,b,c,d,e,f),return)
-#else
-SDL3_SYM_PASSTHROUGH(SDL_Thread*,CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d),(a,b,c,d),return)
-#endif
+SDL3_SYM(SDL_Thread*,CreateThreadWithStackSizeRuntime,(SDL_ThreadFunction a, const char *b, const size_t c, void *d, SDL_BeginThreadExCallback e, SDL_EndThreadExCallback f),(a,b,c,d,e,f),return)
 
 #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
 SDL3_SYM_PASSTHROUGH(int,RegisterApp,(const char *a, Uint32 b, void *c),(a,b,c),return)