diff options
author | 2018-09-11 18:18:58 +0000 | |
---|---|---|
committer | 2018-09-11 18:18:58 +0000 | |
commit | 820e1f31efc1d6ed04795ba2e79f3044e1907492 (patch) | |
tree | 815cebb3734784074b661935c33f00bd5eb4d862 /lib/libcxx/src/mutex.cpp | |
parent | Nuke unused LIST() ieee80211com_head. (diff) | |
download | wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.tar.xz wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.zip |
import of libc++ 6.0.0
Diffstat (limited to 'lib/libcxx/src/mutex.cpp')
-rw-r--r-- | lib/libcxx/src/mutex.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/libcxx/src/mutex.cpp b/lib/libcxx/src/mutex.cpp index 9f808ca5076..c36bd5549da 100644 --- a/lib/libcxx/src/mutex.cpp +++ b/lib/libcxx/src/mutex.cpp @@ -11,8 +11,8 @@ #include "mutex" #include "limits" #include "system_error" -#include "cassert" #include "include/atomic_support.h" +#include "__undef_macros" _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS @@ -37,7 +37,7 @@ mutex::lock() bool mutex::try_lock() _NOEXCEPT { - return __libcpp_mutex_trylock(&__m_) == 0; + return __libcpp_mutex_trylock(&__m_); } void @@ -45,7 +45,7 @@ mutex::unlock() _NOEXCEPT { int ec = __libcpp_mutex_unlock(&__m_); (void)ec; - assert(ec == 0); + _LIBCPP_ASSERT(ec == 0, "call to mutex::unlock failed"); } // recursive_mutex @@ -59,15 +59,15 @@ recursive_mutex::recursive_mutex() recursive_mutex::~recursive_mutex() { - int e = __libcpp_mutex_destroy(&__m_); + int e = __libcpp_recursive_mutex_destroy(&__m_); (void)e; - assert(e == 0); + _LIBCPP_ASSERT(e == 0, "call to ~recursive_mutex() failed"); } void recursive_mutex::lock() { - int ec = __libcpp_mutex_lock(&__m_); + int ec = __libcpp_recursive_mutex_lock(&__m_); if (ec) __throw_system_error(ec, "recursive_mutex lock failed"); } @@ -75,15 +75,15 @@ recursive_mutex::lock() void recursive_mutex::unlock() _NOEXCEPT { - int e = __libcpp_mutex_unlock(&__m_); + int e = __libcpp_recursive_mutex_unlock(&__m_); (void)e; - assert(e == 0); + _LIBCPP_ASSERT(e == 0, "call to recursive_mutex::unlock() failed"); } bool recursive_mutex::try_lock() _NOEXCEPT { - return __libcpp_mutex_trylock(&__m_) == 0; + return __libcpp_recursive_mutex_trylock(&__m_); } // timed_mutex @@ -195,13 +195,10 @@ recursive_timed_mutex::unlock() _NOEXCEPT // keep in sync with: 7741191. #ifndef _LIBCPP_HAS_NO_THREADS -static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER; -static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER; +_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER; +_LIBCPP_SAFE_STATIC static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER; #endif -/// NOTE: Changes to flag are done via relaxed atomic stores -/// even though the accesses are protected by a mutex because threads -/// just entering 'call_once` concurrently read from flag. void __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) { @@ -238,7 +235,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) __libcpp_mutex_unlock(&mut); func(arg); __libcpp_mutex_lock(&mut); - __libcpp_relaxed_store(&flag, ~0ul); + __libcpp_atomic_store(&flag, ~0ul, _AO_Release); __libcpp_mutex_unlock(&mut); __libcpp_condvar_broadcast(&cv); #ifndef _LIBCPP_NO_EXCEPTIONS |