[PATCH] D21637: [libcxx] Don't use pthread initializers in constexpr constructors
Julien via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 23 01:00:57 PDT 2016
elram created this revision.
elram added a reviewer: EricWF.
elram added a subscriber: cfe-commits.
Some pthread implementations use volatile types in their structs.
C++11 does not allow initializing volatile types in constexpr constructors.
This fixes building libcxx on musl-libc and NetBSD.
http://reviews.llvm.org/D21637
Files:
include/__mutex_base
Index: include/__mutex_base
===================================================================
--- include/__mutex_base
+++ include/__mutex_base
@@ -34,15 +34,14 @@
class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
{
- __libcpp_mutex_t __m_;
+ __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
public:
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
- constexpr mutex() _NOEXCEPT : __m_(_LIBCPP_MUTEX_INITIALIZER) {}
-#else
- mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
+ constexpr
#endif
+ mutex() _NOEXCEPT = default;
~mutex();
private:
@@ -287,15 +286,15 @@
class _LIBCPP_TYPE_VIS condition_variable
{
- __libcpp_condvar_t __cv_;
+ __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
+
public:
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
- constexpr condition_variable() : __cv_(_LIBCPP_CONDVAR_INITIALIZER) {}
-#else
- condition_variable() {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
+ constexpr
#endif
- ~condition_variable();
+ condition_variable() _NOEXCEPT;
+ ~condition_variable() _NOEXCEPT;
private:
condition_variable(const condition_variable&); // = delete;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21637.61645.patch
Type: text/x-patch
Size: 1265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160623/ba8af260/attachment.bin>
More information about the cfe-commits
mailing list