From 7d5006df84aeec510a07717310e17a35043e1f9e Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 19 May 2016 23:22:52 -0700 Subject: [PATCH] use constexpr when using glibc POSIX does not permit using PTHREAD_COND_INITIALIZER except for static initialization, and certainly does not permit using it as a value also POSIX does not specify the type of the object (it's opaque) so if there are any types for which their code would be invalid C++, then their code is invalid Signed-off-by: Khem Raj --- include/__mutex_base | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/__mutex_base b/include/__mutex_base index 38a76ac..0fb1e2f 100644 --- a/include/__mutex_base +++ b/include/__mutex_base @@ -43,7 +43,10 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mut public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR - constexpr mutex() _NOEXCEPT _LIBCPP_DEFAULT +#ifdef __GLIBC__ + constexpr +#endif + mutex() _NOEXCEPT _LIBCPP_DEFAULT #else mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} #endif @@ -300,7 +303,10 @@ class _LIBCPP_TYPE_VIS condition_variable public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR - constexpr condition_variable() _NOEXCEPT _LIBCPP_DEFAULT +#ifdef __GLIBC__ + constexpr +#endif + condition_variable() _NOEXCEPT _LIBCPP_DEFAULT #else condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} #endif -- 2.9.0