[libc++] Refactoring __sync_* builtins; NFC
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 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@307591 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -667,7 +667,7 @@ locale::id::__get()
|
||||
void
|
||||
locale::id::__init()
|
||||
{
|
||||
__id_ = __sync_add_and_fetch(&__next_id, 1);
|
||||
__id_ = __libcpp_sync_add_and_fetch(&__next_id, 1);
|
||||
}
|
||||
|
||||
// template <> class collate_byname<char>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cstdio>
|
||||
#include <__atomic_support>
|
||||
|
||||
namespace std {
|
||||
|
||||
@@ -20,13 +21,13 @@ _LIBCPP_SAFE_STATIC static std::unexpected_handler __unexpected_handler;
|
||||
unexpected_handler
|
||||
set_unexpected(unexpected_handler func) _NOEXCEPT
|
||||
{
|
||||
return __sync_lock_test_and_set(&__unexpected_handler, func);
|
||||
return __libcpp_sync_lock_test_and_set(&__unexpected_handler, func);
|
||||
}
|
||||
|
||||
unexpected_handler
|
||||
get_unexpected() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
|
||||
return __libcpp_sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
|
||||
|
||||
}
|
||||
|
||||
@@ -41,14 +42,13 @@ void unexpected()
|
||||
terminate_handler
|
||||
set_terminate(terminate_handler func) _NOEXCEPT
|
||||
{
|
||||
return __sync_lock_test_and_set(&__terminate_handler, func);
|
||||
return __libcpp_sync_lock_test_and_set(&__terminate_handler, func);
|
||||
}
|
||||
|
||||
terminate_handler
|
||||
get_terminate() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
|
||||
|
||||
return __libcpp_sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__ // We provide this in JS
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <__atomic_support>
|
||||
|
||||
namespace std {
|
||||
|
||||
_LIBCPP_SAFE_STATIC static std::new_handler __new_handler;
|
||||
@@ -15,13 +17,13 @@ _LIBCPP_SAFE_STATIC static std::new_handler __new_handler;
|
||||
new_handler
|
||||
set_new_handler(new_handler handler) _NOEXCEPT
|
||||
{
|
||||
return __sync_lock_test_and_set(&__new_handler, handler);
|
||||
return __libcpp_sync_lock_test_and_set(&__new_handler, handler);
|
||||
}
|
||||
|
||||
new_handler
|
||||
get_new_handler() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__new_handler, nullptr);
|
||||
return __libcpp_sync_fetch_and_add<new_handler>(&__new_handler, nullptr);
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
Reference in New Issue
Block a user