blob: c125c4ace5faca720a18cd8bd9b9e587a67d103a (
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 7d5006df84aeec510a07717310e17a35043e1f9e 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 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
|