diff options
Diffstat (limited to '')
-rw-r--r-- | src/thread/PosixMutex.hxx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/thread/PosixMutex.hxx b/src/thread/PosixMutex.hxx index 9d1674dd4..5805158d5 100644 --- a/src/thread/PosixMutex.hxx +++ b/src/thread/PosixMutex.hxx @@ -41,10 +41,21 @@ class PosixMutex { pthread_mutex_t mutex; public: -#ifndef __BIONIC__ - constexpr +#if defined(__NetBSD__) || defined(__BIONIC__) + /* NetBSD's PTHREAD_MUTEX_INITIALIZER is not compatible with + "constexpr" */ + PosixMutex() { + pthread_mutex_init(&mutex, nullptr); + } + + ~PosixMutex() { + pthread_mutex_destroy(&mutex); + } +#else + /* optimized constexpr constructor for sane POSIX + implementations */ + constexpr PosixMutex():mutex(PTHREAD_MUTEX_INITIALIZER) {} #endif - PosixMutex():mutex(PTHREAD_MUTEX_INITIALIZER) {} PosixMutex(const PosixMutex &other) = delete; PosixMutex &operator=(const PosixMutex &other) = delete; |