2015-06-18 08:00:35 +00:00
|
|
|
/* Copyright (c) 2013-2015 Jeffrey Pfau
|
2014-12-03 08:39:06 +00:00
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2014-01-16 07:46:47 +00:00
|
|
|
#ifndef THREADING_H
|
|
|
|
#define THREADING_H
|
|
|
|
|
2016-12-31 01:00:22 +00:00
|
|
|
#include <mgba-util/common.h>
|
2014-01-16 07:46:47 +00:00
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_START
|
|
|
|
|
2015-06-04 03:37:45 +00:00
|
|
|
#ifndef DISABLE_THREADING
|
2014-01-16 07:46:47 +00:00
|
|
|
#ifdef USE_PTHREADS
|
2016-12-31 01:00:22 +00:00
|
|
|
#include <mgba-util/platform/posix/threading.h>
|
2018-09-14 01:12:32 +00:00
|
|
|
#elif defined(_WIN32)
|
2016-12-31 01:00:22 +00:00
|
|
|
#include <mgba-util/platform/windows/threading.h>
|
2018-09-14 01:12:32 +00:00
|
|
|
#elif defined(PSP2)
|
2016-12-31 01:00:22 +00:00
|
|
|
#include <mgba-util/platform/psp2/threading.h>
|
2018-09-14 01:12:32 +00:00
|
|
|
#elif defined(_3DS)
|
2016-12-31 01:00:22 +00:00
|
|
|
#include <mgba-util/platform/3ds/threading.h>
|
2018-09-14 01:12:32 +00:00
|
|
|
#elif defined(__SWITCH__)
|
|
|
|
#include <mgba-util/platform/switch/threading.h>
|
2014-12-09 00:00:08 +00:00
|
|
|
#else
|
|
|
|
#define DISABLE_THREADING
|
2015-06-04 03:37:45 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef DISABLE_THREADING
|
2016-01-03 18:34:25 +00:00
|
|
|
#ifdef _3DS
|
|
|
|
// ctrulib already has a type called Thread
|
|
|
|
#include <3ds/thread.h>
|
|
|
|
#else
|
2014-12-09 00:00:08 +00:00
|
|
|
typedef void* Thread;
|
2016-01-03 18:34:25 +00:00
|
|
|
#endif
|
2014-12-09 00:00:08 +00:00
|
|
|
typedef void* Mutex;
|
|
|
|
typedef void* Condition;
|
2014-12-09 02:49:05 +00:00
|
|
|
|
|
|
|
static inline int MutexInit(Mutex* mutex) {
|
|
|
|
UNUSED(mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int MutexDeinit(Mutex* mutex) {
|
|
|
|
UNUSED(mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int MutexLock(Mutex* mutex) {
|
|
|
|
UNUSED(mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-13 06:50:09 +00:00
|
|
|
static inline int MutexTryLock(Mutex* mutex) {
|
|
|
|
UNUSED(mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-09 02:49:05 +00:00
|
|
|
static inline int MutexUnlock(Mutex* mutex) {
|
|
|
|
UNUSED(mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ConditionInit(Condition* cond) {
|
|
|
|
UNUSED(cond);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ConditionDeinit(Condition* cond) {
|
|
|
|
UNUSED(cond);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ConditionWait(Condition* cond, Mutex* mutex) {
|
|
|
|
UNUSED(cond);
|
|
|
|
UNUSED(mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-21 11:44:15 +00:00
|
|
|
static inline int ConditionWaitTimed(Condition* cond, Mutex* mutex, int32_t timeoutMs) {
|
|
|
|
UNUSED(cond);
|
|
|
|
UNUSED(mutex);
|
|
|
|
UNUSED(timeoutMs);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-09 02:49:05 +00:00
|
|
|
static inline int ConditionWake(Condition* cond) {
|
|
|
|
UNUSED(cond);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-01-16 07:46:47 +00:00
|
|
|
#endif
|
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_END
|
|
|
|
|
2014-01-16 07:46:47 +00:00
|
|
|
#endif
|