diff options
Diffstat (limited to 'libcxx/src/exception.cpp')
-rw-r--r-- | libcxx/src/exception.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libcxx/src/exception.cpp b/libcxx/src/exception.cpp index 1ab5a19520c..062114c251f 100644 --- a/libcxx/src/exception.cpp +++ b/libcxx/src/exception.cpp @@ -26,9 +26,13 @@ std::unexpected_handler std::set_unexpected(std::unexpected_handler func) throw() { - std::terminate_handler old = __unexpected_handler; - __unexpected_handler = func; - return old; + return __sync_lock_test_and_set(&__unexpected_handler, func); +} + +std::unexpected_handler +std::get_unexpected() throw() +{ + return __sync_fetch_and_add(&__unexpected_handler, (std::unexpected_handler)0); } void @@ -42,9 +46,13 @@ std::unexpected() std::terminate_handler std::set_terminate(std::terminate_handler func) throw() { - std::terminate_handler old = __terminate_handler; - __terminate_handler = func; - return old; + return __sync_lock_test_and_set(&__terminate_handler, func); +} + +std::terminate_handler +std::get_terminate() throw() +{ + return __sync_fetch_and_add(&__terminate_handler, (std::terminate_handler)0); } void |