mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-09 21:28:28 +00:00
Rename SDL mutex, semaphore and condition variable types to match SDL 3.0 naming convention
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#define FAKE_RECURSIVE_MUTEX
|
||||
#endif
|
||||
|
||||
struct SDL_mutex
|
||||
struct SDL_Mutex
|
||||
{
|
||||
pthread_mutex_t id;
|
||||
#ifdef FAKE_RECURSIVE_MUTEX
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user