aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread/PosixMutex.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread/PosixMutex.hxx')
-rw-r--r--src/thread/PosixMutex.hxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/thread/PosixMutex.hxx b/src/thread/PosixMutex.hxx
index d50764af4..445c0ace2 100644
--- a/src/thread/PosixMutex.hxx
+++ b/src/thread/PosixMutex.hxx
@@ -41,7 +41,21 @@ class PosixMutex {
pthread_mutex_t mutex;
public:
+#ifdef __NetBSD__
+ /* 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(const PosixMutex &other) = delete;
PosixMutex &operator=(const PosixMutex &other) = delete;