From 1183acbc77370e000efafcaa5c596fe652eb7efd Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Fri, 11 Mar 2022 02:30:26 +0300 Subject: Use LWP_Mutex API from libOGC where needed --- src/chips/common/mutex.hpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/chips/common/mutex.hpp') diff --git a/src/chips/common/mutex.hpp b/src/chips/common/mutex.hpp index 89d49b0..02ad1c7 100644 --- a/src/chips/common/mutex.hpp +++ b/src/chips/common/mutex.hpp @@ -22,7 +22,10 @@ */ #ifndef DOSBOX_NO_MUTEX -# if !defined(_WIN32) +# if defined(USE_LIBOGC_MUTEX) +# include +typedef mutex_t MutexNativeObject; +# elif !defined(_WIN32) # include typedef pthread_mutex_t MutexNativeObject; # else @@ -31,6 +34,7 @@ typedef CRITICAL_SECTION MutexNativeObject; # endif #endif + class Mutex { public: @@ -71,6 +75,29 @@ inline void Mutex::lock() inline void Mutex::unlock() {} +#elif defined(USE_LIBOGC_MUTEX) + +inline Mutex::Mutex() +{ + m = LWP_MUTEX_NULL; + LWP_MutexInit(&m, 0); +} + +inline Mutex::~Mutex() +{ + LWP_MutexDestroy(m); +} + +inline void Mutex::lock() +{ + LWP_MutexLock(m); +} + +inline void Mutex::unlock() +{ + LWP_MutexUnlock(m); +} + #elif !defined(_WIN32) // pthread inline Mutex::Mutex() -- cgit v1.2.3