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/memory.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/memory.cpp')
-rw-r--r-- | contrib/libc++/src/memory.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/contrib/libc++/src/memory.cpp b/contrib/libc++/src/memory.cpp index 8a4eb34..66fb143 100644 --- a/contrib/libc++/src/memory.cpp +++ b/contrib/libc++/src/memory.cpp @@ -13,24 +13,28 @@ #include "mutex" #include "thread" #endif +#include "support/atomic_support.h" _LIBCPP_BEGIN_NAMESPACE_STD namespace { +// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively) +// should be sufficient for thread safety. +// See https://llvm.org/bugs/show_bug.cgi?id=22803 template <class T> inline T increment(T& t) _NOEXCEPT { - return __sync_add_and_fetch(&t, 1); + return __libcpp_atomic_add(&t, 1, _AO_Relaxed); } template <class T> inline T decrement(T& t) _NOEXCEPT { - return __sync_add_and_fetch(&t, -1); + return __libcpp_atomic_add(&t, -1, _AO_Acq_Rel); } } // namespace @@ -99,14 +103,13 @@ __shared_weak_count::__release_weak() _NOEXCEPT __shared_weak_count* __shared_weak_count::lock() _NOEXCEPT { - long object_owners = __shared_owners_; + long object_owners = __libcpp_atomic_load(&__shared_owners_); while (object_owners != -1) { - if (__sync_bool_compare_and_swap(&__shared_owners_, - object_owners, - object_owners+1)) + if (__libcpp_atomic_compare_exchange(&__shared_owners_, + &object_owners, + object_owners+1)) return this; - object_owners = __shared_owners_; } return 0; } |