diff options
author | Weiming Zhao <weimingz@codeaurora.org> | 2017-09-19 23:18:03 +0000 |
---|---|---|
committer | Weiming Zhao <weimingz@codeaurora.org> | 2017-09-19 23:18:03 +0000 |
commit | fbfaec7089b8bfc1e3ef91dfbc50b4b7cf7a79e7 (patch) | |
tree | bf88e3f6fae85e9cc9fec9db4f23ba229b229997 /libcxx/src/support | |
parent | 3ac802a1f65f71c739f58c2f49ee967e99ba3170 (diff) | |
download | bcm5719-llvm-fbfaec7089b8bfc1e3ef91dfbc50b4b7cf7a79e7.tar.gz bcm5719-llvm-fbfaec7089b8bfc1e3ef91dfbc50b4b7cf7a79e7.zip |
[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
Diffstat (limited to 'libcxx/src/support')
-rw-r--r-- | libcxx/src/support/runtime/exception_fallback.ipp | 9 | ||||
-rw-r--r-- | libcxx/src/support/runtime/new_handler_fallback.ipp | 4 |
2 files changed, 6 insertions, 7 deletions
diff --git a/libcxx/src/support/runtime/exception_fallback.ipp b/libcxx/src/support/runtime/exception_fallback.ipp index 69c06a9ce3a..664e7f48c09 100644 --- a/libcxx/src/support/runtime/exception_fallback.ipp +++ b/libcxx/src/support/runtime/exception_fallback.ipp @@ -20,13 +20,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_atomic_exchange(&__unexpected_handler, func); } unexpected_handler get_unexpected() _NOEXCEPT { - return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0); + return __libcpp_atomic_load(&__unexpected_handler); } @@ -41,14 +41,13 @@ void unexpected() terminate_handler set_terminate(terminate_handler func) _NOEXCEPT { - return __sync_lock_test_and_set(&__terminate_handler, func); + return __libcpp_atomic_exchange(&__terminate_handler, func); } terminate_handler get_terminate() _NOEXCEPT { - return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0); - + return __libcpp_atomic_load(&__terminate_handler); } #ifndef __EMSCRIPTEN__ // We provide this in JS diff --git a/libcxx/src/support/runtime/new_handler_fallback.ipp b/libcxx/src/support/runtime/new_handler_fallback.ipp index b7092d542d9..ec3f52354ca 100644 --- a/libcxx/src/support/runtime/new_handler_fallback.ipp +++ b/libcxx/src/support/runtime/new_handler_fallback.ipp @@ -15,13 +15,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_atomic_exchange(&__new_handler, handler); } new_handler get_new_handler() _NOEXCEPT { - return __sync_fetch_and_add(&__new_handler, nullptr); + return __libcpp_atomic_load(&__new_handler); } } // namespace std |