Use C99 bool internally in SDL

This commit is contained in:
Sam Lantinga
2024-08-22 09:21:26 -07:00
parent 6501e90018
commit 8f546bb3c9
450 changed files with 6046 additions and 6033 deletions

View File

@@ -272,7 +272,7 @@ static void SDLCALL SDL_FreeErrBuf(void *data)
#endif
// Routine to get the thread-specific error variable
SDL_error *SDL_GetErrBuf(SDL_bool create)
SDL_error *SDL_GetErrBuf(bool create)
{
#ifdef SDL_THREADS_DISABLED
return SDL_GetStaticErrBuf();

View File

@@ -71,10 +71,10 @@ static void *RunThread(void *data)
}
#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN)
static SDL_bool checked_setname = SDL_FALSE;
static bool checked_setname = false;
static int (*ppthread_setname_np)(const char *) = NULL;
#elif defined(SDL_PLATFORM_LINUX) && defined(HAVE_DLOPEN)
static SDL_bool checked_setname = SDL_FALSE;
static bool checked_setname = false;
static int (*ppthread_setname_np)(pthread_t, const char *) = NULL;
#endif
int SDL_SYS_CreateThread(SDL_Thread *thread,
@@ -92,7 +92,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread,
#elif defined(SDL_PLATFORM_LINUX)
ppthread_setname_np = (int (*)(pthread_t, const char *))fn;
#endif
checked_setname = SDL_TRUE;
checked_setname = true;
}
#endif
@@ -186,7 +186,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
int pri_policy;
pthread_t thread = pthread_self();
const char *policyhint = SDL_GetHint(SDL_HINT_THREAD_PRIORITY_POLICY);
const SDL_bool timecritical_realtime_hint = SDL_GetHintBoolean(SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL, SDL_FALSE);
const bool timecritical_realtime_hint = SDL_GetHintBoolean(SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL, false);
if (pthread_getschedparam(thread, &policy, &sched) != 0) {
return SDL_SetError("pthread_getschedparam() failed");

View File

@@ -27,7 +27,7 @@
#define INVALID_PTHREAD_KEY ((pthread_key_t)-1)
static pthread_key_t thread_local_storage = INVALID_PTHREAD_KEY;
static SDL_bool generic_local_storage = SDL_FALSE;
static bool generic_local_storage = false;
void SDL_SYS_InitTLSData(void)
{
@@ -35,7 +35,7 @@ void SDL_SYS_InitTLSData(void)
if (pthread_key_create(&thread_local_storage, NULL) != 0) {
thread_local_storage = INVALID_PTHREAD_KEY;
SDL_Generic_InitTLSData();
generic_local_storage = SDL_TRUE;
generic_local_storage = true;
}
}
}
@@ -68,7 +68,7 @@ void SDL_SYS_QuitTLSData(void)
{
if (generic_local_storage) {
SDL_Generic_QuitTLSData();
generic_local_storage = SDL_FALSE;
generic_local_storage = false;
} else {
if (thread_local_storage != INVALID_PTHREAD_KEY) {
pthread_key_delete(thread_local_storage);

View File

@@ -193,8 +193,8 @@ SDL_RWLock *SDL_CreateRWLock(void)
{
HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
if (kernel32) {
SDL_bool okay = SDL_TRUE;
#define LOOKUP_SRW_SYM(sym) if (okay) { if ((p##sym = (pfn##sym)GetProcAddress(kernel32, #sym)) == NULL) { okay = SDL_FALSE; } }
bool okay = true;
#define LOOKUP_SRW_SYM(sym) if (okay) { if ((p##sym = (pfn##sym)GetProcAddress(kernel32, #sym)) == NULL) { okay = false; } }
LOOKUP_SRW_SYM(InitializeSRWLock);
LOOKUP_SRW_SYM(ReleaseSRWLockShared);
LOOKUP_SRW_SYM(AcquireSRWLockShared);

View File

@@ -330,7 +330,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
const SDL_sem_impl_t *impl = &SDL_sem_impl_kern;
#if !SDL_WINAPI_FAMILY_PHONE
if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, SDL_FALSE)) {
if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, false)) {
#ifdef SDL_PLATFORM_WINRT
// Link statically on this platform
impl = &SDL_sem_impl_atom;

View File

@@ -40,7 +40,7 @@
#endif
static DWORD thread_local_storage = TLS_OUT_OF_INDEXES;
static SDL_bool generic_local_storage = SDL_FALSE;
static bool generic_local_storage = false;
void SDL_SYS_InitTLSData(void)
{
@@ -48,7 +48,7 @@ void SDL_SYS_InitTLSData(void)
thread_local_storage = TlsAlloc();
if (thread_local_storage == TLS_OUT_OF_INDEXES) {
SDL_Generic_InitTLSData();
generic_local_storage = SDL_TRUE;
generic_local_storage = true;
}
}
}
@@ -81,7 +81,7 @@ void SDL_SYS_QuitTLSData(void)
{
if (generic_local_storage) {
SDL_Generic_QuitTLSData();
generic_local_storage = SDL_FALSE;
generic_local_storage = false;
} else {
if (thread_local_storage != TLS_OUT_OF_INDEXES) {
TlsFree(thread_local_storage);