aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/PosixCond.hxx17
-rw-r--r--src/thread/PosixMutex.hxx17
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;