Updated source to match SDL function prototype style

This commit is contained in:
Sam Lantinga
2023-05-23 11:29:41 -07:00
parent 737aa881fa
commit ddbdd73258
173 changed files with 481 additions and 942 deletions

View File

@@ -26,8 +26,7 @@
#include "SDL_systhread.h"
#include "../SDL_error_c.h"
SDL_TLSID
SDL_TLSCreate(void)
SDL_TLSID SDL_TLSCreate(void)
{
static SDL_AtomicInt SDL_tls_id;
return SDL_AtomicIncRef(&SDL_tls_id) + 1;
@@ -112,8 +111,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;
@@ -215,8 +213,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)
{
#ifdef SDL_THREADS_DISABLED
return SDL_GetStaticErrBuf();
@@ -317,14 +314,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
{
@@ -372,14 +367,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
{
@@ -405,8 +398,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
@@ -416,8 +408,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;
@@ -429,8 +420,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

@@ -50,8 +50,7 @@ typedef struct SDL_cond_generic
} SDL_cond_generic;
/* Create a condition variable */
SDL_Condition *
SDL_CreateCondition_generic(void)
SDL_Condition *SDL_CreateCondition_generic(void)
{
SDL_cond_generic *cond;

View File

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

View File

@@ -26,8 +26,7 @@
#ifdef SDL_THREADS_DISABLED
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_SetError("SDL not built with thread support");
return (SDL_Semaphore *)0;
@@ -62,8 +61,7 @@ struct SDL_Semaphore
SDL_Condition *count_nonzero;
};
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_Semaphore *sem;

View File

@@ -40,8 +40,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_Condition
};
/* Create a condition variable */
SDL_Condition *
SDL_CreateCondition(void)
SDL_Condition *SDL_CreateCondition(void)
{
SDL_Condition *cond = (SDL_Condition *)SDL_malloc(sizeof(SDL_Condition));
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

@@ -39,8 +39,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;
@@ -83,8 +82,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

@@ -75,8 +75,7 @@ static void WaitAll(SDL_Semaphore *sem)
}
}
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
RSemaphore s;
TInt status = CreateUnique(NewSema, &s, &initial_value);

View File

@@ -78,8 +78,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

@@ -38,8 +38,7 @@ struct SDL_Condition
};
/* Create a condition variable */
SDL_Condition *
SDL_CreateCondition(void)
SDL_Condition *SDL_CreateCondition(void)
{
SDL_Condition *cond;

View File

@@ -37,8 +37,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

@@ -34,8 +34,7 @@ struct SDL_Condition
};
/* Create a condition variable */
SDL_Condition *
SDL_CreateCondition(void)
SDL_Condition *SDL_CreateCondition(void)
{
SDL_Condition *cond;

View File

@@ -25,8 +25,7 @@
#include "SDL_sysmutex_c.h"
SDL_Mutex *
SDL_CreateMutex(void)
SDL_Mutex *SDL_CreateMutex(void)
{
SDL_Mutex *mutex;
pthread_mutexattr_t attr;

View File

@@ -29,8 +29,7 @@ struct SDL_RWLock
};
SDL_RWLock *
SDL_CreateRWLock(void)
SDL_RWLock *SDL_CreateRWLock(void)
{
SDL_RWLock *rwlock;

View File

@@ -39,8 +39,7 @@ struct SDL_Semaphore
};
/* Create a semaphore, initialized with value */
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_Semaphore *sem = (SDL_Semaphore *)SDL_malloc(sizeof(SDL_Semaphore));
if (sem != NULL) {

View File

@@ -168,8 +168,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

@@ -29,8 +29,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

@@ -38,8 +38,7 @@ struct SDL_Condition
};
/* Create a condition variable */
SDL_Condition *
SDL_CreateCondition(void)
SDL_Condition *SDL_CreateCondition(void)
{
SDL_Condition *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 = NULL;
SceInt32 res = 0;

View File

@@ -206,8 +206,7 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = {
};
#endif
SDL_Condition *
SDL_CreateCondition(void)
SDL_Condition *SDL_CreateCondition(void)
{
if (SDL_cond_impl_active.Create == NULL) {
const SDL_cond_impl_t *impl = NULL;

View File

@@ -220,8 +220,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

@@ -328,8 +328,7 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = {
* Runtime selection and redirection
*/
SDL_Semaphore *
SDL_CreateSemaphore(Uint32 initial_value)
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
if (SDL_sem_impl_active.Create == NULL) {
/* Default to fallback implementation */

View File

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

View File

@@ -42,8 +42,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;