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