all repos — mgba @ 9de8f084ba55460b02d300c1dd8b8e6c56f691d5

mGBA Game Boy Advance Emulator

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#else
33typedef void* Thread;
34#endif
35typedef void* Mutex;
36typedef void* Condition;
37
38static inline int MutexInit(Mutex* mutex) {
39	UNUSED(mutex);
40	return 0;
41}
42
43static inline int MutexDeinit(Mutex* mutex) {
44	UNUSED(mutex);
45	return 0;
46}
47
48static inline int MutexLock(Mutex* mutex) {
49	UNUSED(mutex);
50	return 0;
51}
52
53static inline int MutexTryLock(Mutex* mutex) {
54	UNUSED(mutex);
55	return 0;
56}
57
58static inline int MutexUnlock(Mutex* mutex) {
59	UNUSED(mutex);
60	return 0;
61}
62
63static inline int ConditionInit(Condition* cond) {
64	UNUSED(cond);
65	return 0;
66}
67
68static inline int ConditionDeinit(Condition* cond) {
69	UNUSED(cond);
70	return 0;
71}
72
73static inline int ConditionWait(Condition* cond, Mutex* mutex) {
74	UNUSED(cond);
75	UNUSED(mutex);
76	return 0;
77}
78
79static inline int ConditionWaitTimed(Condition* cond, Mutex* mutex, int32_t timeoutMs) {
80	UNUSED(cond);
81	UNUSED(mutex);
82	UNUSED(timeoutMs);
83	return 0;
84}
85
86static inline int ConditionWake(Condition* cond) {
87	UNUSED(cond);
88	return 0;
89}
90#endif
91
92CXX_GUARD_END
93
94#endif