From cddd4fac6cc0bed5be5400bc6aad34721604aaf5 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 22 May 2024 20:55:04 +0300
Subject: [PATCH] fixed windows builds after the thread api changes.
---
src/sdl2_compat.c | 15 ++++-----------
src/sdl2_compat.h | 6 ++++++
src/sdl3_include_wrapper.h | 18 +++++++++---------
3 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 3a8eab3..e417b8d 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -8216,23 +8216,16 @@ static SDL_Thread *SDL2_CreateThread(SDL_ThreadFunction fn, const char *name, vo
#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && !defined(SDL_PLATFORM_WINRT)
-typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread)
- (void *, unsigned, unsigned (__stdcall *func)(void *),
- void * /*arg*/, unsigned, unsigned * /* threadID */);
-typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
-
SDL_DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
- pfnSDL_CurrentBeginThread pfnBeginThread,
- pfnSDL_CurrentEndThread pfnEndThread)
+ pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
{
return SDL2_CreateThread(fn, name, data, (SDL_FunctionPointer) pfnBeginThread, (SDL_FunctionPointer) pfnEndThread);
}
-extern SDL_DECLSPEC SDL_Thread *SDLCALL
+SDL_DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data,
- pfnSDL_CurrentBeginThread pfnBeginThread,
- pfnSDL_CurrentEndThread pfnEndThread);
+ pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
{
return SDL2_CreateThreadWithStackSize(fn, name, stacksize, data, (SDL_FunctionPointer) pfnBeginThread, (SDL_FunctionPointer) pfnEndThread);
}
@@ -8245,7 +8238,7 @@ SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data)
return SDL2_CreateThread(fn, name, data, NULL, NULL);
}
-extern SDL_DECLSPEC SDL_Thread *SDLCALL
+SDL_DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data)
{
return SDL2_CreateThreadWithStackSize(fn, name, stacksize, data, NULL, NULL);
diff --git a/src/sdl2_compat.h b/src/sdl2_compat.h
index 5b68684..e903821 100644
--- a/src/sdl2_compat.h
+++ b/src/sdl2_compat.h
@@ -217,6 +217,12 @@ typedef struct ID3D12Device ID3D12Device;
typedef void (SDLCALL * SDL2_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
#endif
+#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && !defined(SDL_PLATFORM_WINRT)
+typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread)
+ (void *, unsigned, unsigned (__stdcall *func)(void *), void *, unsigned, unsigned *);
+typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned);
+#endif
+
typedef struct SDL2_version
{
Uint8 major;
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index 77f7dce..7e5d570 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -1406,15 +1406,6 @@
#undef SDL_CreateThreadWithPropertiesRuntime
#endif
-/* dump the macro CreateThread versions, too. */
-#ifdef SDL_CreateThread
-#undef SDL_CreateThread
-#endif
-
-#ifdef SDL_CreateThreadWithProperties
-#undef SDL_CreateThreadWithProperties
-#endif
-
#ifdef SDL_CreateWindow
#undef SDL_CreateWindow
#endif
@@ -5113,6 +5104,15 @@
#undef SDL_ThreadID /* see at top */
+/* dump the macro CreateThread versions, too. */
+#ifdef SDL_CreateThread
+#undef SDL_CreateThread
+#endif
+
+#ifdef SDL_CreateThreadWithProperties
+#undef SDL_CreateThreadWithProperties
+#endif
+
/* undefine these macros, too: redefine as SDL3_xxx, if needed. */
#ifdef SDL_enabled_assert