From df5e66f6eb5ea0998e593870b0d68ac56033c686 Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Tue, 8 Mar 2022 03:33:47 +0300 Subject: Disable mutex usage at some platforms --- src/chips/common/mutex.hpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/chips/common/mutex.hpp b/src/chips/common/mutex.hpp index 8fc1dc8..89d49b0 100644 --- a/src/chips/common/mutex.hpp +++ b/src/chips/common/mutex.hpp @@ -21,12 +21,14 @@ * along with this program. If not, see . */ -#if !defined(_WIN32) -#include +#ifndef DOSBOX_NO_MUTEX +# if !defined(_WIN32) +# include typedef pthread_mutex_t MutexNativeObject; -#else -#include +# else +# include typedef CRITICAL_SECTION MutexNativeObject; +# endif #endif class Mutex @@ -37,7 +39,9 @@ public: void lock(); void unlock(); private: +#if !defined(DOSBOX_NO_MUTEX) MutexNativeObject m; +#endif Mutex(const Mutex &); Mutex &operator=(const Mutex &); }; @@ -53,7 +57,22 @@ private: MutexHolder &operator=(const MutexHolder &); }; -#if !defined(_WIN32) +#if defined(DOSBOX_NO_MUTEX) // No mutex, just a dummy + +inline Mutex::Mutex() +{} + +inline Mutex::~Mutex() +{} + +inline void Mutex::lock() +{} + +inline void Mutex::unlock() +{} + +#elif !defined(_WIN32) // pthread + inline Mutex::Mutex() { pthread_mutex_init(&m, NULL); @@ -73,7 +92,9 @@ inline void Mutex::unlock() { pthread_mutex_unlock(&m); } -#else + +#else // Win32 + inline Mutex::Mutex() { InitializeCriticalSection(&m); -- cgit v1.2.3