From fb283a732a11a4ccd6ebcfbe3cd671844b5b92e6 Mon Sep 17 00:00:00 2001
From: Xing Ji <[EMAIL REDACTED]>
Date: Wed, 24 Mar 2021 22:42:47 +0800
Subject: [PATCH] Squashed commit of the following:
commit 6b8f933589aa3925978a23e77a305a7e89c6ae4a
Author: Xing Ji <jixingcn@gmail.com>
Date: Wed Mar 24 22:31:29 2021 +0800
update the dynapi by `gendynapi.pl`
commit ebd1790c19983b652713f40ab1e139e485e1a2b7
Author: Xing Ji <jixingcn@gmail.com>
Date: Wed Mar 24 22:17:48 2021 +0800
revert the change in src/dynapi
commit 734b5f85c1613070081e39238e84198128971b53
Merge: 5a56e5a8 5ac6bd54
Author: Xing Ji <jixingcn@gmail.com>
Date: Wed Mar 24 22:14:40 2021 +0800
Merge remote-tracking branch 'libsdl/main' into jixingcn
commit 5a56e5a8227d9cff6b497b681c618a76bec1cae1
Author: Xing Ji <jixingcn@gmail.com>
Date: Mon Mar 22 23:55:10 2021 +0800
Fix #3596, can call the `SDL_TLSCleanup` to cleanup the TLS data when closing the application
---
include/SDL_thread.h | 4 ++++
src/dynapi/SDL_dynapi_overrides.h | 1 +
src/dynapi/SDL_dynapi_procs.h | 1 +
src/thread/SDL_thread.c | 2 +-
4 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/SDL_thread.h b/include/SDL_thread.h
index 49168c52f..be0601cc9 100644
--- a/include/SDL_thread.h
+++ b/include/SDL_thread.h
@@ -435,6 +435,10 @@ extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id);
*/
extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void*));
+/**
+ * \brief Cleanup all TLS data for this thread.
+ */
+extern DECLSPEC void SDLCALL SDL_TLSCleanup(void);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 085156e8b..2d35d5f9b 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -809,3 +809,4 @@
#define SDL_isgraph SDL_isgraph_REAL
#define SDL_AndroidShowToast SDL_AndroidShowToast_REAL
#define SDL_GetAudioDeviceSpec SDL_GetAudioDeviceSpec_REAL
+#define SDL_TLSCleanup SDL_TLSCleanup_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 1cd285393..6d89825f0 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -874,3 +874,4 @@ SDL_DYNAPI_PROC(int,SDL_isgraph,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_AndroidShowToast,(const char *a, int b, int c, int d, int e),(a,b,c,d,e),return)
#endif
SDL_DYNAPI_PROC(int,SDL_GetAudioDeviceSpec,(int a, int b, SDL_AudioSpec *c),(a,b,c),return)
+SDL_DYNAPI_PROC(void,SDL_TLSCleanup,(void),(),)
diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c
index 05c05ce49..438612c24 100644
--- a/src/thread/SDL_thread.c
+++ b/src/thread/SDL_thread.c
@@ -82,7 +82,7 @@ SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void *))
return 0;
}
-static void
+void
SDL_TLSCleanup()
{
SDL_TLSData *storage;