Author: hhinnant
Date: Sat Jul 7 15:01:52 2012
New Revision: 159901
URL: http://llvm.org/viewvc/llvm-project?rev=159901&view=rev
Log:
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.
Modified:
libcxx/trunk/include/__mutex_base
Modified: libcxx/trunk/include/__mutex_base
URL:
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=159901&r1=159900&r2=159901&view=diff
==============================================================================
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Sat Jul 7 15:01:52 2012
@@ -38,7 +38,11 @@
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 @@
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:
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits