diff options
author | Weiming Zhao <weimingz@codeaurora.org> | 2017-07-10 21:37:35 +0000 |
---|---|---|
committer | Weiming Zhao <weimingz@codeaurora.org> | 2017-07-10 21:37:35 +0000 |
commit | f7850fa8b64d56e688543414d02bca3b1f1c9364 (patch) | |
tree | a79a2fca79998e29c71739af0126dfad64431bac /libcxx/include/__refstring | |
parent | 50daf5fbbb9d6ef03fdf6af44c71e2c7ee4a2edf (diff) | |
download | bcm5719-llvm-f7850fa8b64d56e688543414d02bca3b1f1c9364.tar.gz bcm5719-llvm-f7850fa8b64d56e688543414d02bca3b1f1c9364.zip |
[libc++] Refactoring __sync_* builtins; NFC (Reland)
Summary: Wrap __sync_* builtins with __libcpp_ functions to facility future customizations as atomic operations are unavailable on some targets.
Reviewers: danalbert, EricWF, jroelofs
Subscribers: joerg, llvm-commits
Differential Revision: https://reviews.llvm.org/D34918
llvm-svn: 307595
Diffstat (limited to 'libcxx/include/__refstring')
-rw-r--r-- | libcxx/include/__refstring | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libcxx/include/__refstring b/libcxx/include/__refstring index 7f417a03c49..de89b79a4b9 100644 --- a/libcxx/include/__refstring +++ b/libcxx/include/__refstring @@ -14,6 +14,7 @@ #include <stdexcept> #include <cstddef> #include <cstring> +#include <__atomic_support> #ifdef __APPLE__ #include <dlfcn.h> #include <mach-o/dyld.h> @@ -83,7 +84,7 @@ __libcpp_refstring::__libcpp_refstring(const __libcpp_refstring &s) _NOEXCEPT : __imp_(s.__imp_) { if (__uses_refcount()) - __sync_add_and_fetch(&rep_from_data(__imp_)->count, 1); + __libcpp_sync_add_and_fetch(&rep_from_data(__imp_)->count, 1); } inline @@ -92,10 +93,10 @@ __libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) _ struct _Rep_base *old_rep = rep_from_data(__imp_); __imp_ = s.__imp_; if (__uses_refcount()) - __sync_add_and_fetch(&rep_from_data(__imp_)->count, 1); + __libcpp_sync_add_and_fetch(&rep_from_data(__imp_)->count, 1); if (adjust_old_count) { - if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0) + if (__libcpp_sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0) { ::operator delete(old_rep); } @@ -107,7 +108,7 @@ inline __libcpp_refstring::~__libcpp_refstring() { if (__uses_refcount()) { _Rep_base* rep = rep_from_data(__imp_); - if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0) { + if (__libcpp_sync_add_and_fetch(&rep->count, count_t(-1)) < 0) { ::operator delete(rep); } } |