Revert "[libc++] Refactoring __sync_* builtins; NFC (Reland)"

This reverts commit r307595. The commit had some issues that needed
to first be addressed in review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@307746 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2017-07-12 01:16:33 +00:00
parent 347be61138
commit d60e344b70
5 changed files with 12 additions and 47 deletions

View File

@@ -14,7 +14,6 @@
#include <stdexcept>
#include <cstddef>
#include <cstring>
#include <__atomic_support>
#ifdef __APPLE__
#include <dlfcn.h>
#include <mach-o/dyld.h>
@@ -84,7 +83,7 @@ __libcpp_refstring::__libcpp_refstring(const __libcpp_refstring &s) _NOEXCEPT
: __imp_(s.__imp_)
{
if (__uses_refcount())
__libcpp_sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
__sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
}
inline
@@ -93,10 +92,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())
__libcpp_sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
__sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
if (adjust_old_count)
{
if (__libcpp_sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0)
if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0)
{
::operator delete(old_rep);
}
@@ -108,7 +107,7 @@ inline
__libcpp_refstring::~__libcpp_refstring() {
if (__uses_refcount()) {
_Rep_base* rep = rep_from_data(__imp_);
if (__libcpp_sync_add_and_fetch(&rep->count, count_t(-1)) < 0) {
if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0) {
::operator delete(rep);
}
}