diff options
author | Max Kellermann <max@duempel.org> | 2014-09-24 21:49:20 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-09-24 21:49:20 +0200 |
commit | 92704857231423f662152495d5521301195dfd17 (patch) | |
tree | fdc2e8102018456790652f3c96953ce23147ce56 /src/thread | |
parent | cbdaf4827fedd4159de07a648899d88ca9a884af (diff) | |
parent | e93975cb466db335f4c9739669fb22ad4ecf0b08 (diff) | |
download | mpd-92704857231423f662152495d5521301195dfd17.tar.gz mpd-92704857231423f662152495d5521301195dfd17.tar.xz mpd-92704857231423f662152495d5521301195dfd17.zip |
Merge branch 'v0.18.x'
Diffstat (limited to 'src/thread')
-rw-r--r-- | src/thread/PosixCond.hxx | 17 | ||||
-rw-r--r-- | src/thread/PosixMutex.hxx | 17 |
2 files changed, 28 insertions, 6 deletions
diff --git a/src/thread/PosixCond.hxx b/src/thread/PosixCond.hxx index e0d6623dd..b3fe204e1 100644 --- a/src/thread/PosixCond.hxx +++ b/src/thread/PosixCond.hxx @@ -41,10 +41,21 @@ class PosixCond { pthread_cond_t cond; public: -#ifndef __BIONIC__ - constexpr +#if defined(__NetBSD__) || defined(__BIONIC__) + /* NetBSD's PTHREAD_COND_INITIALIZER is not compatible with + "constexpr" */ + PosixCond() { + pthread_cond_init(&cond, nullptr); + } + + ~PosixCond() { + pthread_cond_destroy(&cond); + } +#else + /* optimized constexpr constructor for sane POSIX + implementations */ + constexpr PosixCond():cond(PTHREAD_COND_INITIALIZER) {} #endif - PosixCond():cond(PTHREAD_COND_INITIALIZER) {} PosixCond(const PosixCond &other) = delete; PosixCond &operator=(const PosixCond &other) = delete; 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; |