aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread/PosixCond.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-08-25 12:46:12 +0200
committerMax Kellermann <max@duempel.org>2015-08-25 12:46:12 +0200
commit75dff6445063d9b49cca126fd661c9abbd680977 (patch)
tree585a91e6e91b7f5641d2093d98a4bf43df29d531 /src/thread/PosixCond.hxx
parentf0b58c6f2463da0b7f509a53d8054d5472504094 (diff)
downloadmpd-75dff6445063d9b49cca126fd661c9abbd680977.tar.gz
mpd-75dff6445063d9b49cca126fd661c9abbd680977.tar.xz
mpd-75dff6445063d9b49cca126fd661c9abbd680977.zip
thread/Posix{Mutex,Cond}: use "constexpr" only with glibc
Apparently all other C libraries are not compatible with "constexpr". Those which are not will get a performance penalty, but at least they work at all.
Diffstat (limited to '')
-rw-r--r--src/thread/PosixCond.hxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/thread/PosixCond.hxx b/src/thread/PosixCond.hxx
index b3fe204e1..73dbe0218 100644
--- a/src/thread/PosixCond.hxx
+++ b/src/thread/PosixCond.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2013 Max Kellermann <max@duempel.org>
+ * Copyright (C) 2009-2015 Max Kellermann <max@duempel.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,9 +41,13 @@ class PosixCond {
pthread_cond_t cond;
public:
-#if defined(__NetBSD__) || defined(__BIONIC__)
- /* NetBSD's PTHREAD_COND_INITIALIZER is not compatible with
- "constexpr" */
+#ifdef __GLIBC__
+ /* optimized constexpr constructor for pthread implementations
+ that support it */
+ constexpr PosixCond():cond(PTHREAD_COND_INITIALIZER) {}
+#else
+ /* slow fallback for pthread implementations that are not
+ compatible with "constexpr" */
PosixCond() {
pthread_cond_init(&cond, nullptr);
}
@@ -51,10 +55,6 @@ public:
~PosixCond() {
pthread_cond_destroy(&cond);
}
-#else
- /* optimized constexpr constructor for sane POSIX
- implementations */
- constexpr PosixCond():cond(PTHREAD_COND_INITIALIZER) {}
#endif
PosixCond(const PosixCond &other) = delete;