From 61c0c009abd597bc7c3d9d99e4fc4cb26cfd3b67 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 27 Apr 2023 20:49:54 -0700
Subject: [PATCH] Rename SDL semaphore and condition variable functions to
match SDL 3.0 naming convention
Fixes https://github.com/libsdl-org/SDL/issues/7642
---
build-scripts/SDL_migration.cocci | 55 ++++++++
docs/README-migration.md | 15 +++
docs/README-n3ds.md | 2 +-
include/SDL3/SDL_mutex.h | 144 ++++++++++-----------
include/SDL3/SDL_oldnames.h | 26 ++++
src/SDL_internal.h | 4 +-
src/audio/coreaudio/SDL_coreaudio.m | 6 +-
src/audio/jack/SDL_jackaudio.c | 12 +-
src/audio/openslES/SDL_openslES.c | 10 +-
src/audio/wasapi/SDL_wasapi_winrt.cpp | 6 +-
src/core/android/SDL_android.c | 12 +-
src/dynapi/SDL_dynapi.sym | 22 ++--
src/dynapi/SDL_dynapi_overrides.h | 22 ++--
src/dynapi/SDL_dynapi_procs.h | 22 ++--
src/hidapi/libusb/hid.c | 20 +--
src/joystick/hidapi/SDL_hidapi_rumble.c | 6 +-
src/joystick/windows/SDL_windowsjoystick.c | 8 +-
src/thread/SDL_thread.c | 20 +--
src/thread/generic/SDL_syscond.c | 40 +++---
src/thread/generic/SDL_syscond_c.h | 10 +-
src/thread/generic/SDL_sysmutex.c | 6 +-
src/thread/generic/SDL_sysrwlock.c | 8 +-
src/thread/generic/SDL_syssem.c | 22 ++--
src/thread/n3ds/SDL_syscond.c | 14 +-
src/thread/n3ds/SDL_syssem.c | 6 +-
src/thread/ngage/SDL_syssem.cpp | 6 +-
src/thread/ps2/SDL_syssem.c | 6 +-
src/thread/psp/SDL_syscond.c | 30 ++---
src/thread/psp/SDL_syssem.c | 6 +-
src/thread/pthread/SDL_syscond.c | 10 +-
src/thread/pthread/SDL_syssem.c | 6 +-
src/thread/stdcpp/SDL_syscond.cpp | 14 +-
src/thread/vita/SDL_syscond.c | 30 ++---
src/thread/vita/SDL_syssem.c | 6 +-
src/thread/windows/SDL_syscond_cv.c | 60 ++++-----
src/thread/windows/SDL_syssem.c | 42 +++---
src/timer/SDL_timer.c | 6 +-
src/video/android/SDL_androidevents.c | 12 +-
src/video/cocoa/SDL_cocoaopengl.m | 10 +-
src/video/psp/SDL_pspevents.c | 8 +-
src/video/raspberry/SDL_rpiopengles.c | 2 +-
src/video/raspberry/SDL_rpivideo.c | 8 +-
src/video/winrt/SDL_winrtevents.cpp | 12 +-
test/testatomic.c | 4 +-
test/testsem.c | 24 ++--
45 files changed, 458 insertions(+), 362 deletions(-)
diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci
index 9bb8d8ba49ea..2f0469418c20 100644
--- a/build-scripts/SDL_migration.cocci
+++ b/build-scripts/SDL_migration.cocci
@@ -2538,3 +2538,58 @@ typedef SDL_atomic_t, SDL_AtomicInt;
@@
- SDL_atomic_t
+ SDL_AtomicInt
+@@
+@@
+- SDL_SemWait
++ SDL_WaitSemaphore
+ (...)
+@@
+@@
+- SDL_SemTryWait
++ SDL_TryWaitSemaphore
+ (...)
+@@
+@@
+- SDL_SemWaitTimeout
++ SDL_WaitSemaphoreTimeout
+ (...)
+@@
+@@
+- SDL_SemPost
++ SDL_PostSemaphore
+ (...)
+@@
+@@
+- SDL_SemValue
++ SDL_GetSemaphoreValue
+ (...)
+@@
+@@
+- SDL_CreateCond
++ SDL_CreateCondition
+ (...)
+@@
+@@
+- SDL_DestroyCond
++ SDL_DestroyCondition
+ (...)
+@@
+@@
+- SDL_CondSignal
++ SDL_SignalCondition
+ (...)
+@@
+@@
+- SDL_CondBroadcast
++ SDL_BroadcastCondition
+ (...)
+@@
+@@
+- SDL_CondWait
++ SDL_WaitCondition
+ (...)
+@@
+@@
+- SDL_CondWaitTimeout
++ SDL_WaitConditionTimeout
+ (...)
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 736869ff7add..25d762ffba5c 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -554,6 +554,21 @@ SDL_GetMouseState(), SDL_GetGlobalMouseState(), SDL_GetRelativeMouseState(), SDL
The following functions have been renamed:
* SDL_FreeCursor() => SDL_DestroyCursor()
+## SDL_mutex.h
+
+The following functions have been renamed:
+* SDL_CondBroadcast() => SDL_BroadcastCondition()
+* SDL_CondSignal() => SDL_SignalCondition()
+* SDL_CondWait() => SDL_WaitCondition()
+* SDL_CondWaitTimeout() => SDL_WaitConditionTimeout()
+* SDL_CreateCond() => SDL_CreateCondition()
+* SDL_DestroyCond() => SDL_DestroyCondition()
+* SDL_SemPost() => SDL_PostSemaphore()
+* SDL_SemTryWait() => SDL_TryWaitSemaphore()
+* SDL_SemValue() => SDL_GetSemaphoreValue()
+* SDL_SemWait() => SDL_WaitSemaphore()
+* SDL_SemWaitTimeout() => SDL_WaitSemaphoreTimeout()
+
## SDL_pixels.h
SDL_CalculateGammaRamp has been removed, because SDL_SetWindowGammaRamp has been removed as well due to poor support in modern operating systems (see [SDL_video.h](#sdl_videoh)).
diff --git a/docs/README-n3ds.md b/docs/README-n3ds.md
index 33ac084462d6..80da3802d425 100644
--- a/docs/README-n3ds.md
+++ b/docs/README-n3ds.md
@@ -25,4 +25,4 @@ cmake --install build
- SDL3_main should be used to ensure ROMFS is enabled - this is done with `#include <SDL3/SDL_main.h>` in the source file that contains your main function.
- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function.
- `SDL_GetBasePath` returns the romfs root instead of the executable's directory.
-- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information.
+- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_WaitSemaphore`, `SDL_WaitCondition`, `SDL_WaitThread`). To avoid starving other threads, `SDL_TryWaitSemaphore` and `SDL_WaitSemaphoreTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information.
diff --git a/include/SDL3/SDL_mutex.h b/include/SDL3/SDL_mutex.h
index a25d8b8396e2..67741abc314d 100644
--- a/include/SDL3/SDL_mutex.h
+++ b/include/SDL3/SDL_mutex.h
@@ -481,11 +481,11 @@ typedef struct SDL_semaphore SDL_sem;
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_DestroySemaphore
- * \sa SDL_SemPost
- * \sa SDL_SemTryWait
- * \sa SDL_SemValue
- * \sa SDL_SemWait
- * \sa SDL_SemWaitTimeout
+ * \sa SDL_PostSemaphore
+ * \sa SDL_TryWaitSemaphore
+ * \sa SDL_GetSemaphoreValue
+ * \sa SDL_WaitSemaphore
+ * \sa SDL_WaitSemaphoreTimeout
*/
extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
@@ -500,11 +500,11 @@ extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateSemaphore
- * \sa SDL_SemPost
- * \sa SDL_SemTryWait
- * \sa SDL_SemValue
- * \sa SDL_SemWait
- * \sa SDL_SemWaitTimeout
+ * \sa SDL_PostSemaphore
+ * \sa SDL_TryWaitSemaphore
+ * \sa SDL_GetSemaphoreValue
+ * \sa SDL_WaitSemaphore
+ * \sa SDL_WaitSemaphoreTimeout
*/
extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem);
@@ -516,7 +516,7 @@ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem);
* signal or error. If the call is successful it will atomically decrement the
* semaphore value.
*
- * This function is the equivalent of calling SDL_SemWaitTimeout() with a time
+ * This function is the equivalent of calling SDL_WaitSemaphoreTimeout() with a time
* length of `SDL_MUTEX_MAXWAIT`.
*
* \param sem the semaphore wait on
@@ -527,13 +527,13 @@ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem);
*
* \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore
- * \sa SDL_SemPost
- * \sa SDL_SemTryWait
- * \sa SDL_SemValue
- * \sa SDL_SemWait
- * \sa SDL_SemWaitTimeout
+ * \sa SDL_PostSemaphore
+ * \sa SDL_TryWaitSemaphore
+ * \sa SDL_GetSemaphoreValue
+ * \sa SDL_WaitSemaphore
+ * \sa SDL_WaitSemaphoreTimeout
*/
-extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem);
+extern DECLSPEC int SDLCALL SDL_WaitSemaphore(SDL_sem *sem);
/**
* See if a semaphore has a positive value and decrement it if it does.
@@ -552,12 +552,12 @@ extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem);
*
* \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore
- * \sa SDL_SemPost
- * \sa SDL_SemValue
- * \sa SDL_SemWait
- * \sa SDL_SemWaitTimeout
+ * \sa SDL_PostSemaphore
+ * \sa SDL_GetSemaphoreValue
+ * \sa SDL_WaitSemaphore
+ * \sa SDL_WaitSemaphoreTimeout
*/
-extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem);
+extern DECLSPEC int SDLCALL SDL_TryWaitSemaphore(SDL_sem *sem);
/**
* Wait until a semaphore has a positive value and then decrements it.
@@ -577,12 +577,12 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem);
*
* \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore
- * \sa SDL_SemPost
- * \sa SDL_SemTryWait
- * \sa SDL_SemValue
- * \sa SDL_SemWait
+ * \sa SDL_PostSemaphore
+ * \sa SDL_TryWaitSemaphore
+ * \sa SDL_GetSemaphoreValue
+ * \sa SDL_WaitSemaphore
*/
-extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Sint32 timeoutMS);
+extern DECLSPEC int SDLCALL SDL_WaitSemaphoreTimeout(SDL_sem *sem, Sint32 timeoutMS);
/**
* Atomically increment a semaphore's value and wake waiting threads.
@@ -595,12 +595,12 @@ extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Sint32 timeoutMS);
*
* \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore
- * \sa SDL_SemTryWait
- * \sa SDL_SemValue
- * \sa SDL_SemWait
- * \sa SDL_SemWaitTimeout
+ * \sa SDL_TryWaitSemaphore
+ * \sa SDL_GetSemaphoreValue
+ * \sa SDL_WaitSemaphore
+ * \sa SDL_WaitSemaphoreTimeout
*/
-extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem);
+extern DECLSPEC int SDLCALL SDL_PostSemaphore(SDL_sem *sem);
/**
* Get the current value of a semaphore.
@@ -612,7 +612,7 @@ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem);
*
* \sa SDL_CreateSemaphore
*/
-extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem);
+extern DECLSPEC Uint32 SDLCALL SDL_GetSemaphoreValue(SDL_sem *sem);
/* @} *//* Semaphore functions */
@@ -634,13 +634,13 @@ typedef struct SDL_cond SDL_cond;
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_CondBroadcast
- * \sa SDL_CondSignal
- * \sa SDL_CondWait
- * \sa SDL_CondWaitTimeout
- * \sa SDL_DestroyCond
+ * \sa SDL_BroadcastCondition
+ * \sa SDL_SignalCondition
+ * \sa SDL_WaitCondition
+ * \sa SDL_WaitConditionTimeout
+ * \sa SDL_DestroyCondition
*/
-extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
+extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCondition(void);
/**
* Destroy a condition variable.
@@ -649,13 +649,13 @@ extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_CondBroadcast
- * \sa SDL_CondSignal
- * \sa SDL_CondWait
- * \sa SDL_CondWaitTimeout
- * \sa SDL_CreateCond
+ * \sa SDL_BroadcastCondition
+ * \sa SDL_SignalCondition
+ * \sa SDL_WaitCondition
+ * \sa SDL_WaitConditionTimeout
+ * \sa SDL_CreateCondition
*/
-extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond);
+extern DECLSPEC void SDLCALL SDL_DestroyCondition(SDL_cond *cond);
/**
* Restart one of the threads that are waiting on the condition variable.
@@ -666,13 +666,13 @@ extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond);
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_CondBroadcast
- * \sa SDL_CondWait
- * \sa SDL_CondWaitTimeout
- * \sa SDL_CreateCond
- * \sa SDL_DestroyCond
+ * \sa SDL_BroadcastCondition
+ * \sa SDL_WaitCondition
+ * \sa SDL_WaitConditionTimeout
+ * \sa SDL_CreateCondition
+ * \sa SDL_DestroyCondition
*/
-extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond);
+extern DECLSPEC int SDLCALL SDL_SignalCondition(SDL_cond *cond);
/**
* Restart all threads that are waiting on the condition variable.
@@ -683,19 +683,19 @@ extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond);
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_CondSignal
- * \sa SDL_CondWait
- * \sa SDL_CondWaitTimeout
- * \sa SDL_CreateCond
- * \sa SDL_DestroyCond
+ * \sa SDL_SignalCondition
+ * \sa SDL_WaitCondition
+ * \sa SDL_WaitConditionTimeout
+ * \sa SDL_CreateCondition
+ * \sa SDL_DestroyCondition
*/
-extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond);
+extern DECLSPEC int SDLCALL SDL_BroadcastCondition(SDL_cond *cond);
/**
* Wait until a condition variable is signaled.
*
* This function unlocks the specified `mutex` and waits for another thread to
- * call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
+ * call SDL_SignalCondition() or SDL_BroadcastCondition() on the condition variable
* `cond`. Once the condition variable is signaled, the mutex is re-locked and
* the function returns.
*
@@ -703,7 +703,7 @@ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond);
* recursively (more than once) is not supported and leads to undefined
* behavior.
*
- * This function is the equivalent of calling SDL_CondWaitTimeout() with a
+ * This function is the equivalent of calling SDL_WaitConditionTimeout() with a
* time length of `SDL_MUTEX_MAXWAIT`.
*
* \param cond the condition variable to wait on
@@ -713,19 +713,19 @@ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond);
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_CondBroadcast
- * \sa SDL_CondSignal
- * \sa SDL_CondWaitTimeout
- * \sa SDL_CreateCond
- * \sa SDL_DestroyCond
+ * \sa SDL_BroadcastCondition
+ * \sa SDL_SignalCondition
+ * \sa SDL_WaitConditionTimeout
+ * \sa SDL_CreateCondition
+ * \sa SDL_DestroyCondition
*/
-extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex);
+extern DECLSPEC int SDLCALL SDL_WaitCondition(SDL_cond *cond, SDL_mutex *mutex);
/**
* Wait until a condition variable is signaled or a certain time has passed.
*
* This function unlocks the specified `mutex` and waits for another thread to
- * call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
+ * call SDL_SignalCondition() or SDL_BroadcastCondition() on the condition variable
* `cond`, or for the specified time to elapse. Once the condition variable is
* signaled or the time elapsed, the mutex is re-locked and the function
* returns.
@@ -744,13 +744,13 @@ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex);
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_CondBroadcast
- * \sa SDL_CondSignal
- * \sa SDL_CondWait
- * \sa SDL_CreateCond
- * \sa SDL_DestroyCond
+ * \sa SDL_BroadcastCondition
+ * \sa SDL_SignalCondition
+ * \sa SDL_WaitCondition
+ * \sa SDL_CreateCondition
+ * \sa SDL_DestroyCondition
*/
-extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond,
+extern DECLSPEC int SDLCALL SDL_WaitConditionTimeout(SDL_cond *cond,
SDL_mutex *mutex, Sint32 timeoutMS);
/* @} *//* Condition variable functions */
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index 48966e4d4be1..e9348eca9d98 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -314,6 +314,19 @@
/* ##SDL_mouse.h */
#define SDL_FreeCursor SDL_DestroyCursor
+/* ##SDL_mutex.h */
+#define SDL_CondBroadcast SDL_BroadcastCondition
+#define SDL_CondSignal SDL_SignalCondition
+#define SDL_CondWait SDL_WaitCondition
+#define SDL_CondWaitTimeout SDL_WaitConditionTimeout
+#define SDL_CreateCond SDL_CreateCondition
+#define SDL_DestroyCond SDL_DestroyCondition
+#define SDL_SemPost SDL_PostSemaphore
+#define SDL_SemTryWait SDL_TryWaitSemaphore
+#define SDL_SemValue SDL_GetSemaphoreValue
+#define SDL_SemWait SDL_WaitSemaphore
+#define SDL_SemWaitTimeout SDL_WaitSemaphoreTimeout
+
/* ##SDL_pixels.h */
#define SDL_AllocFormat SDL_CreatePixelFormat
#define SDL_AllocPalette SDL_CreatePalette
@@ -711,6 +724,19 @@
/* ##SDL_mouse.h */
#define SDL_FreeCursor SDL_FreeCursor_renamed_SDL_DestroyCursor
+/* ##SDL_mutex.h */
+#define SDL_CondBroadcast SDL_CondBroadcast_renamed_SDL_BroadcastCondition
+#define SDL_CondSignal SDL_CondSignal_renamed_SDL_SignalCondition
+#define SDL_CondWait SDL_CondWait_renamed_SDL_WaitCondition
+#define SDL_CondWaitTimeout SDL_CondWaitTimeout_renamed_SDL_WaitConditionTimeout
+#define SDL_CreateCond SDL_CreateCond_renamed_SDL_CreateCondition
+#define SDL_DestroyCond SDL_DestroyCond_renamed_SDL_DestroyCondition
+#define SDL_SemPost SDL_SemPost_renamed_SDL_PostSemaphore
+#define SDL_SemTryWait SDL_SemTryWait_renamed_SDL_TryWaitSemaphore
+#define SDL_SemValue SDL_SemValue_renamed_SDL_GetSemaphoreValue
+#define SDL_SemWait SDL_SemWait_renamed_SDL_WaitSemaphore
+#define SDL_SemWaitTimeout SDL_SemWaitTimeout_renamed_SDL_WaitSemaphoreTimeout
+
/* ##SDL_pixels.h */
#define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_CreatePixelFormat
#define SDL_AllocPalette SDL_AllocPalette_renamed_SDL_CreatePalette
diff --git a/src/SDL_internal.h b/src/SDL_internal.h
index 7dfcdc85978b..4cc6319cba6d 100644
--- a/src/SDL_internal.h
+++ b/src/SDL_internal.h
@@ -197,8 +197,8 @@
extern "C" {
#endif
-extern DECLSPEC int SDLCALL SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS);
-extern DECLSPEC int SDLCALL SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS);
+extern DECLSPEC int SDLCALL SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS);
+extern DECLSPEC int SDLCALL SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS);
extern DECLSPEC int SDLCALL SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS);
/* Ends C function definitions when using C++ */
diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m
index 48573f96a778..53ff5353c761 100644
--- a/src/audio/coreaudio/SDL_coreaudio.m
+++ b/src/audio/coreaudio/SDL_coreaudio.m
@@ -950,14 +950,14 @@ static int audioqueue_thread(void *arg)
rc = prepare_audioqueue(this);
if (!rc) {
this->hidden->thread_error = SDL_strdup(SDL_GetError());
- SDL_SemPost(this->hidden->ready_semaphore);
+ SDL_PostSemaphore(this->hidden->ready_semaphore);
return 0;
}
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
/* init was successful, alert parent thread and start running... */
- SDL_SemPost(this->hidden->ready_semaphore);
+ SDL_PostSemaphore(this->hidden->ready_semaphore);
while (!SDL_AtomicGet(&this->shutdown)) {
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.10, 1);
@@ -1119,7 +1119,7 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname)
return -1;
}
- SDL_SemWait(this->hidden->ready_semaphore);
+ SDL_WaitSemaphore(this->hidden->ready_semaphore);
SDL_DestroySemaphore(this->hidden->ready_semaphore);
this->hidden->ready_semaphore = NULL;
diff --git a/src/audio/jack/SDL_jackaudio.c b/src/audio/jack/SDL_jackaudio.c
index 19ed12822404..43916bbe5722 100644
--- a/src/audio/jack/SDL_jackaudio.c
+++ b/src/audio/jack/SDL_jackaudio.c
@@ -137,7 +137,7 @@ static void jackShutdownCallback(void *arg) /* JACK went away; device is lost. *
{
SDL_AudioDevice *this = (SDL_AudioDevice *)arg;
SDL_OpenedAudioDeviceDisconnected(this);
- SDL_SemPost(this->hidden->iosem); /* unblock the SDL thread. */
+ SDL_PostSemaphore(this->hidden->iosem); /* unblock the SDL thread. */
}
// !!! FIXME: implement and register these!
@@ -169,7 +169,7 @@ static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
}
}
- SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; refill the buffer. */
+ SDL_PostSemaphore(this->hidden->iosem); /* tell SDL thread we're done; refill the buffer. */
return 0;
}
@@ -177,7 +177,7 @@ static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
static void JACK_WaitDevice(_THIS)
{
if (SDL_AtomicGet(&this->enabled)) {
- if (SDL_SemWait(this->hidden->iosem) == -1) {
+ if (SDL_WaitSemaphore(this->hidden->iosem) == -1) {
SDL_OpenedAudioDeviceDisconnected(this);
}
}
@@ -210,7 +210,7 @@ static int jackProcessCaptureCallback(jack_nframes_t nframes, void *arg)
}
}
- SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; new buffer is ready! */
+ SDL_PostSemaphore(this->hidden->iosem); /* tell SDL thread we're done; new buffer is ready! */
return 0;
}
@@ -219,7 +219,7 @@ static int JACK_CaptureFromDevice(_THIS, void *buffer, int buflen)
SDL_assert(buflen == this->spec.size); /* we always fill a full buffer. */
/* Wait for JACK to fill the iobuffer */
- if (SDL_SemWait(this->hidden->iosem) == -1) {
+ if (SDL_WaitSemaphore(this->hidden->iosem) == -1) {
return -1;
}
@@ -229,7 +229,7 @@ static int JACK_CaptureFromDevice(_THIS, void *buffer, int buflen)
static void JACK_FlushCapture(_THIS)
{
- SDL_SemWait(this->hidden->iosem);
+ SDL_WaitSemaphore(this->hidden->iosem);
}
static void JACK_CloseDevice(_THIS)
diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c
index 6966355f6597..626df9420550 100644
--- a/src/audio/openslES/SDL_openslES.c
+++ b/src/audio/openslES/SDL_openslES.c
@@ -186,7 +186,7 @@ static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context;
LOGV("SLES: Recording Callback");
- SDL_SemPost(audiodata->playsem);
+ SDL_PostSemaphore(audiodata->playsem);
}
static void openslES_DestroyPCMRecorder(_THIS)
@@ -363,7 +363,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context;
LOGV("SLES: Playback Callback");
- SDL_SemPost(audiodata->playsem);
+ SDL_PostSemaphore(audiodata->playsem);
}
static void openslES_DestroyPCMPlayer(_THIS)
@@ -625,7 +625,7 @@ static void openslES_WaitDevice(_THIS)
LOGV("openslES_WaitDevice()");
/* Wait for an audio chunk to finish */
- SDL_SemWait(audiodata->playsem);
+ SDL_WaitSemaphore(audiodata->playsem);
}
static void openslES_PlayDevice(_THIS)
@@ -646,7 +646,7 @@ static void openslES_PlayDevice(_THIS)
/* If Enqueue fails, callback won't be called.
* Post the semphore, not to run out of buffer */
if (SL_RESULT_SUCCESS != result) {
- SDL_SemPost(audiodata->playsem);
+ SDL_PostSemaphore(audiodata->playsem);
}
}
@@ -676,7 +676,7 @@ static int openslES_CaptureFromDevice(_THIS, void *buffer, int buflen)
SLresult result;
/* Wait for new recorded data */
- SDL_SemWait(audiodata->playsem);
+ SDL_WaitSemaphore(audiodata->playsem);
/* Copy it to the output buffer */
SDL_assert(buflen == this->spec.size);
diff --git a/src/audio/wasapi/SDL_wasapi_winrt.cpp b/src/audio/wasapi/SDL_wasapi_winrt.cpp
index 879ac9232e3b..f60180c774a7 100644
--- a/src/audio/wasapi/SDL_wasapi_winrt.cpp
+++ b/src/audio/wasapi/SDL_wasapi_winrt.cpp
@@ -175,7 +175,7 @@ void SDL_WasapiDeviceEventHandler::OnDeviceUpdated(DeviceWatcher ^ sender, Devic
void SDL_WasapiDeviceEventHandler::OnEnumerationCompleted(DeviceWatcher ^ sender, Platform::Object ^ args)
{
SDL_assert(sender == this->watcher);
- SDL_SemPost(this->completed);
+ SDL_PostSemaphore(this->completed);
}
void SDL_WasapiDeviceEventHandler::OnDefaultRenderDeviceChanged(Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args)
@@ -225,8 +225,8 @@ void WASAPI_EnumerateEndpoints(void)
// listening for updates.
playback_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_FALSE);
capture_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_TRUE);
- SDL_SemWait(playback_device_event_handler->completed);
- SDL_SemWait(capture_device_event_handler->completed);
+ SDL_WaitSemaphore(playback_device_event_handler->completed);
+ SDL_WaitSemaphore(capture_device_event_handler->completed);
}
struct SDL_WasapiActivationHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>, FtmBase, IActivateAudioInterfaceCompletionHandler>
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 064b0be36dca..937723a709df 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -859,8 +859,8 @@ void Android_ActivityMutex_Lock_Running()
SDL_LockMutex(Android_ActivityMutex);
- pauseSignaled = SDL_SemValue(Android_PauseSem);
- resumeSignaled = SDL_SemValue(Android_ResumeSem);
+ pauseSignaled = SDL_GetSemaphoreValue(Android_PauseSem);
+ resumeSignaled = SDL_GetSemaphoreValue(Android_ResumeSem);
if (pauseSignaled > resumeSignaled) {
SDL_UnlockMutex(Android_ActivityMutex);
@@ -1225,12 +1225,12 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)(
SDL_SendQuit();
SDL_SendAppEvent(SDL_EVENT_TERMINATING);
/* Robustness: clear any pending Pause */
- while (SDL_SemTryWait(Android_PauseSem) == 0) {
+ while (SDL_TryWaitSemaphore(Android_PauseSem) == 0) {
/* empty */
}
/* Resume the event loop so that the app can catch SDL_EVENT_QUIT which
* should now be the top event in the event queue. */
- SDL_SemPost(Android_ResumeSem);
+ SDL_PostSemaphore(Android_ResumeSem);
}
/* Activity ends */
@@ -1272,7 +1272,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
/* Signal the pause semaphore so the event loop knows to pause and (optionally) block itself.
* Sometimes 2 pauses can be queued (eg pause/resume/pause), so it's always increased. */
- SDL_SemPost(Android_PauseSem);
+ SDL_PostSemaphore(Android_PauseSem);
}
/* Resume */
@@ -1285,7 +1285,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)(
* We can't restore the GL Context here because it needs to be done on the SDL main thread
* and this function will be called from the Java thread instead.
*/
- SDL_SemPost(Android_ResumeSem);
+ SDL_PostSemaphore(Android_ResumeSem);
}
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)(
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index 2a1dd322d2fa..3870424b209d 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -44,16 +44,16 @@ SDL3_0.0.0 {
SDL_CloseJoystick;
SDL_CloseSensor;
SDL_ComposeCustomBlendMode;
- SDL_CondBroadcast;
- SDL_CondSignal;
- SDL_CondWait;
- SDL_CondWaitTimeout;
+ SDL_BroadcastCondition;
+ SDL_SignalCondition;
+ SDL_WaitCondition;
+ SDL_WaitConditionTimeout;
SDL_ConvertPixels;
SDL_ConvertSurface;
SDL_ConvertSurfaceFormat;
SDL_CreateAudioStream;
SDL_CreateColorCursor;
- SDL_CreateCond;
+ SDL_CreateCondition;
SDL_CreateCursor;
SDL_CreateMutex;
SDL_CreatePalette;
@@ -80,7 +80,7 @@ SDL3_0.0.0 {
SDL_DelayNS;
SDL_DequeueAudio;
SDL_DestroyAudioStream;
- SDL_DestroyCond;
+ SDL_DestroyCondition;
SDL_DestroyMutex;
SDL_DestroyPalette;
SDL_DestroyPixelFormat;
@@ -548,11 +548,11 @@ SDL3_0.0.0 {
SDL_SaveBMP_RW;
SDL_ScreenKeyboardShown;
SDL_ScreenSaverEnabled;
- SDL_SemPost;
- SDL_SemTryWait;
- SDL_SemValue;
- SDL_SemWait;
- SDL_SemWaitTimeout;
+ SDL_PostSemaphore;
+ SDL_TryWaitSemaphore;
+ SDL_GetSemaphoreValue;
+ SDL_WaitSemaphore;
+ SDL_WaitSemaphoreTimeout;
SDL_SendGamepadEffect;
SDL_SendJoystickEffect;
SDL_SetAssertionHandler;
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index d9095bec7cbf..5c78a8c00e26 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -68,16 +68,16 @@
#define SDL_CloseJoystick SDL_CloseJoystick_REAL
#define SDL_CloseSensor SDL_CloseSensor_REAL
#define SDL_ComposeCustomBlendMode SDL_ComposeCustomBlendMode_REAL
-#define SDL_CondBroadcast SDL_CondBroadcast_REAL
-#define SDL_CondSignal SDL_CondSignal_REAL
-#define SDL_CondWait SDL_CondWait_REAL
-#define SDL_CondWaitTimeout SDL_CondWaitTimeout_REAL
+#define SDL_BroadcastCondition SDL_BroadcastCondition_REAL
+#define SDL_SignalCondition SDL_SignalCondition_REAL
+#define SDL_WaitCondition SDL_WaitCondition_REAL
+#define SDL_WaitConditionTimeout SDL_WaitConditionTimeout_REAL
#define SDL_ConvertPixels SDL_ConvertPixels_REAL
#define SDL_ConvertSurface SDL_ConvertSurface_REAL
#define SDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat_REAL
#define SDL_CreateAudioStream SDL_CreateAudioStream_REAL
#define SDL_CreateColorCursor SDL_CreateColorCursor_REAL
-#define SDL_CreateCond SDL_CreateCond_REAL
+#define SDL_CreateCondition SDL_CreateCondition_REAL
#define SDL_CreateCursor SDL_CreateCursor_REAL
#define SDL_CreateMutex SDL_CreateMutex_REAL
#define SDL_CreatePalette SDL_CreatePalette_REAL
@@ -104,7 +104,7 @@
#define SDL_DelayNS SDL_DelayNS_REAL
#define SDL_DequeueAudio SDL_DequeueAudio_REAL
#define SDL_DestroyAudioStream SDL_DestroyAudioStream_REAL
-#define SDL_DestroyCond SDL_DestroyCond_REAL
+#define SDL_DestroyCondition SDL_DestroyCondition_REAL
#define SDL_DestroyMutex SDL_DestroyMutex_REAL
#define SDL_DestroyPalette SDL_DestroyPalette_REAL
#define SDL_DestroyPixelFormat SDL_DestroyPixelFormat_REAL
@@ -572,11 +572,11 @@
#define SDL_SaveBMP_RW SDL_SaveBMP_RW_REAL
#define SDL_ScreenKeyboardShown SDL_ScreenKeyboardShown_REAL
#define SDL_ScreenSaverEnabled SDL_ScreenSaverEnabled_REAL
-#define SDL_SemPost SDL_SemPost_REAL
-#define SDL_SemTryWait SDL_SemTryWait_REAL
-#define SDL_SemValue SDL_SemValue_REAL
-#define SDL_SemWait SDL_SemWait_REAL
-#define SDL_SemWaitTimeout SDL_SemWaitTimeout_REAL
+#define SDL_PostSemaphore SDL_PostSemaphore_REAL
+#define SDL_TryWaitSemaphore SDL_TryWaitSemaphore_REAL
+#define SDL_GetSemaphoreValue SDL_GetSemaphoreValue_REAL
+#define SDL_WaitSemaphore SDL_WaitSemaphore_REAL
+#define SDL_WaitSemaphoreTimeout SDL_WaitSemaphoreTimeout_REAL
#define SDL_SendGamepadEffect SDL_SendGamepadEffect_REAL
#define SDL_SendJoystickEffect SDL_SendJoystickEffect_REAL
#define SDL_SetAssertionHandler SDL_SetAssertionHandler_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index bd97581e13ae..fae09a6702c0 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -149,16 +149,16 @@ SDL_DYNAPI_PROC(void,SDL_CloseGamepad,(SDL_Gamepad *a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseJoystick,(SDL_Joystick *a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseSensor,(SDL_Sensor *a),(a),)
SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return)
-SDL_DYNAPI_PROC(int,SDL_CondBroadcast,(SDL_cond *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_CondSignal,(SDL_cond *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_CondWait,(SDL_cond *a, SDL_mutex *b),(a,b),return)
-SDL_DYNAPI_PROC(int,SDL_CondWaitTimeout,(SDL_cond *a, SDL_mutex *b, Sint32 c),(a,b,c),return)
+SDL_DYNAPI_PROC(int,SDL_BroadcastCondition,(SDL_cond *a),(a),re
(Patch may be truncated, please check the link at the top of this post.)