Index: libcxxabi/trunk/src/cxa_default_handlers.cpp =================================================================== --- libcxxabi/trunk/src/cxa_default_handlers.cpp +++ libcxxabi/trunk/src/cxa_default_handlers.cpp @@ -101,9 +101,10 @@ unexpected_handler set_unexpected(unexpected_handler func) _NOEXCEPT { - if (func == 0) - func = default_unexpected_handler; - return __sync_swap(&__cxa_unexpected_handler, func); + if (func == 0) + func = default_unexpected_handler; + return __atomic_exchange_n(&__cxa_unexpected_handler, func, + __ATOMIC_ACQ_REL); // Using of C++11 atomics this should be rewritten // return __cxa_unexpected_handler.exchange(func, memory_order_acq_rel); } @@ -111,9 +112,10 @@ terminate_handler set_terminate(terminate_handler func) _NOEXCEPT { - if (func == 0) - func = default_terminate_handler; - return __sync_swap(&__cxa_terminate_handler, func); + if (func == 0) + func = default_terminate_handler; + return __atomic_exchange_n(&__cxa_terminate_handler, func, + __ATOMIC_ACQ_REL); // Using of C++11 atomics this should be rewritten // return __cxa_terminate_handler.exchange(func, memory_order_acq_rel); } Index: libcxxabi/trunk/src/cxa_handlers.cpp =================================================================== --- libcxxabi/trunk/src/cxa_handlers.cpp +++ libcxxabi/trunk/src/cxa_handlers.cpp @@ -102,14 +102,14 @@ __terminate(get_terminate()); } -extern "C" new_handler __cxa_new_handler = 0; +new_handler __cxa_new_handler = 0; // In the future these will become: // std::atomic __cxa_new_handler(0); new_handler set_new_handler(new_handler handler) _NOEXCEPT { - return __sync_swap(&__cxa_new_handler, handler); + return __atomic_exchange_n(&__cxa_new_handler, handler, __ATOMIC_ACQ_REL); // Using of C++11 atomics this should be rewritten // return __cxa_new_handler.exchange(handler, memory_order_acq_rel); }