aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread/PosixMutex.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-09-24 21:49:20 +0200
committerMax Kellermann <max@duempel.org>2014-09-24 21:49:20 +0200
commit92704857231423f662152495d5521301195dfd17 (patch)
treefdc2e8102018456790652f3c96953ce23147ce56 /src/thread/PosixMutex.hxx
parentcbdaf4827fedd4159de07a648899d88ca9a884af (diff)
parente93975cb466db335f4c9739669fb22ad4ecf0b08 (diff)
downloadmpd-92704857231423f662152495d5521301195dfd17.tar.gz
mpd-92704857231423f662152495d5521301195dfd17.tar.xz
mpd-92704857231423f662152495d5521301195dfd17.zip
Merge branch 'v0.18.x'
Diffstat (limited to 'src/thread/PosixMutex.hxx')
-rw-r--r--src/thread/PosixMutex.hxx17
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;