From ba270628424c16a7393d3547f27740d71a71fced Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 8 Aug 2022 13:05:32 -0700 Subject: [PATCH] Vita, Wii: Build fixes --- include/mgba-util/platform/psp2/threading.h | 5 ++++- include/mgba-util/threading.h | 16 +++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/mgba-util/platform/psp2/threading.h b/include/mgba-util/platform/psp2/threading.h index 96e21e851..ba4827229 100644 --- a/include/mgba-util/platform/psp2/threading.h +++ b/include/mgba-util/platform/psp2/threading.h @@ -17,7 +17,6 @@ typedef struct { } Condition; #define THREAD_ENTRY int typedef THREAD_ENTRY (*ThreadEntry)(void*); -typedef int ThreadLocal; static inline int MutexInit(Mutex* mutex) { Mutex id = sceKernelCreateMutex("mutex", 0, 0, 0); @@ -145,6 +144,9 @@ static inline int ThreadSetName(const char* name) { return -1; } +#if (__STDC_VERSION__ < 201112L) || (__STDC_NO_THREADS__ == 1) +typedef int ThreadLocal; + static inline void ThreadLocalInitKey(ThreadLocal* key) { static int base = 0x90; *key = __atomic_fetch_add(&base, 1, __ATOMIC_SEQ_CST); @@ -160,3 +162,4 @@ static inline void* ThreadLocalGetValue(ThreadLocal key) { return *tls; } #endif +#endif diff --git a/include/mgba-util/threading.h b/include/mgba-util/threading.h index eefff031f..445f47f92 100644 --- a/include/mgba-util/threading.h +++ b/include/mgba-util/threading.h @@ -11,12 +11,6 @@ CXX_GUARD_START #ifndef DISABLE_THREADING -#if (__STDC_VERSION__ >= 201112L) && (__STDC_NO_THREADS__ != 1) -#define ThreadLocal _Thread_local void* -#define ThreadLocalInitKey(X) -#define ThreadLocalSetKey(K, V) K = V -#define ThreadLocalGetValue(K) K -#endif #ifdef USE_PTHREADS #include #elif defined(_WIN32) @@ -31,7 +25,15 @@ CXX_GUARD_START #define DISABLE_THREADING #endif #endif -#ifdef DISABLE_THREADING + +#ifndef DISABLE_THREADING +#if (__STDC_VERSION__ >= 201112L) && (__STDC_NO_THREADS__ != 1) +#define ThreadLocal _Thread_local void* +#define ThreadLocalInitKey(X) +#define ThreadLocalSetKey(K, V) K = V +#define ThreadLocalGetValue(K) K +#endif +#else #ifdef __3DS__ // ctrulib already has a type called Thread #include <3ds/thread.h>