From f960c687fb24d5a57650e68bad56493255ed3731 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 29 Apr 2023 00:50:00 +0300
Subject: [PATCH] adapt to recent renamings in SDL3
---
src/sdl2_compat.c | 4 +--
src/sdl2_compat.h | 6 +++-
src/sdl3_include_wrapper.h | 66 +++++++++++++++++++-------------------
src/sdl3_syms.h | 36 ++++++++++-----------
4 files changed, 58 insertions(+), 54 deletions(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 8dd5106..0d41e05 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -5267,12 +5267,12 @@ SDL_SensorOpen(int idx)
DECLSPEC int SDLCALL
SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
{
- return SDL3_CondWaitTimeout(cond, mutex, (Sint32)ms);
+ return SDL3_WaitConditionTimeout(cond, mutex, (Sint32)ms);
}
DECLSPEC int SDLCALL
SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms)
{
- return SDL3_SemWaitTimeout(sem, (Sint32)ms);
+ return SDL3_WaitSemaphoreTimeout(sem, (Sint32)ms);
}
diff --git a/src/sdl2_compat.h b/src/sdl2_compat.h
index f8540ee..6676815 100644
--- a/src/sdl2_compat.h
+++ b/src/sdl2_compat.h
@@ -22,10 +22,14 @@
#ifndef sdl2_compat_h
#define sdl2_compat_h
-/* these types were removed from SDL3, but we need them for SDL2 APIs exported here. */
+/* these types were removed from / renamed in SDL3. We need them for SDL2 APIs exported here. */
typedef SDL_AtomicInt SDL_atomic_t;
+typedef SDL_Condition SDL_cond;
+typedef SDL_Mutex SDL_mutex;
+typedef SDL_Semaphore SDL_sem;
+
typedef SDL_Gamepad SDL_GameController; /* since they're opaque types, for simplicity we just typedef it here and use the old types in sdl3_syms.h */
typedef SDL_GamepadAxis SDL_GameControllerAxis;
typedef SDL_GamepadBinding SDL_GameControllerButtonBind;
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index b36af7c..1d67916 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -70,16 +70,16 @@
#define SDL_CloseJoystick IGNORE_THIS_VERSION_OF_SDL_CloseJoystick
#define SDL_CloseSensor IGNORE_THIS_VERSION_OF_SDL_CloseSensor
#define SDL_ComposeCustomBlendMode IGNORE_THIS_VERSION_OF_SDL_ComposeCustomBlendMode
-#define SDL_CondBroadcast IGNORE_THIS_VERSION_OF_SDL_CondBroadcast
-#define SDL_CondSignal IGNORE_THIS_VERSION_OF_SDL_CondSignal
-#define SDL_CondWait IGNORE_THIS_VERSION_OF_SDL_CondWait
-#define SDL_CondWaitTimeout IGNORE_THIS_VERSION_OF_SDL_CondWaitTimeout
+#define SDL_BroadcastCondition IGNORE_THIS_VERSION_OF_SDL_BroadcastCondition
+#define SDL_SignalCondition IGNORE_THIS_VERSION_OF_SDL_SignalCondition
+#define SDL_WaitCondition IGNORE_THIS_VERSION_OF_SDL_WaitCondition
+#define SDL_WaitConditionTimeout IGNORE_THIS_VERSION_OF_SDL_WaitConditionTimeout
#define SDL_ConvertPixels IGNORE_THIS_VERSION_OF_SDL_ConvertPixels
#define SDL_ConvertSurface IGNORE_THIS_VERSION_OF_SDL_ConvertSurface
#define SDL_ConvertSurfaceFormat IGNORE_THIS_VERSION_OF_SDL_ConvertSurfaceFormat
#define SDL_CreateAudioStream IGNORE_THIS_VERSION_OF_SDL_CreateAudioStream
#define SDL_CreateColorCursor IGNORE_THIS_VERSION_OF_SDL_CreateColorCursor
-#define SDL_CreateCond IGNORE_THIS_VERSION_OF_SDL_CreateCond
+#define SDL_CreateCondition IGNORE_THIS_VERSION_OF_SDL_CreateCondition
#define SDL_CreateCursor IGNORE_THIS_VERSION_OF_SDL_CreateCursor
#define SDL_CreateMutex IGNORE_THIS_VERSION_OF_SDL_CreateMutex
#define SDL_CreatePalette IGNORE_THIS_VERSION_OF_SDL_CreatePalette
@@ -106,7 +106,7 @@
#define SDL_DelayNS IGNORE_THIS_VERSION_OF_SDL_DelayNS
#define SDL_DequeueAudio IGNORE_THIS_VERSION_OF_SDL_DequeueAudio
#define SDL_DestroyAudioStream IGNORE_THIS_VERSION_OF_SDL_DestroyAudioStream
-#define SDL_DestroyCond IGNORE_THIS_VERSION_OF_SDL_DestroyCond
+#define SDL_DestroyCondition IGNORE_THIS_VERSION_OF_SDL_DestroyCondition
#define SDL_DestroyMutex IGNORE_THIS_VERSION_OF_SDL_DestroyMutex
#define SDL_DestroyPalette IGNORE_THIS_VERSION_OF_SDL_DestroyPalette
#define SDL_DestroyPixelFormat IGNORE_THIS_VERSION_OF_SDL_DestroyPixelFormat
@@ -574,11 +574,11 @@
#define SDL_SaveBMP_RW IGNORE_THIS_VERSION_OF_SDL_SaveBMP_RW
#define SDL_ScreenKeyboardShown IGNORE_THIS_VERSION_OF_SDL_ScreenKeyboardShown
#define SDL_ScreenSaverEnabled IGNORE_THIS_VERSION_OF_SDL_ScreenSaverEnabled
-#define SDL_SemPost IGNORE_THIS_VERSION_OF_SDL_SemPost
-#define SDL_SemTryWait IGNORE_THIS_VERSION_OF_SDL_SemTryWait
-#define SDL_SemValue IGNORE_THIS_VERSION_OF_SDL_SemValue
-#define SDL_SemWait IGNORE_THIS_VERSION_OF_SDL_SemWait
-#define SDL_SemWaitTimeout IGNORE_THIS_VERSION_OF_SDL_SemWaitTimeout
+#define SDL_PostSemaphore IGNORE_THIS_VERSION_OF_SDL_PostSemaphore
+#define SDL_TryWaitSemaphore IGNORE_THIS_VERSION_OF_SDL_TryWaitSemaphore
+#define SDL_GetSemaphoreValue IGNORE_THIS_VERSION_OF_SDL_GetSemaphoreValue
+#define SDL_WaitSemaphore IGNORE_THIS_VERSION_OF_SDL_WaitSemaphore
+#define SDL_WaitSemaphoreTimeout IGNORE_THIS_VERSION_OF_SDL_WaitSemaphoreTimeout
#define SDL_SendGamepadEffect IGNORE_THIS_VERSION_OF_SDL_SendGamepadEffect
#define SDL_SendJoystickEffect IGNORE_THIS_VERSION_OF_SDL_SendJoystickEffect
#define SDL_SetAssertionHandler IGNORE_THIS_VERSION_OF_SDL_SetAssertionHandler
@@ -1103,20 +1103,20 @@ typedef void (__cdecl *pfnSDL_CurrentEndThread) (unsigned);
#undef SDL_ComposeCustomBlendMode
#endif
-#ifdef SDL_CondBroadcast
-#undef SDL_CondBroadcast
+#ifdef SDL_BroadcastCondition
+#undef SDL_BroadcastCondition
#endif
-#ifdef SDL_CondSignal
-#undef SDL_CondSignal
+#ifdef SDL_SignalCondition
+#undef SDL_SignalCondition
#endif
-#ifdef SDL_CondWait
-#undef SDL_CondWait
+#ifdef SDL_WaitCondition
+#undef SDL_WaitCondition
#endif
-#ifdef SDL_CondWaitTimeout
-#undef SDL_CondWaitTimeout
+#ifdef SDL_WaitConditionTimeout
+#undef SDL_WaitConditionTimeout
#endif
#ifdef SDL_ConvertPixels
@@ -1139,8 +1139,8 @@ typedef void (__cdecl *pfnSDL_CurrentEndThread) (unsigned);
#undef SDL_CreateColorCursor
#endif
-#ifdef SDL_CreateCond
-#undef SDL_CreateCond
+#ifdef SDL_CreateCondition
+#undef SDL_CreateCondition
#endif
#ifdef SDL_CreateCursor
@@ -1247,8 +1247,8 @@ typedef void (__cdecl *pfnSDL_CurrentEndThread) (unsigned);
#undef SDL_DestroyAudioStream
#endif
-#ifdef SDL_DestroyCond
-#undef SDL_DestroyCond
+#ifdef SDL_DestroyCondition
+#undef SDL_DestroyCondition
#endif
#ifdef SDL_DestroyMutex
@@ -3119,24 +3119,24 @@ typedef void (__cdecl *pfnSDL_CurrentEndThread) (unsigned);
#undef SDL_ScreenSaverEnabled
#endif
-#ifdef SDL_SemPost
-#undef SDL_SemPost
+#ifdef SDL_PostSemaphore
+#undef SDL_PostSemaphore
#endif
-#ifdef SDL_SemTryWait
-#undef SDL_SemTryWait
+#ifdef SDL_TryWaitSemaphore
+#undef SDL_TryWaitSemaphore
#endif
-#ifdef SDL_SemValue
-#undef SDL_SemValue
+#ifdef SDL_GetSemaphoreValue
+#undef SDL_GetSemaphoreValue
#endif
-#ifdef SDL_SemWait
-#undef SDL_SemWait
+#ifdef SDL_WaitSemaphore
+#undef SDL_WaitSemaphore
#endif
-#ifdef SDL_SemWaitTimeout
-#undef SDL_SemWaitTimeout
+#ifdef SDL_WaitSemaphoreTimeout
+#undef SDL_WaitSemaphoreTimeout
#endif
#ifdef SDL_SendGamepadEffect
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 4ad30fd..69b5dd5 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -253,24 +253,24 @@ SDL3_SYM(int,SetCursor,(SDL_Cursor *a),(a),return)
SDL3_SYM_PASSTHROUGH(SDL_Cursor*,GetCursor,(void),(),return)
SDL3_SYM_PASSTHROUGH(SDL_Cursor*,GetDefaultCursor,(void),(),return)
SDL3_SYM_RENAMED(void,FreeCursor,DestroyCursor,(SDL_Cursor *a),(a),)
-SDL3_SYM_PASSTHROUGH(SDL_mutex*,CreateMutex,(void),(),return)
-SDL3_SYM_PASSTHROUGH(int,LockMutex,(SDL_mutex *a),(a),return)
-SDL3_SYM_PASSTHROUGH(int,TryLockMutex,(SDL_mutex *a),(a),return)
-SDL3_SYM_PASSTHROUGH(int,UnlockMutex,(SDL_mutex *a),(a),return)
-SDL3_SYM_PASSTHROUGH(void,DestroyMutex,(SDL_mutex *a),(a),)
-SDL3_SYM_PASSTHROUGH(SDL_sem*,CreateSemaphore,(Uint32 a),(a),return)
-SDL3_SYM_PASSTHROUGH(void,DestroySemaphore,(SDL_sem *a),(a),)
-SDL3_SYM_PASSTHROUGH(int,SemWait,(SDL_sem *a),(a),return)
-SDL3_SYM_PASSTHROUGH(int,SemTryWait,(SDL_sem *a),(a),return)
-SDL3_SYM(int,SemWaitTimeout,(SDL_sem *a, Sint32 b),(a,b),return)
-SDL3_SYM_PASSTHROUGH(int,SemPost,(SDL_sem *a),(a),return)
-SDL3_SYM_PASSTHROUGH(Uint32,SemValue,(SDL_sem *a),(a),return)
-SDL3_SYM_PASSTHROUGH(SDL_cond*,CreateCond,(void),(),return)
-SDL3_SYM_PASSTHROUGH(void,DestroyCond,(SDL_cond *a),(a),)
-SDL3_SYM_PASSTHROUGH(int,CondSignal,(SDL_cond *a),(a),return)
-SDL3_SYM_PASSTHROUGH(int,CondBroadcast,(SDL_cond *a),(a),return)
-SDL3_SYM_PASSTHROUGH(int,CondWait,(SDL_cond *a, SDL_mutex *b),(a,b),return)
-SDL3_SYM(int,CondWaitTimeout,(SDL_cond *a, SDL_mutex *b, Sint32 c),(a,b,c),return)
+SDL3_SYM_PASSTHROUGH(SDL_Mutex*,CreateMutex,(void),(),return)
+SDL3_SYM_PASSTHROUGH(int,LockMutex,(SDL_Mutex *a),(a),return)
+SDL3_SYM_PASSTHROUGH(int,TryLockMutex,(SDL_Mutex *a),(a),return)
+SDL3_SYM_PASSTHROUGH(int,UnlockMutex,(SDL_Mutex *a),(a),return)
+SDL3_SYM_PASSTHROUGH(void,DestroyMutex,(SDL_Mutex *a),(a),)
+SDL3_SYM_PASSTHROUGH(SDL_Semaphore*,CreateSemaphore,(Uint32 a),(a),return)
+SDL3_SYM_PASSTHROUGH(void,DestroySemaphore,(SDL_Semaphore *a),(a),)
+SDL3_SYM_RENAMED(int,SemWait,WaitSemaphore,(SDL_Semaphore *a),(a),return)
+SDL3_SYM_RENAMED(int,SemTryWait,TryWaitSemaphore,(SDL_Semaphore *a),(a),return)
+SDL3_SYM(int,WaitSemaphoreTimeout,(SDL_Semaphore *a, Sint32 b),(a,b),return)
+SDL3_SYM_RENAMED(int,SemPost,PostSemaphore,(SDL_Semaphore *a),(a),return)
+SDL3_SYM_RENAMED(Uint32,SemValue,GetSemaphoreValue,(SDL_Semaphore *a),(a),return)
+SDL3_SYM_RENAMED(SDL_Condition*,CreateCond,CreateCondition,(void),(),return)
+SDL3_SYM_RENAMED(void,DestroyCond,DestroyCondition,(SDL_Condition *a),(a),)
+SDL3_SYM_RENAMED(int,CondSignal,SignalCondition,(SDL_Condition *a),(a),return)
+SDL3_SYM_RENAMED(int,CondBroadcast,BroadcastCondition,(SDL_Condition *a),(a),return)
+SDL3_SYM_RENAMED(int,CondWait,WaitCondition,(SDL_Condition *a, SDL_Mutex *b),(a,b),return)
+SDL3_SYM(int,WaitConditionTimeout,(SDL_Condition *a, SDL_Mutex *b, Sint32 c),(a,b,c),return)
SDL3_SYM_PASSTHROUGH(const char*,GetPixelFormatName,(Uint32 a),(a),return)
SDL3_SYM_RENAMED(SDL_bool,PixelFormatEnumToMasks,GetMasksForPixelFormatEnum,(Uint32 a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
SDL3_SYM_RENAMED(Uint32,MasksToPixelFormatEnum,GetPixelFormatEnumForMasks,(int a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),return)