Rename SDL mutex, semaphore and condition variable types to match SDL 3.0 naming convention

This commit is contained in:
Sam Lantinga
2023-04-28 07:31:12 -07:00
parent 61c0c009ab
commit 87ad71f9b2
75 changed files with 452 additions and 422 deletions

View File

@@ -110,7 +110,7 @@ typedef struct SDL_TLSEntry
struct SDL_TLSEntry *next;
} SDL_TLSEntry;
static SDL_mutex *SDL_generic_TLS_mutex;
static SDL_Mutex *SDL_generic_TLS_mutex;
static SDL_TLSEntry *SDL_generic_TLS;
SDL_TLSData *
@@ -125,7 +125,7 @@ SDL_Generic_GetTLSData(void)
static SDL_SpinLock tls_lock;
SDL_AtomicLock(&tls_lock);
if (SDL_generic_TLS_mutex == NULL) {
SDL_mutex *mutex = SDL_CreateMutex();
SDL_Mutex *mutex = SDL_CreateMutex();
SDL_MemoryBarrierRelease();
SDL_generic_TLS_mutex = mutex;
if (SDL_generic_TLS_mutex == NULL) {
@@ -481,17 +481,17 @@ void SDL_DetachThread(SDL_Thread *thread)
}
}
int SDL_WaitSemaphore(SDL_sem *sem)
int SDL_WaitSemaphore(SDL_Semaphore *sem)
{
return SDL_WaitSemaphoreTimeoutNS(sem, SDL_MUTEX_MAXWAIT);
}
int SDL_TryWaitSemaphore(SDL_sem *sem)
int SDL_TryWaitSemaphore(SDL_Semaphore *sem)
{
return SDL_WaitSemaphoreTimeoutNS(sem, 0);
}
int SDL_WaitSemaphoreTimeout(SDL_sem *sem, Sint32 timeoutMS)
int SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sint32 timeoutMS)
{
Sint64 timeoutNS;
@@ -503,12 +503,12 @@ int SDL_WaitSemaphoreTimeout(SDL_sem *sem, Sint32 timeoutMS)
return SDL_WaitSemaphoreTimeoutNS(sem, timeoutNS);
}
int SDL_WaitCondition(SDL_cond *cond, SDL_mutex *mutex)
int SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mutex)
{
return SDL_WaitConditionTimeoutNS(cond, mutex, SDL_MUTEX_MAXWAIT);
}
int SDL_WaitConditionTimeout(SDL_cond *cond, SDL_mutex *mutex, Sint32 timeoutMS)
int SDL_WaitConditionTimeout(SDL_Condition *cond, SDL_Mutex *mutex, Sint32 timeoutMS)
{
Sint64 timeoutNS;

View File

@@ -42,15 +42,15 @@
typedef struct SDL_cond_generic
{
SDL_mutex *lock;
SDL_Mutex *lock;
int waiting;
int signals;
SDL_sem *wait_sem;
SDL_sem *wait_done;
SDL_Semaphore *wait_sem;
SDL_Semaphore *wait_done;
} SDL_cond_generic;
/* Create a condition variable */
SDL_cond *
SDL_Condition *
SDL_CreateCondition_generic(void)
{
SDL_cond_generic *cond;
@@ -62,17 +62,17 @@ SDL_CreateCondition_generic(void)
cond->wait_done = SDL_CreateSemaphore(0);
cond->waiting = cond->signals = 0;
if (!cond->lock || !cond->wait_sem || !cond->wait_done) {
SDL_DestroyCondition_generic((SDL_cond *)cond);
SDL_DestroyCondition_generic((SDL_Condition *)cond);
cond = NULL;
}
} else {
SDL_OutOfMemory();
}
return (SDL_cond *)cond;
return (SDL_Condition *)cond;
}
/* Destroy a condition variable */
void SDL_DestroyCondition_generic(SDL_cond *_cond)
void SDL_DestroyCondition_generic(SDL_Condition *_cond)
{
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (cond) {
@@ -90,7 +90,7 @@ void SDL_DestroyCondition_generic(SDL_cond *_cond)
}
/* Restart one of the threads that are waiting on the condition variable */
int SDL_SignalCondition_generic(SDL_cond *_cond)
int SDL_SignalCondition_generic(SDL_Condition *_cond)
{
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (cond == NULL) {
@@ -114,7 +114,7 @@ int SDL_SignalCondition_generic(SDL_cond *_cond)
}
/* Restart all threads that are waiting on the condition variable */
int SDL_BroadcastCondition_generic(SDL_cond *_cond)
int SDL_BroadcastCondition_generic(SDL_Condition *_cond)
{
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (cond == NULL) {
@@ -168,7 +168,7 @@ Thread B:
SDL_SignalCondition(cond);
SDL_UnlockMutex(lock);
*/
int SDL_WaitConditionTimeoutNS_generic(SDL_cond *_cond, SDL_mutex *mutex, Sint64 timeoutNS)
int SDL_WaitConditionTimeoutNS_generic(SDL_Condition *_cond, SDL_Mutex *mutex, Sint64 timeoutNS)
{
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
int retval;

View File

@@ -25,11 +25,11 @@
#ifdef SDL_THREAD_GENERIC_COND_SUFFIX
SDL_cond *SDL_CreateCondition_generic(void);
void SDL_DestroyCondition_generic(SDL_cond *cond);
int SDL_SignalCondition_generic(SDL_cond *cond);
int SDL_BroadcastCondition_generic(SDL_cond *cond);
int SDL_WaitConditionTimeoutNS_generic(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS);
SDL_Condition *SDL_CreateCondition_generic(void);
void SDL_DestroyCondition_generic(SDL_Condition *cond);
int SDL_SignalCondition_generic(SDL_Condition *cond);
int SDL_BroadcastCondition_generic(SDL_Condition *cond);
int SDL_WaitConditionTimeoutNS_generic(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS);
#endif /* SDL_THREAD_GENERIC_COND_SUFFIX */

View File

@@ -24,21 +24,21 @@
#include "SDL_systhread_c.h"
struct SDL_mutex
struct SDL_Mutex
{
int recursive;
SDL_threadID owner;
SDL_sem *sem;
SDL_Semaphore *sem;
};
/* Create a mutex */
SDL_mutex *
SDL_Mutex *
SDL_CreateMutex(void)
{
SDL_mutex *mutex;
SDL_Mutex *mutex;
/* Allocate mutex memory */
mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex));
mutex = (SDL_Mutex *)SDL_calloc(1, sizeof(*mutex));
#ifndef SDL_THREADS_DISABLED
if (mutex) {
@@ -59,7 +59,7 @@ SDL_CreateMutex(void)
}
/* Free the mutex */
void SDL_DestroyMutex(SDL_mutex *mutex)
void SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex) {
if (mutex->sem) {
@@ -70,7 +70,7 @@ 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 */
int SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
#ifdef SDL_THREADS_DISABLED
return 0;
@@ -99,7 +99,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
}
/* try Lock the mutex */
int SDL_TryLockMutex(SDL_mutex *mutex)
int SDL_TryLockMutex(SDL_Mutex *mutex)
{
#ifdef SDL_THREADS_DISABLED
return 0;
@@ -131,7 +131,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
}
/* Unlock the mutex */
int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
#ifdef SDL_THREADS_DISABLED
return 0;

View File

@@ -41,18 +41,18 @@
#define SDL_UnlockRWLock_generic SDL_UnlockRWLock
#endif
struct SDL_rwlock
struct SDL_RWLock
{
SDL_mutex *lock;
SDL_cond *condition;
SDL_Mutex *lock;
SDL_Condition *condition;
SDL_threadID writer_thread;
SDL_AtomicInt reader_count;
SDL_AtomicInt writer_count;
};
SDL_rwlock *SDL_CreateRWLock_generic(void)
SDL_RWLock *SDL_CreateRWLock_generic(void)
{
SDL_rwlock *rwlock = (SDL_rwlock *) SDL_malloc(sizeof (*rwlock));
SDL_RWLock *rwlock = (SDL_RWLock *) SDL_malloc(sizeof (*rwlock));
if (!rwlock) {
SDL_OutOfMemory();
@@ -78,7 +78,7 @@ SDL_rwlock *SDL_CreateRWLock_generic(void)
return rwlock;
}
void SDL_DestroyRWLock_generic(SDL_rwlock *rwlock)
void SDL_DestroyRWLock_generic(SDL_RWLock *rwlock)
{
if (rwlock) {
SDL_DestroyMutex(rwlock->lock);
@@ -87,7 +87,7 @@ void SDL_DestroyRWLock_generic(SDL_rwlock *rwlock)
}
}
int SDL_LockRWLockForReading_generic(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_LockRWLockForReading_generic(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (!rwlock) {
return SDL_InvalidParamError("rwlock");
@@ -102,7 +102,7 @@ int SDL_LockRWLockForReading_generic(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_AN
return 0;
}
int SDL_LockRWLockForWriting_generic(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_LockRWLockForWriting_generic(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (!rwlock) {
return SDL_InvalidParamError("rwlock");
@@ -120,7 +120,7 @@ int SDL_LockRWLockForWriting_generic(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_AN
return 0;
}
int SDL_TryLockRWLockForReading_generic(SDL_rwlock *rwlock)
int SDL_TryLockRWLockForReading_generic(SDL_RWLock *rwlock)
{
int rc;
@@ -141,7 +141,7 @@ int SDL_TryLockRWLockForReading_generic(SDL_rwlock *rwlock)
return 0;
}
int SDL_TryLockRWLockForWriting_generic(SDL_rwlock *rwlock)
int SDL_TryLockRWLockForWriting_generic(SDL_RWLock *rwlock)
{
int rc;
@@ -162,7 +162,7 @@ int SDL_TryLockRWLockForWriting_generic(SDL_rwlock *rwlock)
return 0;
}
int SDL_UnlockRWLock_generic(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_UnlockRWLock_generic(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (!rwlock) {
return SDL_InvalidParamError("rwlock");

View File

@@ -25,13 +25,13 @@
#ifdef SDL_THREAD_GENERIC_RWLOCK_SUFFIX
SDL_rwlock *SDL_CreateRWLock_generic(void);
void SDL_DestroyRWLock_generic(SDL_rwlock *rwlock);
int SDL_LockRWLockForReading_generic(SDL_rwlock *rwlock);
int SDL_LockRWLockForWriting_generic(SDL_rwlock *rwlock);
int SDL_TryLockRWLockForReading_generic(SDL_rwlock *rwlock);
int SDL_TryLockRWLockForWriting_generic(SDL_rwlock *rwlock);
int SDL_UnlockRWLock_generic(SDL_rwlock *rwlock);
SDL_RWLock *SDL_CreateRWLock_generic(void);
void SDL_DestroyRWLock_generic(SDL_RWLock *rwlock);
int SDL_LockRWLockForReading_generic(SDL_RWLock *rwlock);
int SDL_LockRWLockForWriting_generic(SDL_RWLock *rwlock);
int SDL_TryLockRWLockForReading_generic(SDL_RWLock *rwlock);
int SDL_TryLockRWLockForWriting_generic(SDL_RWLock *rwlock);
int SDL_UnlockRWLock_generic(SDL_RWLock *rwlock);
#endif /* SDL_THREAD_GENERIC_RWLOCK_SUFFIX */

View File

@@ -26,49 +26,49 @@
#ifdef SDL_THREADS_DISABLED
SDL_sem *
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_SetError("SDL not built with thread support");
return (SDL_sem *)0;
return (SDL_Semaphore *)0;
}
void SDL_DestroySemaphore(SDL_sem *sem)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
}
int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
return SDL_SetError("SDL not built with thread support");
}
Uint32
SDL_GetSemaphoreValue(SDL_sem *sem)
SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
return 0;
}
int SDL_PostSemaphore(SDL_sem *sem)
int SDL_PostSemaphore(SDL_Semaphore *sem)
{
return SDL_SetError("SDL not built with thread support");
}
#else
struct SDL_semaphore
struct SDL_Semaphore
{
Uint32 count;
Uint32 waiters_count;
SDL_mutex *count_lock;
SDL_cond *count_nonzero;
SDL_Mutex *count_lock;
SDL_Condition *count_nonzero;
};
SDL_sem *
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem;
SDL_Semaphore *sem;
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem));
if (sem == NULL) {
SDL_OutOfMemory();
return NULL;
@@ -89,7 +89,7 @@ SDL_CreateSemaphore(Uint32 initial_value)
/* WARNING:
You cannot call this function when another thread is using the semaphore.
*/
void SDL_DestroySemaphore(SDL_sem *sem)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
if (sem) {
sem->count = 0xFFFFFFFF;
@@ -107,7 +107,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
}
}
int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
int retval;
@@ -145,7 +145,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
}
Uint32
SDL_GetSemaphoreValue(SDL_sem *sem)
SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
Uint32 value;
@@ -158,7 +158,7 @@ SDL_GetSemaphoreValue(SDL_sem *sem)
return value;
}
int SDL_PostSemaphore(SDL_sem *sem)
int SDL_PostSemaphore(SDL_Semaphore *sem)
{
if (sem == NULL) {
return SDL_InvalidParamError("sem");

View File

@@ -26,16 +26,16 @@
#include "SDL_sysmutex_c.h"
struct SDL_cond
struct SDL_Condition
{
CondVar cond_variable;
};
/* Create a condition variable */
SDL_cond *
SDL_Condition *
SDL_CreateCondition(void)
{
SDL_cond *cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond));
SDL_Condition *cond = (SDL_Condition *)SDL_malloc(sizeof(SDL_Condition));
if (cond) {
CondVar_Init(&cond->cond_variable);
} else {
@@ -45,7 +45,7 @@ SDL_CreateCondition(void)
}
/* Destroy a condition variable */
void SDL_DestroyCondition(SDL_cond *cond)
void SDL_DestroyCondition(SDL_Condition *cond)
{
if (cond) {
SDL_free(cond);
@@ -53,7 +53,7 @@ void SDL_DestroyCondition(SDL_cond *cond)
}
/* Restart one of the threads that are waiting on the condition variable */
int SDL_SignalCondition(SDL_cond *cond)
int SDL_SignalCondition(SDL_Condition *cond)
{
if (cond == NULL) {
return SDL_InvalidParamError("cond");
@@ -64,7 +64,7 @@ int SDL_SignalCondition(SDL_cond *cond)
}
/* Restart all threads that are waiting on the condition variable */
int SDL_BroadcastCondition(SDL_cond *cond)
int SDL_BroadcastCondition(SDL_Condition *cond)
{
if (cond == NULL) {
return SDL_InvalidParamError("cond");
@@ -95,7 +95,7 @@ Thread B:
SDL_SignalCondition(cond);
SDL_UnlockMutex(lock);
*/
int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS)
{
Result res;

View File

@@ -27,13 +27,13 @@
#include "SDL_sysmutex_c.h"
/* Create a mutex */
SDL_mutex *
SDL_Mutex *
SDL_CreateMutex(void)
{
SDL_mutex *mutex;
SDL_Mutex *mutex;
/* Allocate mutex memory */
mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
mutex = (SDL_Mutex *)SDL_malloc(sizeof(*mutex));
if (mutex) {
RecursiveLock_Init(&mutex->lock);
} else {
@@ -43,7 +43,7 @@ SDL_CreateMutex(void)
}
/* Free the mutex */
void SDL_DestroyMutex(SDL_mutex *mutex)
void SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex) {
SDL_free(mutex);
@@ -51,7 +51,7 @@ 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 */
int SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (mutex == NULL) {
return 0;
@@ -63,7 +63,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
}
/* try Lock the mutex */
int SDL_TryLockMutex(SDL_mutex *mutex)
int SDL_TryLockMutex(SDL_Mutex *mutex)
{
if (mutex == NULL) {
return 0;
@@ -73,7 +73,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
}
/* Unlock the mutex */
int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (mutex == NULL) {
return 0;

View File

@@ -25,7 +25,7 @@
#include <3ds.h>
struct SDL_mutex
struct SDL_Mutex
{
RecursiveLock lock;
};

View File

@@ -26,23 +26,23 @@
#include <3ds.h>
int WaitOnSemaphoreFor(SDL_sem *sem, Sint64 timeout);
int WaitOnSemaphoreFor(SDL_Semaphore *sem, Sint64 timeout);
struct SDL_semaphore
struct SDL_Semaphore
{
LightSemaphore semaphore;
};
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem;
SDL_Semaphore *sem;
if (initial_value > SDL_MAX_SINT16) {
SDL_SetError("Initial semaphore value too high for this platform");
return NULL;
}
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem));
if (sem == NULL) {
SDL_OutOfMemory();
return NULL;
@@ -56,12 +56,12 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
/* WARNING:
You cannot call this function when another thread is using the semaphore.
*/
void SDL_DestroySemaphore(SDL_sem *sem)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
SDL_free(sem);
}
int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
if (sem == NULL) {
return SDL_InvalidParamError("sem");
@@ -79,7 +79,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
return 0;
}
int WaitOnSemaphoreFor(SDL_sem *sem, Sint64 timeout)
int WaitOnSemaphoreFor(SDL_Semaphore *sem, Sint64 timeout)
{
Uint64 stop_time = SDL_GetTicksNS() + timeout;
Uint64 current_time = SDL_GetTicksNS();
@@ -97,7 +97,7 @@ int WaitOnSemaphoreFor(SDL_sem *sem, Sint64 timeout)
return SDL_MUTEX_TIMEDOUT;
}
Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
if (sem == NULL) {
SDL_InvalidParamError("sem");
@@ -106,7 +106,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
return sem->semaphore.current_count;
}
int SDL_PostSemaphore(SDL_sem *sem)
int SDL_PostSemaphore(SDL_Semaphore *sem)
{
if (sem == NULL) {
return SDL_InvalidParamError("sem");

View File

@@ -26,7 +26,7 @@
#include "SDL_systhread_c.h"
struct SDL_mutex
struct SDL_Mutex
{
TInt handle;
};
@@ -39,7 +39,7 @@ static TInt NewMutex(const TDesC &aName, TAny *aPtr1, TAny *)
}
/* Create a mutex */
SDL_mutex *
SDL_Mutex *
SDL_CreateMutex(void)
{
RMutex rmutex;
@@ -49,13 +49,13 @@ SDL_CreateMutex(void)
SDL_SetError("Couldn't create mutex.");
return NULL;
}
SDL_mutex *mutex = new /*(ELeave)*/ SDL_mutex;
SDL_Mutex *mutex = new /*(ELeave)*/ SDL_Mutex;
mutex->handle = rmutex.Handle();
return mutex;
}
/* Free the mutex */
void SDL_DestroyMutex(SDL_mutex *mutex)
void SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex) {
RMutex rmutex;
@@ -68,7 +68,7 @@ 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 */
int SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (mutex == NULL) {
return 0;
@@ -84,7 +84,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
/* Try to lock the mutex */
#if 0
int
SDL_TryLockMutex(SDL_mutex *mutex)
SDL_TryLockMutex(SDL_Mutex *mutex)
{
if (mutex == NULL)
{
@@ -97,7 +97,7 @@ 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 */
int SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (mutex == NULL) {
return 0;

View File

@@ -27,7 +27,7 @@
/* !!! FIXME: Should this be SDL_MUTEX_TIMEDOUT? */
#define SDL_MUTEX_TIMEOUT -2
struct SDL_semaphore
struct SDL_Semaphore
{
TInt handle;
TInt count;
@@ -65,7 +65,7 @@ static TInt NewSema(const TDesC &aName, TAny *aPtr1, TAny *aPtr2)
return ((RSemaphore *)aPtr1)->CreateGlobal(aName, value);
}
static void WaitAll(SDL_sem *sem)
static void WaitAll(SDL_Semaphore *sem)
{
RSemaphore sema;
sema.SetHandle(sem->handle);
@@ -75,7 +75,7 @@ static void WaitAll(SDL_sem *sem)
}
}
SDL_sem *
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
{
RSemaphore s;
@@ -83,13 +83,13 @@ SDL_CreateSemaphore(Uint32 initial_value)
if (status != KErrNone) {
SDL_SetError("Couldn't create semaphore");
}
SDL_semaphore *sem = new /*(ELeave)*/ SDL_semaphore;
SDL_Semaphore *sem = new /*(ELeave)*/ SDL_Semaphore;
sem->handle = s.Handle();
sem->count = initial_value;
return sem;
}
void SDL_DestroySemaphore(SDL_sem *sem)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
if (sem != NULL) {
RSemaphore sema;
@@ -101,7 +101,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
}
}
int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
if (sem == NULL) {
return SDL_InvalidParamError("sem");
@@ -140,7 +140,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
}
Uint32
SDL_GetSemaphoreValue(SDL_sem *sem)
SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
if (sem == NULL) {
SDL_InvalidParamError("sem");
@@ -149,7 +149,7 @@ SDL_GetSemaphoreValue(SDL_sem *sem)
return sem->count;
}
int SDL_PostSemaphore(SDL_sem *sem)
int SDL_PostSemaphore(SDL_Semaphore *sem)
{
if (sem == NULL) {
return SDL_InvalidParamError("sem");

View File

@@ -30,7 +30,7 @@
#include <kernel.h>
struct SDL_semaphore
struct SDL_Semaphore
{
s32 semid;
};
@@ -41,12 +41,12 @@ static void usercb(struct timer_alarm_t *alarm, void *arg)
}
/* Create a semaphore */
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem;
SDL_Semaphore *sem;
ee_sema_t sema;
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem));
if (sem != NULL) {
/* TODO: Figure out the limit on the maximum value. */
sema.init_count = initial_value;
@@ -67,7 +67,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
}
/* Free the semaphore */
void SDL_DestroySemaphore(SDL_sem *sem)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
if (sem != NULL) {
if (sem->semid > 0) {
@@ -79,7 +79,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
}
}
int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
int ret;
struct timer_alarm_t alarm;
@@ -110,7 +110,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
}
/* Returns the current count of the semaphore */
Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
ee_sema_t info;
@@ -126,7 +126,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
return 0;
}
int SDL_PostSemaphore(SDL_sem *sem)
int SDL_PostSemaphore(SDL_Semaphore *sem)
{
int res;

View File

@@ -28,22 +28,22 @@
implementation, written by Christopher Tate and Owen Smith. Thanks!
*/
struct SDL_cond
struct SDL_Condition
{
SDL_mutex *lock;
SDL_Mutex *lock;
int waiting;
int signals;
SDL_sem *wait_sem;
SDL_sem *wait_done;
SDL_Semaphore *wait_sem;
SDL_Semaphore *wait_done;
};
/* Create a condition variable */
SDL_cond *
SDL_Condition *
SDL_CreateCondition(void)
{
SDL_cond *cond;
SDL_Condition *cond;
cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond));
cond = (SDL_Condition *)SDL_malloc(sizeof(SDL_Condition));
if (cond) {
cond->lock = SDL_CreateMutex();
cond->wait_sem = SDL_CreateSemaphore(0);
@@ -60,7 +60,7 @@ SDL_CreateCondition(void)
}
/* Destroy a condition variable */
void SDL_DestroyCondition(SDL_cond *cond)
void SDL_DestroyCondition(SDL_Condition *cond)
{
if (cond) {
if (cond->wait_sem) {
@@ -77,7 +77,7 @@ void SDL_DestroyCondition(SDL_cond *cond)
}
/* Restart one of the threads that are waiting on the condition variable */
int SDL_SignalCondition(SDL_cond *cond)
int SDL_SignalCondition(SDL_Condition *cond)
{
if (cond == NULL) {
return SDL_InvalidParamError("cond");
@@ -100,7 +100,7 @@ int SDL_SignalCondition(SDL_cond *cond)
}
/* Restart all threads that are waiting on the condition variable */
int SDL_BroadcastCondition(SDL_cond *cond)
int SDL_BroadcastCondition(SDL_Condition *cond)
{
if (cond == NULL) {
return SDL_InvalidParamError("cond");
@@ -153,7 +153,7 @@ Thread B:
SDL_SignalCondition(cond);
SDL_UnlockMutex(lock);
*/
int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS)
{
int retval;

View File

@@ -31,20 +31,20 @@
#define SCE_KERNEL_MUTEX_ATTR_RECURSIVE 0x0200U
struct SDL_mutex
struct SDL_Mutex
{
SceLwMutexWorkarea lock;
};
/* Create a mutex */
SDL_mutex *
SDL_Mutex *
SDL_CreateMutex(void)
{
SDL_mutex *mutex = NULL;
SDL_Mutex *mutex = NULL;
SceInt32 res = 0;
/* Allocate mutex memory */
mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
mutex = (SDL_Mutex *)SDL_malloc(sizeof(*mutex));
if (mutex) {
res = sceKernelCreateLwMutex(
@@ -64,7 +64,7 @@ SDL_CreateMutex(void)
}
/* Free the mutex */
void SDL_DestroyMutex(SDL_mutex *mutex)
void SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex) {
sceKernelDeleteLwMutex(&mutex->lock);
@@ -73,7 +73,7 @@ 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 */
int SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
#ifdef SDL_THREADS_DISABLED
return 0;
@@ -94,7 +94,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
}
/* Try to lock the mutex */
int SDL_TryLockMutex(SDL_mutex *mutex)
int SDL_TryLockMutex(SDL_Mutex *mutex)
{
#ifdef SDL_THREADS_DISABLED
return 0;
@@ -123,7 +123,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
}
/* Unlock the mutex */
int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
#ifdef SDL_THREADS_DISABLED
return 0;

View File

@@ -30,17 +30,17 @@
#include <pspthreadman.h>
#include <pspkerror.h>
struct SDL_semaphore
struct SDL_Semaphore
{
SceUID semid;
};
/* Create a semaphore */
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem;
SDL_Semaphore *sem;
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem));
if (sem != NULL) {
/* TODO: Figure out the limit on the maximum value. */
sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL);
@@ -57,7 +57,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
}
/* Free the semaphore */
void SDL_DestroySemaphore(SDL_sem *sem)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
if (sem != NULL) {
if (sem->semid > 0) {
@@ -73,7 +73,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
* If the timeout is 0 then just poll the semaphore; if it's SDL_MUTEX_MAXWAIT, pass
* NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout
* is specified, convert it to microseconds. */
int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
SceUInt timeoutUS;
SceUInt *pTimeout;
@@ -110,7 +110,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
}
/* Returns the current count of the semaphore */
Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
SceKernelSemaInfo info;
@@ -126,7 +126,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
return 0;
}
int SDL_PostSemaphore(SDL_sem *sem)
int SDL_PostSemaphore(SDL_Semaphore *sem)
{
int res;

View File

@@ -28,18 +28,18 @@
#include "SDL_sysmutex_c.h"
struct SDL_cond
struct SDL_Condition
{
pthread_cond_t cond;
};
/* Create a condition variable */
SDL_cond *
SDL_Condition *
SDL_CreateCondition(void)
{
SDL_cond *cond;
SDL_Condition *cond;
cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond));
cond = (SDL_Condition *)SDL_malloc(sizeof(SDL_Condition));
if (cond) {
if (pthread_cond_init(&cond->cond, NULL) != 0) {
SDL_SetError("pthread_cond_init() failed");
@@ -51,7 +51,7 @@ SDL_CreateCondition(void)
}
/* Destroy a condition variable */
void SDL_DestroyCondition(SDL_cond *cond)
void SDL_DestroyCondition(SDL_Condition *cond)
{
if (cond) {
pthread_cond_destroy(&cond->cond);
@@ -60,7 +60,7 @@ void SDL_DestroyCondition(SDL_cond *cond)
}
/* Restart one of the threads that are waiting on the condition variable */
int SDL_SignalCondition(SDL_cond *cond)
int SDL_SignalCondition(SDL_Condition *cond)
{
int retval;
@@ -76,7 +76,7 @@ int SDL_SignalCondition(SDL_cond *cond)
}
/* Restart all threads that are waiting on the condition variable */
int SDL_BroadcastCondition(SDL_cond *cond)
int SDL_BroadcastCondition(SDL_Condition *cond)
{
int retval;
@@ -91,7 +91,7 @@ int SDL_BroadcastCondition(SDL_cond *cond)
return retval;
}
int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS)
{
int retval;
#ifndef HAVE_CLOCK_GETTIME

View File

@@ -25,14 +25,14 @@
#include "SDL_sysmutex_c.h"
SDL_mutex *
SDL_Mutex *
SDL_CreateMutex(void)
{
SDL_mutex *mutex;
SDL_Mutex *mutex;
pthread_mutexattr_t attr;
/* Allocate the structure */
mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex));
mutex = (SDL_Mutex *)SDL_calloc(1, sizeof(*mutex));
if (mutex) {
pthread_mutexattr_init(&attr);
#ifdef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
@@ -53,7 +53,7 @@ SDL_CreateMutex(void)
return mutex;
}
void SDL_DestroyMutex(SDL_mutex *mutex)
void SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex) {
pthread_mutex_destroy(&mutex->id);
@@ -62,7 +62,7 @@ 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 */
int SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
#ifdef FAKE_RECURSIVE_MUTEX
pthread_t this_thread;
@@ -96,7 +96,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
return 0;
}
int SDL_TryLockMutex(SDL_mutex *mutex)
int SDL_TryLockMutex(SDL_Mutex *mutex)
{
int retval;
int result;
@@ -141,7 +141,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
return retval;
}
int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (mutex == NULL) {
return 0;

View File

@@ -28,7 +28,7 @@
#define FAKE_RECURSIVE_MUTEX
#endif
struct SDL_mutex
struct SDL_Mutex
{
pthread_mutex_t id;
#ifdef FAKE_RECURSIVE_MUTEX

View File

@@ -23,19 +23,19 @@
#include <errno.h>
#include <pthread.h>
struct SDL_rwlock
struct SDL_RWLock
{
pthread_rwlock_t id;
};
SDL_rwlock *
SDL_RWLock *
SDL_CreateRWLock(void)
{
SDL_rwlock *rwlock;
SDL_RWLock *rwlock;
/* Allocate the structure */
rwlock = (SDL_rwlock *)SDL_calloc(1, sizeof(*rwlock));
rwlock = (SDL_RWLock *)SDL_calloc(1, sizeof(*rwlock));
if (rwlock) {
if (pthread_rwlock_init(&rwlock->id, NULL) != 0) {
SDL_SetError("pthread_rwlock_init() failed");
@@ -48,7 +48,7 @@ SDL_CreateRWLock(void)
return rwlock;
}
void SDL_DestroyRWLock(SDL_rwlock *rwlock)
void SDL_DestroyRWLock(SDL_RWLock *rwlock)
{
if (rwlock) {
pthread_rwlock_destroy(&rwlock->id);
@@ -56,7 +56,7 @@ void SDL_DestroyRWLock(SDL_rwlock *rwlock)
}
}
int SDL_LockRWLockForReading(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_LockRWLockForReading(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (rwlock == NULL) {
return SDL_InvalidParamError("rwlock");
@@ -66,7 +66,7 @@ int SDL_LockRWLockForReading(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /
return 0;
}
int SDL_LockRWLockForWriting(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (rwlock == NULL) {
return SDL_InvalidParamError("rwlock");
@@ -76,7 +76,7 @@ int SDL_LockRWLockForWriting(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /
return 0;
}
int SDL_TryLockRWLockForReading(SDL_rwlock *rwlock)
int SDL_TryLockRWLockForReading(SDL_RWLock *rwlock)
{
int retval = 0;
@@ -95,7 +95,7 @@ int SDL_TryLockRWLockForReading(SDL_rwlock *rwlock)
return retval;
}
int SDL_TryLockRWLockForWriting(SDL_rwlock *rwlock)
int SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock)
{
int retval = 0;
@@ -115,7 +115,7 @@ int SDL_TryLockRWLockForWriting(SDL_rwlock *rwlock)
return retval;
}
int SDL_UnlockRWLock(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_UnlockRWLock(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (rwlock == NULL) {
return SDL_InvalidParamError("rwlock");

View File

@@ -33,16 +33,16 @@
#include "../generic/SDL_syssem.c"
#else
struct SDL_semaphore
struct SDL_Semaphore
{
sem_t sem;
};
/* Create a semaphore, initialized with value */
SDL_sem *
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem = (SDL_sem *)SDL_malloc(sizeof(SDL_sem));
SDL_Semaphore *sem = (SDL_Semaphore *)SDL_malloc(sizeof(SDL_Semaphore));
if (sem != NULL) {
if (sem_init(&sem->sem, 0, initial_value) < 0) {
SDL_SetError("sem_init() failed");
@@ -55,7 +55,7 @@ SDL_CreateSemaphore(Uint32 initial_value)
return sem;
}
void SDL_DestroySemaphore(SDL_sem *sem)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
if (sem != NULL) {
sem_destroy(&sem->sem);
@@ -63,7 +63,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
}
}
int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
int retval = 0;
#ifdef HAVE_SEM_TIMEDWAIT
@@ -150,7 +150,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
}
Uint32
SDL_GetSemaphoreValue(SDL_sem *sem)
SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
int ret = 0;
@@ -166,7 +166,7 @@ SDL_GetSemaphoreValue(SDL_sem *sem)
return (Uint32)ret;
}
int SDL_PostSemaphore(SDL_sem *sem)
int SDL_PostSemaphore(SDL_Semaphore *sem)
{
int retval;

View File

@@ -30,18 +30,18 @@ extern "C" {
#include "SDL_sysmutex_c.h"
struct SDL_cond
struct SDL_Condition
{
std::condition_variable_any cpp_cond;
};
/* Create a condition variable */
extern "C" SDL_cond *
extern "C" SDL_Condition *
SDL_CreateCondition(void)
{
/* Allocate and initialize the condition variable */
try {
SDL_cond *cond = new SDL_cond;
SDL_Condition *cond = new SDL_Condition;
return cond;
} catch (std::system_error &ex) {
SDL_SetError("unable to create a C++ condition variable: code=%d; %s", ex.code(), ex.what());
@@ -54,7 +54,7 @@ SDL_CreateCondition(void)
/* Destroy a condition variable */
extern "C" void
SDL_DestroyCondition(SDL_cond *cond)
SDL_DestroyCondition(SDL_Condition *cond)
{
if (cond != NULL) {
delete cond;
@@ -63,7 +63,7 @@ SDL_DestroyCondition(SDL_cond *cond)
/* Restart one of the threads that are waiting on the condition variable */
extern "C" int
SDL_SignalCondition(SDL_cond *cond)
SDL_SignalCondition(SDL_Condition *cond)
{
if (cond == NULL) {
return SDL_InvalidParamError("cond");
@@ -75,7 +75,7 @@ SDL_SignalCondition(SDL_cond *cond)
/* Restart all threads that are waiting on the condition variable */
extern "C" int
SDL_BroadcastCondition(SDL_cond *cond)
SDL_BroadcastCondition(SDL_Condition *cond)
{
if (cond == NULL) {
return SDL_InvalidParamError("cond");
@@ -107,7 +107,7 @@ Thread B:
SDL_UnlockMutex(lock);
*/
extern "C" int
SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS)
{
if (cond == NULL) {
return SDL_InvalidParamError("cond");

View File

@@ -30,12 +30,12 @@ extern "C" {
#include <Windows.h>
/* Create a mutex */
extern "C" SDL_mutex *
extern "C" SDL_Mutex *
SDL_CreateMutex(void)
{
/* Allocate and initialize the mutex */
try {
SDL_mutex *mutex = new SDL_mutex;
SDL_Mutex *mutex = new SDL_Mutex;
return mutex;
} catch (std::system_error &ex) {
SDL_SetError("unable to create a C++ mutex: code=%d; %s", ex.code(), ex.what());
@@ -48,7 +48,7 @@ SDL_CreateMutex(void)
/* Free the mutex */
extern "C" void
SDL_DestroyMutex(SDL_mutex *mutex)
SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex != NULL) {
delete mutex;
@@ -57,7 +57,7 @@ SDL_DestroyMutex(SDL_mutex *mutex)
/* Lock the mutex */
extern "C" int
SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (mutex == NULL) {
return 0;
@@ -72,7 +72,7 @@ SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't k
}
/* TryLock the mutex */
int SDL_TryLockMutex(SDL_mutex *mutex)
int SDL_TryLockMutex(SDL_Mutex *mutex)
{
int retval = 0;
@@ -88,7 +88,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
/* Unlock the mutex */
extern "C" int
SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (mutex == NULL) {
return 0;

View File

@@ -22,7 +22,7 @@
#include <mutex>
struct SDL_mutex
struct SDL_Mutex
{
std::recursive_mutex cpp_mutex;
};

View File

@@ -24,18 +24,18 @@
#include <system_error>
#include <Windows.h>
struct SDL_rwlock
struct SDL_RWLock
{
std::shared_mutex cpp_mutex;
SDL_threadID write_owner;
};
/* Create a rwlock */
extern "C" SDL_rwlock *SDL_CreateRWLock(void)
extern "C" SDL_RWLock *SDL_CreateRWLock(void)
{
/* Allocate and initialize the rwlock */
try {
SDL_rwlock *rwlock = new SDL_rwlock;
SDL_RWLock *rwlock = new SDL_RWLock;
return rwlock;
} catch (std::system_error &ex) {
SDL_SetError("unable to create a C++ rwlock: code=%d; %s", ex.code(), ex.what());
@@ -47,7 +47,7 @@ extern "C" SDL_rwlock *SDL_CreateRWLock(void)
}
/* Free the rwlock */
extern "C" void SDL_DestroyRWLock(SDL_rwlock *rwlock)
extern "C" void SDL_DestroyRWLock(SDL_RWLock *rwlock)
{
if (rwlock != NULL) {
delete rwlock;
@@ -55,7 +55,7 @@ extern "C" void SDL_DestroyRWLock(SDL_rwlock *rwlock)
}
/* Lock the rwlock */
extern "C" int SDL_LockRWLockForReading(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
extern "C" int SDL_LockRWLockForReading(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (!rwlock) {
return SDL_InvalidParamError("rwlock");
@@ -70,7 +70,7 @@ extern "C" int SDL_LockRWLockForReading(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY
}
/* Lock the rwlock for writing */
extern "C" int SDL_LockRWLockForWriting(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
extern "C" int SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (!rwlock) {
return SDL_InvalidParamError("rwlock");
@@ -86,7 +86,7 @@ extern "C" int SDL_LockRWLockForWriting(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY
}
/* TryLock the rwlock for reading */
int SDL_TryLockRWLockForReading(SDL_rwlock *rwlock)
int SDL_TryLockRWLockForReading(SDL_RWLock *rwlock)
{
int retval = 0;
@@ -99,7 +99,7 @@ int SDL_TryLockRWLockForReading(SDL_rwlock *rwlock)
}
/* TryLock the rwlock for writing */
int SDL_TryLockRWLockForWriting(SDL_rwlock *rwlock)
int SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock)
{
int retval = 0;
@@ -115,7 +115,7 @@ int SDL_TryLockRWLockForWriting(SDL_rwlock *rwlock)
/* Unlock the rwlock */
extern "C" int
SDL_UnlockRWLock(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
SDL_UnlockRWLock(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
if (!rwlock) {
return SDL_InvalidParamError("rwlock");

View File

@@ -28,22 +28,22 @@
implementation, written by Christopher Tate and Owen Smith. Thanks!
*/
struct SDL_cond
struct SDL_Condition
{
SDL_mutex *lock;
SDL_Mutex *lock;
int waiting;
int signals;
SDL_sem *wait_sem;
SDL_sem *wait_done;
SDL_Semaphore *wait_sem;
SDL_Semaphore *wait_done;
};
/* Create a condition variable */
SDL_cond *
SDL_Condition *
SDL_CreateCondition(void)
{
SDL_cond *cond;
SDL_Condition *cond;
cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond));
cond = (SDL_Condition *)SDL_malloc(sizeof(SDL_Condition));
if (cond != NULL) {
cond->lock = SDL_CreateMutex();
cond->wait_sem = SDL_CreateSemaphore(0);
@@ -60,7 +60,7 @@ SDL_CreateCondition(void)
}
/* Destroy a condition variable */
void SDL_DestroyCondition(SDL_cond *cond)
void SDL_DestroyCondition(SDL_Condition *cond)
{
if (cond != NULL) {
if (cond->wait_sem) {
@@ -77,7 +77,7 @@ void SDL_DestroyCondition(SDL_cond *cond)
}
/* Restart one of the threads that are waiting on the condition variable */
int SDL_SignalCondition(SDL_cond *cond)
int SDL_SignalCondition(SDL_Condition *cond)
{
if (cond == NULL) {
return SDL_InvalidParamError("cond");
@@ -100,7 +100,7 @@ int SDL_SignalCondition(SDL_cond *cond)
}
/* Restart all threads that are waiting on the condition variable */
int SDL_BroadcastCondition(SDL_cond *cond)
int SDL_BroadcastCondition(SDL_Condition *cond)
{
if (cond == NULL) {
return SDL_InvalidParamError("cond");
@@ -153,7 +153,7 @@ Thread B:
SDL_SignalCondition(cond);
SDL_UnlockMutex(lock);
*/
int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS)
{
int retval;

View File

@@ -27,20 +27,20 @@
#include <psp2/kernel/threadmgr.h>
#include <psp2/kernel/error.h>
struct SDL_mutex
struct SDL_Mutex
{
SceKernelLwMutexWork lock;
};
/* Create a mutex */
SDL_mutex *
SDL_Mutex *
SDL_CreateMutex(void)
{
SDL_mutex *mutex = NULL;
SDL_Mutex *mutex = NULL;
SceInt32 res = 0;
/* Allocate mutex memory */
mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
mutex = (SDL_Mutex *)SDL_malloc(sizeof(*mutex));
if (mutex != NULL) {
res = sceKernelCreateLwMutex(
@@ -60,7 +60,7 @@ SDL_CreateMutex(void)
}
/* Free the mutex */
void SDL_DestroyMutex(SDL_mutex *mutex)
void SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex != NULL) {
sceKernelDeleteLwMutex(&mutex->lock);
@@ -69,7 +69,7 @@ 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 */
int SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
#ifdef SDL_THREADS_DISABLED
return 0;
@@ -90,7 +90,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
}
/* Try to lock the mutex */
int SDL_TryLockMutex(SDL_mutex *mutex)
int SDL_TryLockMutex(SDL_Mutex *mutex)
{
#ifdef SDL_THREADS_DISABLED
return 0;
@@ -119,7 +119,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
}
/* Unlock the mutex */
int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
#ifdef SDL_THREADS_DISABLED
return 0;

View File

@@ -31,17 +31,17 @@
#include <psp2/kernel/error.h>
#include <psp2/kernel/threadmgr.h>
struct SDL_semaphore
struct SDL_Semaphore
{
SceUID semid;
};
/* Create a semaphore */
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem;
SDL_Semaphore *sem;
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem));
if (sem != NULL) {
/* TODO: Figure out the limit on the maximum value. */
sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL);
@@ -58,7 +58,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
}
/* Free the semaphore */
void SDL_DestroySemaphore(SDL_sem *sem)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
if (sem != NULL) {
if (sem->semid > 0) {
@@ -74,7 +74,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
* If the timeout is 0 then just poll the semaphore; if it's SDL_MUTEX_MAXWAIT, pass
* NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout
* is specified, convert it to microseconds. */
int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
SceUInt timeoutUS;
SceUInt *pTimeout;
@@ -111,7 +111,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
}
/* Returns the current count of the semaphore */
Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
SceKernelSemaInfo info;
info.size = sizeof(info);
@@ -128,7 +128,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
return 0;
}
int SDL_PostSemaphore(SDL_sem *sem)
int SDL_PostSemaphore(SDL_Semaphore *sem)
{
int res;

View File

@@ -23,11 +23,11 @@
#include "../generic/SDL_syscond_c.h"
#include "SDL_sysmutex_c.h"
typedef SDL_cond *(*pfnSDL_CreateCondition)(void);
typedef void (*pfnSDL_DestroyCondition)(SDL_cond *);
typedef int (*pfnSDL_SignalCondition)(SDL_cond *);
typedef int (*pfnSDL_BroadcastCondition)(SDL_cond *);
typedef int (*pfnSDL_WaitConditionTimeoutNS)(SDL_cond *, SDL_mutex *, Sint64);
typedef SDL_Condition *(*pfnSDL_CreateCondition)(void);
typedef void (*pfnSDL_DestroyCondition)(SDL_Condition *);
typedef int (*pfnSDL_SignalCondition)(SDL_Condition *);
typedef int (*pfnSDL_BroadcastCondition)(SDL_Condition *);
typedef int (*pfnSDL_WaitConditionTimeoutNS)(SDL_Condition *, SDL_Mutex *, Sint64);
typedef struct SDL_cond_impl_t
{
@@ -78,7 +78,7 @@ typedef struct SDL_cond_cv
CONDITION_VARIABLE cond;
} SDL_cond_cv;
static SDL_cond *SDL_CreateCondition_cv(void)
static SDL_Condition *SDL_CreateCondition_cv(void)
{
SDL_cond_cv *cond;
@@ -88,10 +88,10 @@ static SDL_cond *SDL_CreateCondition_cv(void)
SDL_OutOfMemory();
}
return (SDL_cond *)cond;
return (SDL_Condition *)cond;
}
static void SDL_DestroyCondition_cv(SDL_cond *cond)
static void SDL_DestroyCondition_cv(SDL_Condition *cond)
{
if (cond != NULL) {
/* There are no kernel allocated resources */
@@ -99,7 +99,7 @@ static void SDL_DestroyCondition_cv(SDL_cond *cond)
}
}
static int SDL_SignalCondition_cv(SDL_cond *_cond)
static int SDL_SignalCondition_cv(SDL_Condition *_cond)
{
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (cond == NULL) {
@@ -111,7 +111,7 @@ static int SDL_SignalCondition_cv(SDL_cond *_cond)
return 0;
}
static int SDL_BroadcastCondition_cv(SDL_cond *_cond)
static int SDL_BroadcastCondition_cv(SDL_Condition *_cond)
{
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (cond == NULL) {
@@ -123,7 +123,7 @@ static int SDL_BroadcastCondition_cv(SDL_cond *_cond)
return 0;
}
static int SDL_WaitConditionTimeoutNS_cv(SDL_cond *_cond, SDL_mutex *_mutex, Sint64 timeoutNS)
static int SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mutex, Sint64 timeoutNS)
{
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
DWORD timeout;
@@ -196,7 +196,7 @@ static const SDL_cond_impl_t SDL_cond_impl_cv = {
#ifndef __WINRT__
/* Generic Condition Variable implementation using SDL_mutex and SDL_sem */
/* Generic Condition Variable implementation using SDL_Mutex and SDL_Semaphore */
static const SDL_cond_impl_t SDL_cond_impl_generic = {
&SDL_CreateCondition_generic,
&SDL_DestroyCondition_generic,
@@ -206,7 +206,7 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = {
};
#endif
SDL_cond *
SDL_Condition *
SDL_CreateCondition(void)
{
if (SDL_cond_impl_active.Create == NULL) {
@@ -214,7 +214,7 @@ SDL_CreateCondition(void)
if (SDL_mutex_impl_active.Type == SDL_MUTEX_INVALID) {
/* The mutex implementation isn't decided yet, trigger it */
SDL_mutex *mutex = SDL_CreateMutex();
SDL_Mutex *mutex = SDL_CreateMutex();
if (mutex == NULL) {
return NULL;
}
@@ -249,22 +249,22 @@ SDL_CreateCondition(void)
return SDL_cond_impl_active.Create();
}
void SDL_DestroyCondition(SDL_cond *cond)
void SDL_DestroyCondition(SDL_Condition *cond)
{
SDL_cond_impl_active.Destroy(cond);
}
int SDL_SignalCondition(SDL_cond *cond)
int SDL_SignalCondition(SDL_Condition *cond)
{
return SDL_cond_impl_active.Signal(cond);
}
int SDL_BroadcastCondition(SDL_cond *cond)
int SDL_BroadcastCondition(SDL_Condition *cond)
{
return SDL_cond_impl_active.Broadcast(cond);
}
int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS)
{
return SDL_cond_impl_active.WaitTimeoutNS(cond, mutex, timeoutNS);
}

View File

@@ -56,7 +56,7 @@ static pfnAcquireSRWLockExclusive pAcquireSRWLockExclusive = NULL;
static pfnTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive = NULL;
#endif
static SDL_mutex *SDL_CreateMutex_srw(void)
static SDL_Mutex *SDL_CreateMutex_srw(void)
{
SDL_mutex_srw *mutex;
@@ -67,16 +67,16 @@ static SDL_mutex *SDL_CreateMutex_srw(void)
pInitializeSRWLock(&mutex->srw);
return (SDL_mutex *)mutex;
return (SDL_Mutex *)mutex;
}
static void SDL_DestroyMutex_srw(SDL_mutex *mutex)
static void SDL_DestroyMutex_srw(SDL_Mutex *mutex)
{
/* There are no kernel allocated resources */
SDL_free(mutex);
}
static int SDL_LockMutex_srw(SDL_mutex *_mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
static int SDL_LockMutex_srw(SDL_Mutex *_mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex;
DWORD this_thread;
@@ -97,7 +97,7 @@ static int SDL_LockMutex_srw(SDL_mutex *_mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /*
return 0;
}
static int SDL_TryLockMutex_srw(SDL_mutex *_mutex)
static int SDL_TryLockMutex_srw(SDL_Mutex *_mutex)
{
SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex;
DWORD this_thread;
@@ -118,7 +118,7 @@ static int SDL_TryLockMutex_srw(SDL_mutex *_mutex)
return retval;
}
static int SDL_UnlockMutex_srw(SDL_mutex *_mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
static int SDL_UnlockMutex_srw(SDL_Mutex *_mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex;
@@ -148,7 +148,7 @@ static const SDL_mutex_impl_t SDL_mutex_impl_srw = {
*/
/* Create a mutex */
static SDL_mutex *SDL_CreateMutex_cs(void)
static SDL_Mutex *SDL_CreateMutex_cs(void)
{
SDL_mutex_cs *mutex;
@@ -165,11 +165,11 @@ static SDL_mutex *SDL_CreateMutex_cs(void)
} else {
SDL_OutOfMemory();
}
return (SDL_mutex *)mutex;
return (SDL_Mutex *)mutex;
}
/* Free the mutex */
static void SDL_DestroyMutex_cs(SDL_mutex *mutex_)
static void SDL_DestroyMutex_cs(SDL_Mutex *mutex_)
{
SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_;
@@ -178,7 +178,7 @@ static void SDL_DestroyMutex_cs(SDL_mutex *mutex_)
}
/* Lock the mutex */
static int SDL_LockMutex_cs(SDL_mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
static int SDL_LockMutex_cs(SDL_Mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_;
@@ -187,7 +187,7 @@ static int SDL_LockMutex_cs(SDL_mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS /*
}
/* TryLock the mutex */
static int SDL_TryLockMutex_cs(SDL_mutex *mutex_)
static int SDL_TryLockMutex_cs(SDL_Mutex *mutex_)
{
SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_;
int retval = 0;
@@ -199,7 +199,7 @@ static int SDL_TryLockMutex_cs(SDL_mutex *mutex_)
}
/* Unlock the mutex */
static int SDL_UnlockMutex_cs(SDL_mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
static int SDL_UnlockMutex_cs(SDL_Mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_;
@@ -220,7 +220,7 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = {
* Runtime selection and redirection
*/
SDL_mutex *
SDL_Mutex *
SDL_CreateMutex(void)
{
if (SDL_mutex_impl_active.Create == NULL) {
@@ -254,14 +254,14 @@ SDL_CreateMutex(void)
return SDL_mutex_impl_active.Create();
}
void SDL_DestroyMutex(SDL_mutex *mutex)
void SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex) {
SDL_mutex_impl_active.Destroy(mutex);
}
}
int SDL_LockMutex(SDL_mutex *mutex)
int SDL_LockMutex(SDL_Mutex *mutex)
{
if (mutex == NULL) {
return 0;
@@ -270,7 +270,7 @@ int SDL_LockMutex(SDL_mutex *mutex)
return SDL_mutex_impl_active.Lock(mutex);
}
int SDL_TryLockMutex(SDL_mutex *mutex)
int SDL_TryLockMutex(SDL_Mutex *mutex)
{
if (mutex == NULL) {
return 0;
@@ -279,7 +279,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
return SDL_mutex_impl_active.TryLock(mutex);
}
int SDL_UnlockMutex(SDL_mutex *mutex)
int SDL_UnlockMutex(SDL_Mutex *mutex)
{
if (mutex == NULL) {
return 0;

View File

@@ -22,11 +22,11 @@
#include "../../core/windows/SDL_windows.h"
typedef SDL_mutex *(*pfnSDL_CreateMutex)(void);
typedef int (*pfnSDL_LockMutex)(SDL_mutex *);
typedef int (*pfnSDL_TryLockMutex)(SDL_mutex *);
typedef int (*pfnSDL_UnlockMutex)(SDL_mutex *);
typedef void (*pfnSDL_DestroyMutex)(SDL_mutex *);
typedef SDL_Mutex *(*pfnSDL_CreateMutex)(void);
typedef int (*pfnSDL_LockMutex)(SDL_Mutex *);
typedef int (*pfnSDL_TryLockMutex)(SDL_Mutex *);
typedef int (*pfnSDL_UnlockMutex)(SDL_Mutex *);
typedef void (*pfnSDL_DestroyMutex)(SDL_Mutex *);
typedef enum
{
@@ -42,7 +42,7 @@ typedef struct SDL_mutex_impl_t
pfnSDL_LockMutex Lock;
pfnSDL_TryLockMutex TryLock;
pfnSDL_UnlockMutex Unlock;
/* Needed by SDL_cond: */
/* Needed by SDL_Condition: */
SDL_MutexType Type;
} SDL_mutex_impl_t;

View File

@@ -55,13 +55,13 @@ static pfnAcquireSRWLockExclusive pAcquireSRWLockExclusive = NULL;
static pfnTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive = NULL;
#endif
typedef SDL_rwlock *(*pfnSDL_CreateRWLock)(void);
typedef void (*pfnSDL_DestroyRWLock)(SDL_rwlock *);
typedef int (*pfnSDL_LockRWLockForReading)(SDL_rwlock *);
typedef int (*pfnSDL_LockRWLockForWriting)(SDL_rwlock *);
typedef int (*pfnSDL_TryLockRWLockForReading)(SDL_rwlock *);
typedef int (*pfnSDL_TryLockRWLockForWriting)(SDL_rwlock *);
typedef int (*pfnSDL_UnlockRWLock)(SDL_rwlock *);
typedef SDL_RWLock *(*pfnSDL_CreateRWLock)(void);
typedef void (*pfnSDL_DestroyRWLock)(SDL_RWLock *);
typedef int (*pfnSDL_LockRWLockForReading)(SDL_RWLock *);
typedef int (*pfnSDL_LockRWLockForWriting)(SDL_RWLock *);
typedef int (*pfnSDL_TryLockRWLockForReading)(SDL_RWLock *);
typedef int (*pfnSDL_TryLockRWLockForWriting)(SDL_RWLock *);
typedef int (*pfnSDL_UnlockRWLock)(SDL_RWLock *);
typedef struct SDL_rwlock_impl_t
{
@@ -85,17 +85,17 @@ typedef struct SDL_rwlock_srw
SDL_threadID write_owner;
} SDL_rwlock_srw;
static SDL_rwlock *SDL_CreateRWLock_srw(void)
static SDL_RWLock *SDL_CreateRWLock_srw(void)
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *)SDL_calloc(1, sizeof(*rwlock));
if (rwlock == NULL) {
SDL_OutOfMemory();
}
pInitializeSRWLock(&rwlock->srw);
return (SDL_rwlock *)rwlock;
return (SDL_RWLock *)rwlock;
}
static void SDL_DestroyRWLock_srw(SDL_rwlock *_rwlock)
static void SDL_DestroyRWLock_srw(SDL_RWLock *_rwlock)
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock;
if (rwlock) {
@@ -104,7 +104,7 @@ static void SDL_DestroyRWLock_srw(SDL_rwlock *_rwlock)
}
}
static int SDL_LockRWLockForReading_srw(SDL_rwlock *_rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
static int SDL_LockRWLockForReading_srw(SDL_RWLock *_rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock;
if (rwlock == NULL) {
@@ -114,7 +114,7 @@ static int SDL_LockRWLockForReading_srw(SDL_rwlock *_rwlock) SDL_NO_THREAD_SAFET
return 0;
}
static int SDL_LockRWLockForWriting_srw(SDL_rwlock *_rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
static int SDL_LockRWLockForWriting_srw(SDL_RWLock *_rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock;
if (rwlock == NULL) {
@@ -125,7 +125,7 @@ static int SDL_LockRWLockForWriting_srw(SDL_rwlock *_rwlock) SDL_NO_THREAD_SAFET
return 0;
}
static int SDL_TryLockRWLockForReading_srw(SDL_rwlock *_rwlock)
static int SDL_TryLockRWLockForReading_srw(SDL_RWLock *_rwlock)
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock;
int retval = 0;
@@ -138,7 +138,7 @@ static int SDL_TryLockRWLockForReading_srw(SDL_rwlock *_rwlock)
return retval;
}
static int SDL_TryLockRWLockForWriting_srw(SDL_rwlock *_rwlock)
static int SDL_TryLockRWLockForWriting_srw(SDL_RWLock *_rwlock)
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock;
int retval = 0;
@@ -151,7 +151,7 @@ static int SDL_TryLockRWLockForWriting_srw(SDL_rwlock *_rwlock)
return retval;
}
static int SDL_UnlockRWLock_srw(SDL_rwlock *_rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
static int SDL_UnlockRWLock_srw(SDL_RWLock *_rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock;
if (rwlock == NULL) {
@@ -179,7 +179,7 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_srw = {
#include "../generic/SDL_sysrwlock_c.h"
/* Generic rwlock implementation using SDL_mutex, SDL_cond, and SDL_AtomicInt */
/* Generic rwlock implementation using SDL_Mutex, SDL_Condition, and SDL_AtomicInt */
static const SDL_rwlock_impl_t SDL_rwlock_impl_generic = {
&SDL_CreateRWLock_generic,
&SDL_DestroyRWLock_generic,
@@ -191,7 +191,7 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_generic = {
};
#endif
SDL_rwlock *SDL_CreateRWLock(void)
SDL_RWLock *SDL_CreateRWLock(void)
{
if (SDL_rwlock_impl_active.Create == NULL) {
const SDL_rwlock_impl_t *impl;
@@ -227,32 +227,32 @@ SDL_rwlock *SDL_CreateRWLock(void)
return SDL_rwlock_impl_active.Create();
}
void SDL_DestroyRWLock(SDL_rwlock *rwlock)
void SDL_DestroyRWLock(SDL_RWLock *rwlock)
{
SDL_rwlock_impl_active.Destroy(rwlock);
}
int SDL_LockRWLockForReading(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_LockRWLockForReading(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
return SDL_rwlock_impl_active.LockForReading(rwlock);
}
int SDL_LockRWLockForWriting(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
return SDL_rwlock_impl_active.LockForWriting(rwlock);
}
int SDL_TryLockRWLockForReading(SDL_rwlock *rwlock)
int SDL_TryLockRWLockForReading(SDL_RWLock *rwlock)
{
return SDL_rwlock_impl_active.TryLockForReading(rwlock);
}
int SDL_TryLockRWLockForWriting(SDL_rwlock *rwlock)
int SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock)
{
return SDL_rwlock_impl_active.TryLockForWriting(rwlock);
}
int SDL_UnlockRWLock(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
int SDL_UnlockRWLock(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
{
return SDL_rwlock_impl_active.Unlock(rwlock);
}

View File

@@ -35,11 +35,11 @@
#include "../../core/windows/SDL_windows.h"
typedef SDL_sem *(*pfnSDL_CreateSemaphore)(Uint32);
typedef void (*pfnSDL_DestroySemaphore)(SDL_sem *);
typedef int (*pfnSDL_WaitSemaphoreTimeoutNS)(SDL_sem *, Sint64);
typedef Uint32 (*pfnSDL_GetSemaphoreValue)(SDL_sem *);
typedef int (*pfnSDL_PostSemaphore)(SDL_sem *);
typedef SDL_Semaphore *(*pfnSDL_CreateSemaphore)(Uint32);
typedef void (*pfnSDL_DestroySemaphore)(SDL_Semaphore *);
typedef int (*pfnSDL_WaitSemaphoreTimeoutNS)(SDL_Semaphore *, Sint64);
typedef Uint32 (*pfnSDL_GetSemaphoreValue)(SDL_Semaphore *);
typedef int (*pfnSDL_PostSemaphore)(SDL_Semaphore *);
typedef struct SDL_semaphore_impl_t
{
@@ -78,7 +78,7 @@ typedef struct SDL_semaphore_atom
LONG count;
} SDL_sem_atom;
static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value)
static SDL_Semaphore *SDL_CreateSemaphore_atom(Uint32 initial_value)
{
SDL_sem_atom *sem;
@@ -88,17 +88,17 @@ static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value)
} else {
SDL_OutOfMemory();
}
return (SDL_sem *)sem;
return (SDL_Semaphore *)sem;
}
static void SDL_DestroySemaphore_atom(SDL_sem *sem)
static void SDL_DestroySemaphore_atom(SDL_Semaphore *sem)
{
if (sem != NULL) {
SDL_free(sem);
}
}
static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_sem *_sem, Sint64 timeoutNS)
static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_Semaphore *_sem, Sint64 timeoutNS)
{
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
LONG count;
@@ -172,7 +172,7 @@ static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_sem *_sem, Sint64 timeoutNS)
}
}
static Uint32 SDL_GetSemaphoreValue_atom(SDL_sem *_sem)
static Uint32 SDL_GetSemaphoreValue_atom(SDL_Semaphore *_sem)
{
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
@@ -184,7 +184,7 @@ static Uint32 SDL_GetSemaphoreValue_atom(SDL_sem *_sem)
return (Uint32)sem->count;
}
static int SDL_PostSemaphore_atom(SDL_sem *_sem)
static int SDL_PostSemaphore_atom(SDL_Semaphore *_sem)
{
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
@@ -218,7 +218,7 @@ typedef struct SDL_semaphore_kern
} SDL_sem_kern;
/* Create a semaphore */
static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value)
static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value)
{
SDL_sem_kern *sem;
@@ -240,11 +240,11 @@ static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value)
} else {
SDL_OutOfMemory();
}
return (SDL_sem *)sem;
return (SDL_Semaphore *)sem;
}
/* Free the semaphore */
static void SDL_DestroySemaphore_kern(SDL_sem *_sem)
static void SDL_DestroySemaphore_kern(SDL_Semaphore *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem != NULL) {
@@ -256,7 +256,7 @@ static void SDL_DestroySemaphore_kern(SDL_sem *_sem)
}
}
static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_sem *_sem, Sint64 timeoutNS)
static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_Semaphore *_sem, Sint64 timeoutNS)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
int retval;
@@ -287,7 +287,7 @@ static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_sem *_sem, Sint64 timeoutNS)
}
/* Returns the current count of the semaphore */
static Uint32 SDL_GetSemaphoreValue_kern(SDL_sem *_sem)
static Uint32 SDL_GetSemaphoreValue_kern(SDL_Semaphore *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem == NULL) {
@@ -297,7 +297,7 @@ static Uint32 SDL_GetSemaphoreValue_kern(SDL_sem *_sem)
return (Uint32)sem->count;
}
static int SDL_PostSemaphore_kern(SDL_sem *_sem)
static int SDL_PostSemaphore_kern(SDL_Semaphore *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem == NULL) {
@@ -328,7 +328,7 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = {
* Runtime selection and redirection
*/
SDL_sem *
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
{
if (SDL_sem_impl_active.Create == NULL) {
@@ -367,23 +367,23 @@ SDL_CreateSemaphore(Uint32 initial_value)
return SDL_sem_impl_active.Create(initial_value);
}
void SDL_DestroySemaphore(SDL_sem *sem)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
SDL_sem_impl_active.Destroy(sem);
}
int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
return SDL_sem_impl_active.WaitTimeoutNS(sem, timeoutNS);
}
Uint32
SDL_GetSemaphoreValue(SDL_sem *sem)
SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
return SDL_sem_impl_active.Value(sem);
}
int SDL_PostSemaphore(SDL_sem *sem)
int SDL_PostSemaphore(SDL_Semaphore *sem)
{
return SDL_sem_impl_active.Post(sem);
}