diff options
Diffstat (limited to 'libcxx/src/new.cpp')
-rw-r--r-- | libcxx/src/new.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
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() |