Updated source to match SDL function prototype style

This commit is contained in:
Sam Lantinga
2023-05-23 10:59:03 -07:00
parent 92f72682e7
commit 3f1fd5abff
243 changed files with 1218 additions and 2364 deletions

View File

@@ -28,15 +28,13 @@
#include "SDL_hints.h"
#include "../SDL_error_c.h"
SDL_TLSID
SDL_TLSCreate()
SDL_TLSID SDL_TLSCreate()
{
static SDL_atomic_t SDL_tls_id;
return SDL_AtomicIncRef(&SDL_tls_id) + 1;
}
void *
SDL_TLSGet(SDL_TLSID id)
void *SDL_TLSGet(SDL_TLSID id)
{
SDL_TLSData *storage;
@@ -115,8 +113,7 @@ typedef struct SDL_TLSEntry
static SDL_mutex *SDL_generic_TLS_mutex;
static SDL_TLSEntry *SDL_generic_TLS;
SDL_TLSData *
SDL_Generic_GetTLSData(void)
SDL_TLSData *SDL_Generic_GetTLSData(void)
{
SDL_threadID thread = SDL_ThreadID();
SDL_TLSEntry *entry;
@@ -218,8 +215,7 @@ static void SDLCALL SDL_FreeErrBuf(void *data)
#endif
/* Routine to get the thread-specific error variable */
SDL_error *
SDL_GetErrBuf(void)
SDL_error *SDL_GetErrBuf(void)
{
#if SDL_THREADS_DISABLED
return SDL_GetStaticErrBuf();
@@ -320,14 +316,12 @@ void SDL_RunThread(SDL_Thread *thread)
#endif
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
SDL_Thread *
SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *),
SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *),
const char *name, const size_t stacksize, void *data,
pfnSDL_CurrentBeginThread pfnBeginThread,
pfnSDL_CurrentEndThread pfnEndThread)
#else
SDL_Thread *
SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *),
SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *),
const char *name, const size_t stacksize, void *data)
#endif
{
@@ -375,14 +369,12 @@ SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *),
}
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThread(int(SDLCALL *fn)(void *),
DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int(SDLCALL *fn)(void *),
const char *name, void *data,
pfnSDL_CurrentBeginThread pfnBeginThread,
pfnSDL_CurrentEndThread pfnEndThread)
#else
DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThread(int(SDLCALL *fn)(void *),
DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int(SDLCALL *fn)(void *),
const char *name, void *data)
#endif
{
@@ -408,8 +400,7 @@ SDL_CreateThread(int(SDLCALL *fn)(void *),
#endif
}
SDL_Thread *
SDL_CreateThreadInternal(int(SDLCALL *fn)(void *), const char *name,
SDL_Thread *SDL_CreateThreadInternal(int(SDLCALL *fn)(void *), const char *name,
const size_t stacksize, void *data)
{
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
@@ -419,8 +410,7 @@ SDL_CreateThreadInternal(int(SDLCALL *fn)(void *), const char *name,
#endif
}
SDL_threadID
SDL_GetThreadID(SDL_Thread *thread)
SDL_threadID SDL_GetThreadID(SDL_Thread *thread)
{
SDL_threadID id;
@@ -432,8 +422,7 @@ SDL_GetThreadID(SDL_Thread *thread)
return id;
}
const char *
SDL_GetThreadName(SDL_Thread *thread)
const char *SDL_GetThreadName(SDL_Thread *thread)
{
if (thread) {
return thread->name;

View File

@@ -53,8 +53,7 @@ typedef struct SDL_cond_generic
} SDL_cond_generic;
/* Create a condition variable */
SDL_cond *
SDL_CreateCond_generic(void)
SDL_cond *SDL_CreateCond_generic(void)
{
SDL_cond_generic *cond;

View File

@@ -33,8 +33,7 @@ struct SDL_mutex
};
/* Create a mutex */
SDL_mutex *
SDL_CreateMutex(void)
SDL_mutex *SDL_CreateMutex(void)
{
SDL_mutex *mutex;

View File

@@ -28,8 +28,7 @@
#if SDL_THREADS_DISABLED
SDL_sem *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_SetError("SDL not built with thread support");
return (SDL_sem *)0;
@@ -54,8 +53,7 @@ int SDL_SemWait(SDL_sem *sem)
return SDL_SetError("SDL not built with thread support");
}
Uint32
SDL_SemValue(SDL_sem *sem)
Uint32 SDL_SemValue(SDL_sem *sem)
{
return 0;
}
@@ -75,8 +73,7 @@ struct SDL_semaphore
SDL_cond *count_nonzero;
};
SDL_sem *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem;
@@ -172,8 +169,7 @@ int SDL_SemWait(SDL_sem *sem)
return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
}
Uint32
SDL_SemValue(SDL_sem *sem)
Uint32 SDL_SemValue(SDL_sem *sem)
{
Uint32 value;

View File

@@ -41,8 +41,7 @@ void SDL_SYS_SetupThread(const char *name)
return;
}
SDL_threadID
SDL_ThreadID(void)
SDL_threadID SDL_ThreadID(void)
{
return 0;
}

View File

@@ -22,8 +22,7 @@
#include "../../SDL_internal.h"
#include "../SDL_thread_c.h"
SDL_TLSData *
SDL_SYS_GetTLSData(void)
SDL_TLSData *SDL_SYS_GetTLSData(void)
{
return SDL_Generic_GetTLSData();
}

View File

@@ -32,8 +32,7 @@ struct SDL_cond
};
/* Create a condition variable */
SDL_cond *
SDL_CreateCond(void)
SDL_cond *SDL_CreateCond(void)
{
SDL_cond *cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond));
if (cond) {

View File

@@ -27,8 +27,7 @@
#include "SDL_sysmutex_c.h"
/* Create a mutex */
SDL_mutex *
SDL_CreateMutex(void)
SDL_mutex *SDL_CreateMutex(void)
{
SDL_mutex *mutex;

View File

@@ -67,8 +67,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread)
return 0;
}
static size_t
GetStackSize(size_t requested_size)
static size_t GetStackSize(size_t requested_size)
{
if (requested_size == 0) {
return N3DS_THREAD_STACK_SIZE_DEFAULT;
@@ -90,8 +89,7 @@ void SDL_SYS_SetupThread(const char *name)
return;
}
SDL_threadID
SDL_ThreadID(void)
SDL_threadID SDL_ThreadID(void)
{
u32 thread_ID = 0;
svcGetThreadId(&thread_ID, CUR_THREAD_HANDLE);

View File

@@ -40,8 +40,7 @@ static TInt NewMutex(const TDesC &aName, TAny *aPtr1, TAny *)
}
/* Create a mutex */
SDL_mutex *
SDL_CreateMutex(void)
SDL_mutex *SDL_CreateMutex(void)
{
RMutex rmutex;
@@ -84,8 +83,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)
int SDL_TryLockMutex(SDL_mutex *mutex)
{
if (mutex == NULL)
{

View File

@@ -77,8 +77,7 @@ static void WaitAll(SDL_sem *sem)
}
}
SDL_sem *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{
RSemaphore s;
TInt status = CreateUnique(NewSema, &s, &initial_value);
@@ -150,8 +149,7 @@ int SDL_SemWait(SDL_sem *sem)
return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
}
Uint32
SDL_SemValue(SDL_sem *sem)
Uint32 SDL_SemValue(SDL_sem *sem)
{
if (sem == NULL) {
SDL_InvalidParamError("sem");

View File

@@ -80,8 +80,7 @@ void SDL_SYS_SetupThread(const char *name)
return;
}
SDL_threadID
SDL_ThreadID(void)
SDL_threadID SDL_ThreadID(void)
{
RThread current;
TThreadId id = current.Id();

View File

@@ -37,8 +37,7 @@ struct SDL_mutex {
};
/* Create a mutex */
SDL_mutex *
SDL_CreateMutex(void)
SDL_mutex *SDL_CreateMutex(void)
{
ULONG ulRC;
HMTX hMtx;
@@ -53,8 +52,7 @@ SDL_CreateMutex(void)
}
/* Free the mutex */
void
SDL_DestroyMutex(SDL_mutex * mutex)
void SDL_DestroyMutex(SDL_mutex * mutex)
{
HMTX hMtx = (HMTX)mutex;
if (hMtx != NULLHANDLE) {
@@ -66,8 +64,7 @@ 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 */
{
ULONG ulRC;
HMTX hMtx = (HMTX)mutex;
@@ -85,8 +82,7 @@ SDL_LockMutex(SDL_mutex * mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't
}
/* try Lock the mutex */
int
SDL_TryLockMutex(SDL_mutex * mutex)
int SDL_TryLockMutex(SDL_mutex * mutex)
{
ULONG ulRC;
HMTX hMtx = (HMTX)mutex;
@@ -108,8 +104,7 @@ 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 */
{
ULONG ulRC;
HMTX hMtx = (HMTX)mutex;

View File

@@ -39,8 +39,7 @@ struct SDL_semaphore {
};
SDL_sem *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{
ULONG ulRC;
SDL_sem *pSDLSem = SDL_malloc(sizeof(SDL_sem));
@@ -70,8 +69,7 @@ SDL_CreateSemaphore(Uint32 initial_value)
return pSDLSem;
}
void
SDL_DestroySemaphore(SDL_sem * sem)
void SDL_DestroySemaphore(SDL_sem * sem)
{
if (!sem) return;
@@ -80,8 +78,7 @@ SDL_DestroySemaphore(SDL_sem * sem)
SDL_free(sem);
}
int
SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
int SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
{
ULONG ulRC;
ULONG ulStartTime, ulCurTime;
@@ -129,20 +126,17 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
return 0;
}
int
SDL_SemTryWait(SDL_sem * sem)
int SDL_SemTryWait(SDL_sem * sem)
{
return SDL_SemWaitTimeout(sem, 0);
}
int
SDL_SemWait(SDL_sem * sem)
int SDL_SemWait(SDL_sem * sem)
{
return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
}
Uint32
SDL_SemValue(SDL_sem * sem)
Uint32 SDL_SemValue(SDL_sem * sem)
{
ULONG ulRC;
@@ -161,8 +155,7 @@ SDL_SemValue(SDL_sem * sem)
return ulRC;
}
int
SDL_SemPost(SDL_sem * sem)
int SDL_SemPost(SDL_sem * sem)
{
ULONG ulRC;

View File

@@ -54,8 +54,7 @@ static void RunThread(void *data)
pfnEndThread();
}
int
SDL_SYS_CreateThread(SDL_Thread * thread,
int SDL_SYS_CreateThread(SDL_Thread * thread,
pfnSDL_CurrentBeginThread pfnBeginThread,
pfnSDL_CurrentEndThread pfnEndThread)
{
@@ -80,14 +79,12 @@ SDL_SYS_CreateThread(SDL_Thread * thread,
return 0;
}
void
SDL_SYS_SetupThread(const char *name)
void SDL_SYS_SetupThread(const char *name)
{
/* nothing. */
}
SDL_threadID
SDL_ThreadID(void)
SDL_threadID SDL_ThreadID(void)
{
PTIB tib;
PPIB pib;
@@ -96,8 +93,7 @@ SDL_ThreadID(void)
return tib->tib_ptib2->tib2_ultid;
}
int
SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
{
ULONG ulRC;
@@ -112,8 +108,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
return 0;
}
void
SDL_SYS_WaitThread(SDL_Thread * thread)
void SDL_SYS_WaitThread(SDL_Thread * thread)
{
ULONG ulRC = DosWaitThread((PTID)&thread->handle, DCWW_WAIT);
@@ -122,8 +117,7 @@ SDL_SYS_WaitThread(SDL_Thread * thread)
}
}
void
SDL_SYS_DetachThread(SDL_Thread * thread)
void SDL_SYS_DetachThread(SDL_Thread * thread)
{
/* nothing. */
}

View File

@@ -40,8 +40,7 @@ struct SDL_cond
};
/* Create a condition variable */
SDL_cond *
SDL_CreateCond(void)
SDL_cond *SDL_CreateCond(void)
{
SDL_cond *cond;

View File

@@ -38,8 +38,7 @@ struct SDL_mutex
};
/* Create a mutex */
SDL_mutex *
SDL_CreateMutex(void)
SDL_mutex *SDL_CreateMutex(void)
{
SDL_mutex *mutex = NULL;
SceInt32 res = 0;

View File

@@ -35,8 +35,7 @@ struct SDL_cond
};
/* Create a condition variable */
SDL_cond *
SDL_CreateCond(void)
SDL_cond *SDL_CreateCond(void)
{
SDL_cond *cond;

View File

@@ -39,8 +39,7 @@ struct SDL_mutex
#endif
};
SDL_mutex *
SDL_CreateMutex(void)
SDL_mutex *SDL_CreateMutex(void)
{
SDL_mutex *mutex;
pthread_mutexattr_t attr;

View File

@@ -42,8 +42,7 @@ struct SDL_semaphore
};
/* Create a semaphore, initialized with value */
SDL_sem *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem = (SDL_sem *)SDL_malloc(sizeof(SDL_sem));
if (sem != NULL) {
@@ -172,8 +171,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
return retval;
}
Uint32
SDL_SemValue(SDL_sem *sem)
Uint32 SDL_SemValue(SDL_sem *sem)
{
int ret = 0;

View File

@@ -181,8 +181,7 @@ void SDL_SYS_SetupThread(const char *name)
#endif
}
SDL_threadID
SDL_ThreadID(void)
SDL_threadID SDL_ThreadID(void)
{
return (SDL_threadID)pthread_self();
}

View File

@@ -30,8 +30,7 @@
static pthread_key_t thread_local_storage = INVALID_PTHREAD_KEY;
static SDL_bool generic_local_storage = SDL_FALSE;
SDL_TLSData *
SDL_SYS_GetTLSData(void)
SDL_TLSData *SDL_SYS_GetTLSData(void)
{
if (thread_local_storage == INVALID_PTHREAD_KEY && !generic_local_storage) {
static SDL_SpinLock lock;

View File

@@ -40,8 +40,7 @@ struct SDL_cond
};
/* Create a condition variable */
SDL_cond *
SDL_CreateCond(void)
SDL_cond *SDL_CreateCond(void)
{
SDL_cond *cond;

View File

@@ -34,8 +34,7 @@ struct SDL_mutex
};
/* Create a mutex */
SDL_mutex *
SDL_CreateMutex(void)
SDL_mutex *SDL_CreateMutex(void)
{
SDL_mutex *mutex = NULL;
SceInt32 res = 0;

View File

@@ -218,8 +218,7 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = {
&SDL_CondWaitTimeout_generic,
};
SDL_cond *
SDL_CreateCond(void)
SDL_cond *SDL_CreateCond(void)
{
if (SDL_cond_impl_active.Create == NULL) {
/* Default to generic implementation, works with all mutex implementations */

View File

@@ -243,8 +243,7 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = {
* Runtime selection and redirection
*/
SDL_mutex *
SDL_CreateMutex(void)
SDL_mutex *SDL_CreateMutex(void)
{
if (SDL_mutex_impl_active.Create == NULL) {
/* Default to fallback implementation */

View File

@@ -377,8 +377,7 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = {
* Runtime selection and redirection
*/
SDL_sem *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{
if (SDL_sem_impl_active.Create == NULL) {
/* Default to fallback implementation */
@@ -436,8 +435,7 @@ int SDL_SemWait(SDL_sem *sem)
return SDL_sem_impl_active.Wait(sem);
}
Uint32
SDL_SemValue(SDL_sem *sem)
Uint32 SDL_SemValue(SDL_sem *sem)
{
return SDL_sem_impl_active.Value(sem);
}

View File

@@ -164,8 +164,7 @@ void SDL_SYS_SetupThread(const char *name)
}
}
SDL_threadID
SDL_ThreadID(void)
SDL_threadID SDL_ThreadID(void)
{
return (SDL_threadID)GetCurrentThreadId();
}

View File

@@ -43,8 +43,7 @@
static DWORD thread_local_storage = TLS_OUT_OF_INDEXES;
static SDL_bool generic_local_storage = SDL_FALSE;
SDL_TLSData *
SDL_SYS_GetTLSData(void)
SDL_TLSData *SDL_SYS_GetTLSData(void)
{
if (thread_local_storage == TLS_OUT_OF_INDEXES && !generic_local_storage) {
static SDL_SpinLock lock;