Vita, Wii: Build fixes

This commit is contained in:
Vicki Pfau 2022-08-08 13:05:32 -07:00
parent 9b07a63056
commit ba27062842
2 changed files with 13 additions and 8 deletions

View File

@ -17,7 +17,6 @@ typedef struct {
} Condition; } Condition;
#define THREAD_ENTRY int #define THREAD_ENTRY int
typedef THREAD_ENTRY (*ThreadEntry)(void*); typedef THREAD_ENTRY (*ThreadEntry)(void*);
typedef int ThreadLocal;
static inline int MutexInit(Mutex* mutex) { static inline int MutexInit(Mutex* mutex) {
Mutex id = sceKernelCreateMutex("mutex", 0, 0, 0); Mutex id = sceKernelCreateMutex("mutex", 0, 0, 0);
@ -145,6 +144,9 @@ static inline int ThreadSetName(const char* name) {
return -1; return -1;
} }
#if (__STDC_VERSION__ < 201112L) || (__STDC_NO_THREADS__ == 1)
typedef int ThreadLocal;
static inline void ThreadLocalInitKey(ThreadLocal* key) { static inline void ThreadLocalInitKey(ThreadLocal* key) {
static int base = 0x90; static int base = 0x90;
*key = __atomic_fetch_add(&base, 1, __ATOMIC_SEQ_CST); *key = __atomic_fetch_add(&base, 1, __ATOMIC_SEQ_CST);
@ -160,3 +162,4 @@ static inline void* ThreadLocalGetValue(ThreadLocal key) {
return *tls; return *tls;
} }
#endif #endif
#endif

View File

@ -11,12 +11,6 @@
CXX_GUARD_START CXX_GUARD_START
#ifndef 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
#ifdef USE_PTHREADS #ifdef USE_PTHREADS
#include <mgba-util/platform/posix/threading.h> #include <mgba-util/platform/posix/threading.h>
#elif defined(_WIN32) #elif defined(_WIN32)
@ -31,7 +25,15 @@ CXX_GUARD_START
#define DISABLE_THREADING #define DISABLE_THREADING
#endif #endif
#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__ #ifdef __3DS__
// ctrulib already has a type called Thread // ctrulib already has a type called Thread
#include <3ds/thread.h> #include <3ds/thread.h>