[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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@313694 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Weiming Zhao
2017-09-19 23:18:03 +00:00
parent 7a87049e47
commit bc4474e3ba
7 changed files with 34 additions and 12 deletions

View File

@@ -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 @@ locale::id::__get()
void
locale::id::__init()
{
__id_ = __sync_add_and_fetch(&__next_id, 1);
__id_ = __libcpp_atomic_add(&__next_id, 1);
}
// template <> class collate_byname<char>