mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-03 14:50:15 +02:00
thread: Locking mutexes and rwlocks are now void functions.
Almost nothing checks these return values, and there's no reason a valid lock should fail to operate. The cases where a lock isn't valid (it's a bogus pointer, it was previously destroyed, a thread is unlocking a lock it doesn't own, etc) are undefined behavior and always were, and should be treated as an application bug. Reference Issue #8096.
This commit is contained in:
@@ -67,17 +67,13 @@ void SDL_DestroyMutex(SDL_Mutex *mutex)
|
||||
}
|
||||
|
||||
/* Lock the mutex */
|
||||
int SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
|
||||
void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
return 0;
|
||||
if (mutex != NULL) {
|
||||
RMutex rmutex;
|
||||
rmutex.SetHandle(mutex->handle);
|
||||
rmutex.Wait();
|
||||
}
|
||||
|
||||
RMutex rmutex;
|
||||
rmutex.SetHandle(mutex->handle);
|
||||
rmutex.Wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Try to lock the mutex */
|
||||
@@ -95,16 +91,12 @@ int SDL_TryLockMutex(SDL_Mutex *mutex)
|
||||
#endif
|
||||
|
||||
/* Unlock the mutex */
|
||||
int SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
|
||||
void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
return 0;
|
||||
if (mutex != NULL) {
|
||||
RMutex rmutex;
|
||||
rmutex.SetHandle(mutex->handle);
|
||||
rmutex.Signal();
|
||||
}
|
||||
|
||||
RMutex rmutex;
|
||||
rmutex.SetHandle(mutex->handle);
|
||||
rmutex.Signal();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user