From dec7875a6e23212021e4d9080330a42832dfe02a Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Tue, 15 Jun 2021 01:40:19 +0000
Subject: [PATCH] update SDL soruce to 2.0.14

---
 source/src/thread/windows/SDL_systhread.c |   39 +++++++++++++--------------------------
 1 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/source/src/thread/windows/SDL_systhread.c b/source/src/thread/windows/SDL_systhread.c
index a5e4e35..7e3269b 100644
--- a/source/src/thread/windows/SDL_systhread.c
+++ b/source/src/thread/windows/SDL_systhread.c
@@ -74,23 +74,16 @@
 #endif /* !SDL_PASSED_BEGINTHREAD_ENDTHREAD */
 
 
-typedef struct ThreadStartParms
-{
-    void *args;
-    pfnSDL_CurrentEndThread pfnCurrentEndThread;
-} tThreadStartParms, *pThreadStartParms;
-
 static DWORD
 RunThread(void *data)
 {
-    pThreadStartParms pThreadParms = (pThreadStartParms) data;
-    pfnSDL_CurrentEndThread pfnEndThread = pThreadParms->pfnCurrentEndThread;
-    void *args = pThreadParms->args;
-    SDL_free(pThreadParms);
-    SDL_RunThread(args);
-    if (pfnEndThread != NULL)
+    SDL_Thread *thread = (SDL_Thread *) data;
+    pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread) thread->endfunc;
+    SDL_RunThread(thread);
+    if (pfnEndThread != NULL) {
         pfnEndThread(0);
-    return (0);
+    }
+    return 0;
 }
 
 static DWORD WINAPI
@@ -107,33 +100,27 @@
 
 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
 int
-SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
+SDL_SYS_CreateThread(SDL_Thread * thread,
                      pfnSDL_CurrentBeginThread pfnBeginThread,
                      pfnSDL_CurrentEndThread pfnEndThread)
 {
 #elif defined(__CYGWIN__) || defined(__WINRT__)
 int
-SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
+SDL_SYS_CreateThread(SDL_Thread * thread)
 {
     pfnSDL_CurrentBeginThread pfnBeginThread = NULL;
     pfnSDL_CurrentEndThread pfnEndThread = NULL;
 #else
 int
-SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
+SDL_SYS_CreateThread(SDL_Thread * thread)
 {
     pfnSDL_CurrentBeginThread pfnBeginThread = (pfnSDL_CurrentBeginThread)_beginthreadex;
     pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)_endthreadex;
 #endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
-    pThreadStartParms pThreadParms =
-        (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
     const DWORD flags = thread->stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0;
-    if (!pThreadParms) {
-        return SDL_OutOfMemory();
-    }
+
     /* Save the function which we will have to call to clear the RTL of calling app! */
-    pThreadParms->pfnCurrentEndThread = pfnEndThread;
-    /* Also save the real parameters we have to pass to thread function */
-    pThreadParms->args = args;
+    thread->endfunc = pfnEndThread;
 
     /* thread->stacksize == 0 means "system default", same as win32 expects */
     if (pfnBeginThread) {
@@ -141,12 +128,12 @@
         thread->handle = (SYS_ThreadHandle)
             ((size_t) pfnBeginThread(NULL, (unsigned int) thread->stacksize,
                                      RunThreadViaBeginThreadEx,
-                                     pThreadParms, flags, &threadid));
+                                     thread, flags, &threadid));
     } else {
         DWORD threadid = 0;
         thread->handle = CreateThread(NULL, thread->stacksize,
                                       RunThreadViaCreateThread,
-                                      pThreadParms, flags, &threadid);
+                                      thread, flags, &threadid);
     }
     if (thread->handle == NULL) {
         return SDL_SetError("Not enough resources to create thread");

--
Gitblit v1.9.3