summaryrefslogtreecommitdiffstats
path: root/libcxx/src/include/refstring.h
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/src/include/refstring.h')
-rw-r--r--libcxx/src/include/refstring.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/libcxx/src/include/refstring.h b/libcxx/src/include/refstring.h
index f0d5b4456da..702f2b7388d 100644
--- a/libcxx/src/include/refstring.h
+++ b/libcxx/src/include/refstring.h
@@ -18,6 +18,7 @@
#include <dlfcn.h>
#include <mach-o/dyld.h>
#endif
+#include "atomic_support.h"
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -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_atomic_add(&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_atomic_add(&rep_from_data(__imp_)->count, 1);
if (adjust_old_count)
{
- if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0)
+ if (__libcpp_atomic_add(&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_atomic_add(&rep->count, count_t(-1)) < 0) {
::operator delete(rep);
}
}
OpenPOWER on IntegriCloud