blob: e9eb4d236f160147c81cfe860a1e56824a580c13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
From a97e50970942df6bf0f3f2fda5ba44e10ef63713 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
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 <raj.khem@gmail.com>
---
include/__mutex_base | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/__mutex_base b/include/__mutex_base
index 32536a6..58430c7 100644
--- a/include/__mutex_base
+++ b/include/__mutex_base
@@ -39,7 +39,10 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mut
public:
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
- constexpr mutex() _NOEXCEPT : __m_(_LIBCPP_MUTEX_INITIALIZER) {}
+#ifdef __GLIBC__
+ constexpr
+#endif
+ mutex() _NOEXCEPT : __m_(_LIBCPP_MUTEX_INITIALIZER) {}
#else
mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
#endif
@@ -278,7 +281,10 @@ class _LIBCPP_TYPE_VIS condition_variable
public:
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
- constexpr condition_variable() : __cv_(_LIBCPP_CONDVAR_INITIALIZER) {}
+#ifdef __GLIBC__
+ constexpr
+#endif
+ condition_variable() : __cv_(_LIBCPP_CONDVAR_INITIALIZER) {}
#else
condition_variable() {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
#endif
--
2.8.2
|