diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-08 19:39:03 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-08 19:39:03 +0000 |
| commit | aed8d94e97d1be8b4e26ce1ffb4d0547aee8ab1d (patch) | |
| tree | f4b32ab9e34cda2eead99ae084f0b02d0dab6891 /contrib/libc++/src/mutex.cpp | |
| parent | 657db61c2068b2bcc0d930546402284e2c9c9abd (diff) | |
| parent | 4a2db4d30e1653093d4d8b06e8221e2f8b723507 (diff) | |
Notes
Diffstat (limited to 'contrib/libc++/src/mutex.cpp')
| -rw-r--r-- | contrib/libc++/src/mutex.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/contrib/libc++/src/mutex.cpp b/contrib/libc++/src/mutex.cpp index 9f808ca5076c..9397ae73ca4f 100644 --- a/contrib/libc++/src/mutex.cpp +++ b/contrib/libc++/src/mutex.cpp @@ -59,7 +59,7 @@ 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); } @@ -67,7 +67,7 @@ recursive_mutex::~recursive_mutex() 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,7 +75,7 @@ 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); } @@ -83,7 +83,7 @@ recursive_mutex::unlock() _NOEXCEPT bool recursive_mutex::try_lock() _NOEXCEPT { - return __libcpp_mutex_trylock(&__m_) == 0; + return __libcpp_recursive_mutex_trylock(&__m_) == 0; } // 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 |
