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 _WIN32
17#include <mgba-util/platform/windows/threading.h>
18#elif PSP2
19#include <mgba-util/platform/psp2/threading.h>
20#elif _3DS
21#include <mgba-util/platform/3ds/threading.h>
22#else
23#define DISABLE_THREADING
24#endif
25#endif
26#ifdef DISABLE_THREADING
27#ifdef _3DS
28// ctrulib already has a type called Thread
29#include <3ds/thread.h>
30#else
31typedef void* Thread;
32#endif
33typedef void* Mutex;
34typedef void* Condition;
35
36static inline int MutexInit(Mutex* mutex) {
37 UNUSED(mutex);
38 return 0;
39}
40
41static inline int MutexDeinit(Mutex* mutex) {
42 UNUSED(mutex);
43 return 0;
44}
45
46static inline int MutexLock(Mutex* mutex) {
47 UNUSED(mutex);
48 return 0;
49}
50
51static inline int MutexTryLock(Mutex* mutex) {
52 UNUSED(mutex);
53 return 0;
54}
55
56static inline int MutexUnlock(Mutex* mutex) {
57 UNUSED(mutex);
58 return 0;
59}
60
61static inline int ConditionInit(Condition* cond) {
62 UNUSED(cond);
63 return 0;
64}
65
66static inline int ConditionDeinit(Condition* cond) {
67 UNUSED(cond);
68 return 0;
69}
70
71static inline int ConditionWait(Condition* cond, Mutex* mutex) {
72 UNUSED(cond);
73 UNUSED(mutex);
74 return 0;
75}
76
77static inline int ConditionWaitTimed(Condition* cond, Mutex* mutex, int32_t timeoutMs) {
78 UNUSED(cond);
79 UNUSED(mutex);
80 UNUSED(timeoutMs);
81 return 0;
82}
83
84static inline int ConditionWake(Condition* cond) {
85 UNUSED(cond);
86 return 0;
87}
88#endif
89
90CXX_GUARD_END
91
92#endif