[libcxx] r275819 - Don't use pthread initializers in constexpr constructors. Patch by elram. Reviewed at https://reviews.llvm.org/D21637.

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 18 10:23:06 PDT 2016


Author: marshall
Date: Mon Jul 18 12:23:06 2016
New Revision: 275819

URL: http://llvm.org/viewvc/llvm-project?rev=275819&view=rev
Log:
Don't use pthread initializers in constexpr constructors. Patch by elram. Reviewed at https://reviews.llvm.org/D21637.

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=275819&r1=275818&r2=275819&view=diff
==============================================================================
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Mon Jul 18 12:23:06 2016
@@ -34,16 +34,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
 {
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
+#else
     __libcpp_mutex_t __m_;
+#endif
 
 public:
     _LIBCPP_INLINE_VISIBILITY
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
-    constexpr mutex() _NOEXCEPT : __m_(_LIBCPP_MUTEX_INITIALIZER) {}
+    constexpr mutex() _NOEXCEPT _LIBCPP_DEFAULT
 #else
     mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
 #endif
-     ~mutex();
+    ~mutex();
 
 private:
     mutex(const mutex&);// = delete;
@@ -287,13 +291,18 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_st
 
 class _LIBCPP_TYPE_VIS condition_variable
 {
-    __libcpp_condvar_t  __cv_;
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
+#else
+    __libcpp_condvar_t __cv_;
+#endif
+
 public:
     _LIBCPP_INLINE_VISIBILITY
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
-    constexpr condition_variable() : __cv_(_LIBCPP_CONDVAR_INITIALIZER) {}
+    constexpr condition_variable() _NOEXCEPT _LIBCPP_DEFAULT
 #else
-    condition_variable() {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
+    condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
 #endif
     ~condition_variable();
 




More information about the cfe-commits mailing list