diff options
Diffstat (limited to 'libcxx/src')
-rw-r--r-- | libcxx/src/exception.cpp | 20 | ||||
-rw-r--r-- | libcxx/src/new.cpp | 10 |
2 files changed, 21 insertions, 9 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 diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp index 874ad6c0230..a3783d47efa 100644 --- a/libcxx/src/new.cpp +++ b/libcxx/src/new.cpp @@ -130,9 +130,13 @@ const nothrow_t nothrow = {}; new_handler set_new_handler(new_handler handler) throw() { - new_handler r = __new_handler; - __new_handler = handler; - return r; + return __sync_lock_test_and_set(&__new_handler, handler); +} + +new_handler +get_new_handler() throw() +{ + return __sync_fetch_and_add(&__new_handler, (new_handler)0); } bad_alloc::bad_alloc() throw() |