From 51a936bd661bf24f4869557754a00aab3664bd1e Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 25 Feb 2021 04:12:02 +0300
Subject: [PATCH] fixed Windows version of SDL_CreateThread() :
define the function with the two-params signature and pass NULL to
SDL20_CreateThread() as begin/end thread functions so that it uses
windows' CreateThread().
---
src/SDL12_compat.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 56c17fb..4a75c5a 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -3988,11 +3988,29 @@ DECLSPEC void SDLCALL SDL_CDClose(SDL12_CD *cdrom) {}
#error SDL_PASSED_BEGINTHREAD_ENDTHREAD not defined
#endif
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
+#ifdef _WIN32
+/* Official Windows versions of SDL-1.2 >= 1.2.10 were always built
+ * with HAVE_LIBC, i.e.: *without* SDL_PASSED_BEGINTHREAD_ENDTHREAD
+ * defined, in order to keep binary compatibility with SDL <= 1.2.9.
+ *
+ * On the other hand SDL2 >= 2.0.12, as we dictate for Windows does
+ * always define SDL_PASSED_BEGINTHREAD_ENDTHREAD, in order to keep
+ * SDL2 versions built with and without libc binary compatible with
+ * each other.
+ *
+ * Therefore, we have to do the following trick below. */
+DECLSPEC SDL_Thread * SDLCALL
+SDL_CreateThread(int (SDLCALL *fn)(void *), void *data)
+{
+ return SDL20_CreateThread(fn, NULL, data, NULL, NULL);
+}
+#else
DECLSPEC SDL_Thread * SDLCALL
SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
{
return SDL20_CreateThread(fn, NULL, data, pfnBeginThread, pfnEndThread);
}
+#endif
#else
DECLSPEC SDL_Thread * SDLCALL
SDL_CreateThread(int (SDLCALL *fn)(void *), void *data)