summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/clang/libcxx/0001-use-constexpr-when-using-glibc.patch
blob: f66de8f31369a958fd682b09b202f5900280906c (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
49
50
51
52
53
54
55
56
From 21ddd574f6e9b321614d39a7765f1ad98aa09f54 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 15 Mar 2016 04:56:27 +0000
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 | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/__mutex_base b/include/__mutex_base
index b019b47..10ad9f2 100644
--- a/include/__mutex_base
+++ b/include/__mutex_base
@@ -33,7 +33,10 @@ class _LIBCPP_TYPE_VIS mutex
 public:
     _LIBCPP_INLINE_VISIBILITY
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
-     constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
+#ifdef __GLIBC__
+     constexpr
+#endif
+     mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
 #else
      mutex() _NOEXCEPT {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;}
 #endif
@@ -63,7 +66,6 @@ extern const try_to_lock_t try_to_lock;
 extern const adopt_lock_t  adopt_lock;
 
 #else
-
 constexpr defer_lock_t  defer_lock  = defer_lock_t();
 constexpr try_to_lock_t try_to_lock = try_to_lock_t();
 constexpr adopt_lock_t  adopt_lock  = adopt_lock_t();
@@ -272,7 +274,10 @@ class _LIBCPP_TYPE_VIS condition_variable
 public:
     _LIBCPP_INLINE_VISIBILITY
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
-    constexpr condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {}
+#ifdef __GLIBC__
+    constexpr
+#endif
+    condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {}
 #else
     condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;}
 #endif
-- 
1.9.1