From 1596c4531b3950f4c883013cb51182ad40884633 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 2 Dec 2010 16:45:21 +0000 Subject: N3189 Observers for the three handler functions llvm-svn: 120712 --- libcxx/src/new.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libcxx/src/new.cpp') 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() -- cgit v1.2.3