aboutsummaryrefslogtreecommitdiff
path: root/src/chips/common/mutex.hpp
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2022-03-08 03:33:47 +0300
committerWohlstand <admin@wohlnet.ru>2022-03-08 03:33:47 +0300
commitdf5e66f6eb5ea0998e593870b0d68ac56033c686 (patch)
tree3927429f8d18670c8851c84392bb5848c5d6b257 /src/chips/common/mutex.hpp
parent66527315eadae96a30540a98e3e1b19327062a44 (diff)
downloadlibADLMIDI-df5e66f6eb5ea0998e593870b0d68ac56033c686.tar.gz
libADLMIDI-df5e66f6eb5ea0998e593870b0d68ac56033c686.tar.bz2
libADLMIDI-df5e66f6eb5ea0998e593870b0d68ac56033c686.zip
Disable mutex usage at some platforms
Diffstat (limited to 'src/chips/common/mutex.hpp')
-rw-r--r--src/chips/common/mutex.hpp33
1 files changed, 27 insertions, 6 deletions
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 <http://www.gnu.org/licenses/>.
*/
-#if !defined(_WIN32)
-#include <pthread.h>
+#ifndef DOSBOX_NO_MUTEX
+# if !defined(_WIN32)
+# include <pthread.h>
typedef pthread_mutex_t MutexNativeObject;
-#else
-#include <windows.h>
+# else
+# include <windows.h>
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);