summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2012-07-07 20:01:52 +0000
committerHoward Hinnant <hhinnant@apple.com>2012-07-07 20:01:52 +0000
commitbfa7990b5a5cc72921caa5d3231b3865b09164f3 (patch)
tree6908f425c0755e4045c9e301b5279e997dc4155c
parenteeac9fcfb723bc5ea98b3857536b7f938660d762 (diff)
downloadbcm5719-llvm-bfa7990b5a5cc72921caa5d3231b3865b09164f3.tar.gz
bcm5719-llvm-bfa7990b5a5cc72921caa5d3231b3865b09164f3.zip
Apply constexpr to the mutex constructor. As a conforming extension, apply constexpr to the condition_variable constructor. These are important because it enables the compiler to construct these types at compile time, even though the object will be non-const. Since they are constructed at compile time, there is no chance of a data race before they are constructed.
llvm-svn: 159901
-rw-r--r--libcxx/include/__mutex_base8
1 files changed, 8 insertions, 0 deletions
diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base
index 5410272b4c9..854f02c436f 100644
--- a/libcxx/include/__mutex_base
+++ b/libcxx/include/__mutex_base
@@ -38,7 +38,11 @@ class _LIBCPP_VISIBLE mutex
public:
_LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ constexpr mutex() : __m_ PTHREAD_MUTEX_INITIALIZER {}
+#else
mutex() {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;}
+#endif
~mutex();
private:
@@ -297,7 +301,11 @@ class _LIBCPP_VISIBLE condition_variable
pthread_cond_t __cv_;
public:
_LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ constexpr condition_variable() : __cv_ PTHREAD_COND_INITIALIZER {}
+#else
condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;}
+#endif
~condition_variable();
private:
OpenPOWER on IntegriCloud