include/mgba-util/threading.h (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef THREADING_H
7#define THREADING_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#ifndef DISABLE_THREADING
14#ifdef USE_PTHREADS
15#include <mgba-util/platform/posix/threading.h>
16#elif defined(_WIN32)
17#include <mgba-util/platform/windows/threading.h>
18#elif defined(PSP2)
19#include <mgba-util/platform/psp2/threading.h>
20#elif defined(_3DS)
21#include <mgba-util/platform/3ds/threading.h>
22#elif defined(__SWITCH__)
23#include <mgba-util/platform/switch/threading.h>
24#else
25#define DISABLE_THREADING
26#endif
27#endif
28#ifdef DISABLE_THREADING
29#ifdef _3DS
30// ctrulib already has a type called Thread
31#include <3ds/thread.h>
32#elif defined(__SWITCH__)
33#include <switch/kernel/thread.h>
34#else
35typedef void* Thread;
36#endif
37#ifdef __SWITCH__
38#include <switch/kernel/mutex.h>
39#else
40typedef void* Mutex;
41#endif
42typedef void* Condition;
43
44static inline int MutexInit(Mutex* mutex) {
45 UNUSED(mutex);
46 return 0;
47}
48
49static inline int MutexDeinit(Mutex* mutex) {
50 UNUSED(mutex);
51 return 0;
52}
53
54static inline int MutexLock(Mutex* mutex) {
55 UNUSED(mutex);
56 return 0;
57}
58
59static inline int MutexTryLock(Mutex* mutex) {
60 UNUSED(mutex);
61 return 0;
62}
63
64static inline int MutexUnlock(Mutex* mutex) {
65 UNUSED(mutex);
66 return 0;
67}
68
69static inline int ConditionInit(Condition* cond) {
70 UNUSED(cond);
71 return 0;
72}
73
74static inline int ConditionDeinit(Condition* cond) {
75 UNUSED(cond);
76 return 0;
77}
78
79static inline int ConditionWait(Condition* cond, Mutex* mutex) {
80 UNUSED(cond);
81 UNUSED(mutex);
82 return 0;
83}
84
85static inline int ConditionWaitTimed(Condition* cond, Mutex* mutex, int32_t timeoutMs) {
86 UNUSED(cond);
87 UNUSED(mutex);
88 UNUSED(timeoutMs);
89 return 0;
90}
91
92static inline int ConditionWake(Condition* cond) {
93 UNUSED(cond);
94 return 0;
95}
96#endif
97
98CXX_GUARD_END
99
100#endif