Fix -Wundef warnings due to use of unguarded SDL_THREADS_DISABLED

This commit is contained in:
Anonymous Maarten
2023-03-27 15:07:49 +02:00
parent 93b357a0d2
commit 0c161c1435
10 changed files with 23 additions and 23 deletions

View File

@@ -22,7 +22,7 @@
#ifdef __LINUX__
#if !SDL_THREADS_DISABLED
#ifndef SDL_THREADS_DISABLED
#include <sys/time.h>
#include <sys/resource.h>
#include <pthread.h>
@@ -251,7 +251,7 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
/* this is a public symbol, so it has to exist even if threads are disabled. */
int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority)
{
#if SDL_THREADS_DISABLED
#ifdef SDL_THREADS_DISABLED
return SDL_Unsupported();
#else
if (setpriority(PRIO_PROCESS, (id_t)threadID, priority) == 0) {
@@ -283,7 +283,7 @@ int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority)
/* this is a public symbol, so it has to exist even if threads are disabled. */
int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
{
#if SDL_THREADS_DISABLED
#ifdef SDL_THREADS_DISABLED
return SDL_Unsupported();
#else
int osPriority;

View File

@@ -551,7 +551,7 @@ int SDL_StartEventLoop(void)
*/
/* Create the lock and set ourselves active */
#if !SDL_THREADS_DISABLED
#ifndef SDL_THREADS_DISABLED
if (!SDL_EventQ.lock) {
SDL_EventQ.lock = SDL_CreateMutex();
if (SDL_EventQ.lock == NULL) {

View File

@@ -120,7 +120,7 @@ SDL_Generic_GetTLSData(void)
SDL_TLSEntry *entry;
SDL_TLSData *storage = NULL;
#if !SDL_THREADS_DISABLED
#ifndef SDL_THREADS_DISABLED
if (SDL_generic_TLS_mutex == NULL) {
static SDL_SpinLock tls_lock;
SDL_AtomicLock(&tls_lock);
@@ -145,7 +145,7 @@ SDL_Generic_GetTLSData(void)
break;
}
}
#if !SDL_THREADS_DISABLED
#ifndef SDL_THREADS_DISABLED
SDL_UnlockMutex(SDL_generic_TLS_mutex);
#endif
@@ -203,7 +203,7 @@ static SDL_error *SDL_GetStaticErrBuf(void)
return &SDL_global_error;
}
#if !SDL_THREADS_DISABLED
#ifndef SDL_THREADS_DISABLED
static void SDLCALL SDL_FreeErrBuf(void *data)
{
SDL_error *errbuf = (SDL_error *)data;
@@ -219,7 +219,7 @@ static void SDLCALL SDL_FreeErrBuf(void *data)
SDL_error *
SDL_GetErrBuf(void)
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return SDL_GetStaticErrBuf();
#else
static SDL_SpinLock tls_lock;

View File

@@ -24,7 +24,7 @@
#define SDL_thread_c_h_
/* Need the definitions of SYS_ThreadHandle */
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
#include "generic/SDL_systhread_c.h"
#elif SDL_THREAD_PTHREAD
#include "pthread/SDL_systhread_c.h"

View File

@@ -40,7 +40,7 @@ SDL_CreateMutex(void)
/* Allocate mutex memory */
mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex));
#if !SDL_THREADS_DISABLED
#ifndef SDL_THREADS_DISABLED
if (mutex) {
/* Create the mutex semaphore, with initial value 1 */
mutex->sem = SDL_CreateSemaphore(1);
@@ -72,7 +72,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 */
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return 0;
#else
SDL_threadID this_thread;
@@ -101,7 +101,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
/* try Lock the mutex */
int SDL_TryLockMutex(SDL_mutex *mutex)
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return 0;
#else
int retval = 0;
@@ -133,7 +133,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 */
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return 0;
#else
if (mutex == NULL) {

View File

@@ -24,7 +24,7 @@
#include "SDL_systhread_c.h"
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
SDL_sem *
SDL_CreateSemaphore(Uint32 initial_value)

View File

@@ -75,7 +75,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 */
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return 0;
#else
SceInt32 res = 0;
@@ -96,7 +96,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)
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return 0;
#else
SceInt32 res = 0;
@@ -125,7 +125,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 */
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return 0;
#else
SceInt32 res = 0;

View File

@@ -71,7 +71,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 */
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return 0;
#else
SceInt32 res = 0;
@@ -92,7 +92,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)
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return 0;
#else
SceInt32 res = 0;
@@ -121,7 +121,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 */
{
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
return 0;
#else
SceInt32 res = 0;

View File

@@ -25,7 +25,7 @@
/* #define DEBUG_TIMERS */
#if !defined(__EMSCRIPTEN__) || !SDL_THREADS_DISABLED
#if !defined(__EMSCRIPTEN__) || !defined(SDL_THREADS_DISABLED)
typedef struct SDL_Timer
{

View File

@@ -54,7 +54,7 @@ static ssize_t write_pipe(int fd, const void *buffer, size_t total_length, size_
sigemptyset(&sig_set);
sigaddset(&sig_set, SIGPIPE);
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
sigprocmask(SIG_BLOCK, &sig_set, &old_sig_set);
#else
pthread_sigmask(SIG_BLOCK, &sig_set, &old_sig_set);
@@ -76,7 +76,7 @@ static ssize_t write_pipe(int fd, const void *buffer, size_t total_length, size_
sigtimedwait(&sig_set, 0, &zerotime);
#if SDL_THREADS_DISABLED
#if defined(SDL_THREADS_DISABLED)
sigprocmask(SIG_SETMASK, &old_sig_set, NULL);
#else
pthread_sigmask(SIG_SETMASK, &old_sig_set, NULL);