sdl12-compat: headers, SDL_thread.h: added os2 beginthread()/endthread() magic.

From c71d03781656b28afbdec37018444a9551fd3d96 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 25 May 2021 14:03:50 +0300
Subject: [PATCH] headers, SDL_thread.h: added os2 beginthread()/endthread()
 magic.

---
 include/SDL/SDL_thread.h | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/SDL/SDL_thread.h b/include/SDL/SDL_thread.h
index e80047e..906b270 100644
--- a/include/SDL/SDL_thread.h
+++ b/include/SDL/SDL_thread.h
@@ -30,12 +30,30 @@ real SDL-1.2 available to you. */
 #include "SDL_error.h"
 #include "SDL_mutex.h"
 
+#ifdef __OS2__ /* for _beginthread() and _endthread(). */
+#include <process.h>
+#ifdef __EMX__
+#include <stdlib.h>
+#endif
+#endif
+
 #include "begin_code.h"
 
 typedef struct SDL_Thread SDL_Thread;
 
-/* !!! FIXME: need the windows/os2 beginthread() magic here */
+/* No _beginthread()/_endthread() magic for windows -- only for os2:
+ * 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. */
+#ifdef __OS2__
+typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg);
+typedef void (*pfnSDL_CurrentEndThread)(void);
+extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
+#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
+#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
+#else
 extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
+#endif
 extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void);
 extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread);
 extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status);