[libc++] Replace __sync_* functions with __libcpp_atomic_* functions
Summary:
This patch replaces __sync_* with __libcpp_atomic_* and adds a wrapper
function for __atomic_exchange to support _LIBCPP_HAS_NO_THREADS.
Reviewers: EricWF, jroelofs, mclow.lists, compnerd
Reviewed By: EricWF, compnerd
Subscribers: compnerd, efriedma, cfe-commits, joerg, llvm-commits
Differential Revision: https://reviews.llvm.org/D35235
llvm-svn: 313694
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: fbfaec7089b8bfc1e3ef91dfbc50b4b7cf7a79e7
diff --git a/src/locale.cpp b/src/locale.cpp
index 3b4c83a..a6cb0e9 100644
--- a/src/locale.cpp
+++ b/src/locale.cpp
@@ -36,6 +36,7 @@
#endif
#include <stdlib.h>
#include <stdio.h>
+#include "include/atomic_support.h"
#include "__undef_macros"
// On Linux, wint_t and wchar_t have different signed-ness, and this causes
@@ -667,7 +668,7 @@
void
locale::id::__init()
{
- __id_ = __sync_add_and_fetch(&__next_id, 1);
+ __id_ = __libcpp_atomic_add(&__next_id, 1);
}
// template <> class collate_byname<char>