diff options
author | dim <dim@FreeBSD.org> | 2015-10-06 17:53:29 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-10-06 17:53:29 +0000 |
commit | a6f4f28b545e1f0632ba4b20b86a7ab487932373 (patch) | |
tree | e9dbc6d658415636ba47d28716ee528c8ab7c862 /contrib/libc++/src/mutex.cpp | |
parent | 09f0c012db173aa7875b4d45fc67ef4d26c82548 (diff) | |
parent | 9ba87e73be0d01bbe1cf9547130ae12f9b15d7a7 (diff) | |
download | FreeBSD-src-a6f4f28b545e1f0632ba4b20b86a7ab487932373.zip FreeBSD-src-a6f4f28b545e1f0632ba4b20b86a7ab487932373.tar.gz |
Upgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.7.0
release.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.7.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.7.0/tools/clang/docs/ReleaseNotes.html>
Thanks to Ed Maste, Andrew Turner and Antoine Brodin for their help.
Exp-run: antoine
Relnotes: yes
Diffstat (limited to 'contrib/libc++/src/mutex.cpp')
-rw-r--r-- | contrib/libc++/src/mutex.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/contrib/libc++/src/mutex.cpp b/contrib/libc++/src/mutex.cpp index e56271d..5f8ba0a 100644 --- a/contrib/libc++/src/mutex.cpp +++ b/contrib/libc++/src/mutex.cpp @@ -12,6 +12,7 @@ #include "limits" #include "system_error" #include "cassert" +#include "support/atomic_support.h" _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS @@ -220,6 +221,9 @@ static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cv = PTHREAD_COND_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*)) { @@ -252,11 +256,11 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) try { #endif // _LIBCPP_NO_EXCEPTIONS - flag = 1; + __libcpp_relaxed_store(&flag, 1ul); pthread_mutex_unlock(&mut); func(arg); pthread_mutex_lock(&mut); - flag = ~0ul; + __libcpp_relaxed_store(&flag, ~0ul); pthread_mutex_unlock(&mut); pthread_cond_broadcast(&cv); #ifndef _LIBCPP_NO_EXCEPTIONS @@ -264,7 +268,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) catch (...) { pthread_mutex_lock(&mut); - flag = 0ul; + __libcpp_relaxed_store(&flag, 0ul); pthread_mutex_unlock(&mut); pthread_cond_broadcast(&cv); throw; |