summaryrefslogtreecommitdiffstats
path: root/libcxx/src/support/runtime
diff options
context:
space:
mode:
authorWeiming Zhao <weimingz@codeaurora.org>2017-07-10 21:02:54 +0000
committerWeiming Zhao <weimingz@codeaurora.org>2017-07-10 21:02:54 +0000
commit07f6efddc037558f014b13ab0b6ff6669c8d5f4d (patch)
treec28c5e68f3d926fb6d8eb1c4c0b4d8e85c285073 /libcxx/src/support/runtime
parent6708e0b45eee7518d6662e216348efab1f30d0ea (diff)
downloadbcm5719-llvm-07f6efddc037558f014b13ab0b6ff6669c8d5f4d.tar.gz
bcm5719-llvm-07f6efddc037558f014b13ab0b6ff6669c8d5f4d.zip
[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 llvm-svn: 307591
Diffstat (limited to 'libcxx/src/support/runtime')
-rw-r--r--libcxx/src/support/runtime/exception_fallback.ipp10
-rw-r--r--libcxx/src/support/runtime/new_handler_fallback.ipp6
2 files changed, 9 insertions, 7 deletions
diff --git a/libcxx/src/support/runtime/exception_fallback.ipp b/libcxx/src/support/runtime/exception_fallback.ipp
index 69c06a9ce3a..cdf008afef7 100644
--- a/libcxx/src/support/runtime/exception_fallback.ipp
+++ b/libcxx/src/support/runtime/exception_fallback.ipp
@@ -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
diff --git a/libcxx/src/support/runtime/new_handler_fallback.ipp b/libcxx/src/support/runtime/new_handler_fallback.ipp
index b7092d542d9..75f985d3914 100644
--- a/libcxx/src/support/runtime/new_handler_fallback.ipp
+++ b/libcxx/src/support/runtime/new_handler_fallback.ipp
@@ -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
OpenPOWER on IntegriCloud