<div dir="ltr">Howard, it looks like you're the one that added the commented out behavior, and your commit said that you "could not yet do that". Any update?<div><br></div><div>- Dan</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, May 6, 2014 at 3:35 PM, Dan Albert <span dir="ltr"><<a href="mailto:danalbert@google.com" target="_blank">danalbert@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra">I don't know if these were left commented out because they don't work on some platforms, but they work on OS X. Were they left commented out because they had been forgotten?</div>
<span><font color="#888888">
<div class="gmail_extra"><br></div><div class="gmail_extra">- Dan</div></font></span><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 6, 2014 at 3:32 PM, Dan Albert <span dir="ltr"><<a href="mailto:danalbert@google.com" target="_blank">danalbert@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The commented out regions mentioning this worked as is.<br>
---<br>
src/cxa_default_handlers.cpp | 16 ++++------------<br>
src/cxa_handlers.cpp | 23 +++++------------------<br>
src/cxa_handlers.hpp | 27 +++++----------------------<br>
3 files changed, 14 insertions(+), 52 deletions(-)<br>
<br>
diff --git a/src/cxa_default_handlers.cpp b/src/cxa_default_handlers.cpp<br>
index 27ffb71..6a48cd9 100644<br>
--- a/src/cxa_default_handlers.cpp<br>
+++ b/src/cxa_default_handlers.cpp<br>
@@ -87,12 +87,8 @@ static void default_unexpected_handler()<br>
//<br>
// Global variables that hold the pointers to the current handler<br>
//<br>
-std::terminate_handler __cxa_terminate_handler = default_terminate_handler;<br>
-std::unexpected_handler __cxa_unexpected_handler = default_unexpected_handler;<br>
-<br>
-// In the future these will become:<br>
-// std::atomic<std::terminate_handler> __cxa_terminate_handler(default_terminate_handler);<br>
-// std::atomic<std::unexpected_handler> __cxa_unexpected_handler(default_unexpected_handler);<br>
+std::atomic<std::terminate_handler> __cxa_terminate_handler(default_terminate_handler);<br>
+std::atomic<std::unexpected_handler> __cxa_unexpected_handler(default_unexpected_handler);<br>
<br>
namespace std<br>
{<br>
@@ -102,9 +98,7 @@ set_unexpected(unexpected_handler func) _NOEXCEPT<br>
{<br>
if (func == 0)<br>
func = default_unexpected_handler;<br>
- return __sync_swap(&__cxa_unexpected_handler, func);<br>
-// Using of C++11 atomics this should be rewritten<br>
-// return __cxa_unexpected_handler.exchange(func, memory_order_acq_rel);<br>
+ return __cxa_unexpected_handler.exchange(func, memory_order_acq_rel);<br>
}<br>
<br>
terminate_handler<br>
@@ -112,9 +106,7 @@ set_terminate(terminate_handler func) _NOEXCEPT<br>
{<br>
if (func == 0)<br>
func = default_terminate_handler;<br>
- return __sync_swap(&__cxa_terminate_handler, func);<br>
-// Using of C++11 atomics this should be rewritten<br>
-// return __cxa_terminate_handler.exchange(func, memory_order_acq_rel);<br>
+ return __cxa_terminate_handler.exchange(func, memory_order_acq_rel);<br>
}<br>
<br>
}<br>
diff --git a/src/cxa_handlers.cpp b/src/cxa_handlers.cpp<br>
index 6c13fcd..2d1682e 100644<br>
--- a/src/cxa_handlers.cpp<br>
+++ b/src/cxa_handlers.cpp<br>
@@ -25,10 +25,7 @@ namespace std<br>
unexpected_handler<br>
get_unexpected() _NOEXCEPT<br>
{<br>
- return __sync_fetch_and_add(&__cxa_unexpected_handler, (unexpected_handler)0);<br>
-// The above is safe but overkill on x86<br>
-// Using of C++11 atomics this should be rewritten<br>
-// return __cxa_unexpected_handler.load(memory_order_acq);<br>
+ return __cxa_unexpected_handler.load(memory_order_acquire);<br>
}<br>
<br>
__attribute__((visibility("hidden"), noreturn))<br>
@@ -50,10 +47,7 @@ unexpected()<br>
terminate_handler<br>
get_terminate() _NOEXCEPT<br>
{<br>
- return __sync_fetch_and_add(&__cxa_terminate_handler, (terminate_handler)0);<br>
-// The above is safe but overkill on x86<br>
-// Using of C++11 atomics this should be rewritten<br>
-// return __cxa_terminate_handler.load(memory_order_acq);<br>
+ return __cxa_terminate_handler.load(memory_order_acquire);<br>
}<br>
<br>
__attribute__((visibility("hidden"), noreturn))<br>
@@ -101,25 +95,18 @@ terminate() _NOEXCEPT<br>
__terminate(get_terminate());<br>
}<br>
<br>
-extern "C" new_handler __cxa_new_handler = 0;<br>
-// In the future these will become:<br>
-// std::atomic<std::new_handler> __cxa_new_handler(0);<br>
+std::atomic<std::new_handler> __cxa_new_handler(0);<br>
<br>
new_handler<br>
set_new_handler(new_handler handler) _NOEXCEPT<br>
{<br>
- return __sync_swap(&__cxa_new_handler, handler);<br>
-// Using of C++11 atomics this should be rewritten<br>
-// return __cxa_new_handler.exchange(handler, memory_order_acq_rel);<br>
+ return __cxa_new_handler.exchange(handler, memory_order_acq_rel);<br>
}<br>
<br>
new_handler<br>
get_new_handler() _NOEXCEPT<br>
{<br>
- return __sync_fetch_and_add(&__cxa_new_handler, (new_handler)0);<br>
-// The above is safe but overkill on x86<br>
-// Using of C++11 atomics this should be rewritten<br>
-// return __cxa_new_handler.load(memory_order_acq);<br>
+ return __cxa_new_handler.load(memory_order_acquire);<br>
}<br>
<br>
} // std<br>
diff --git a/src/cxa_handlers.hpp b/src/cxa_handlers.hpp<br>
index ce567ec..23669fe 100644<br>
--- a/src/cxa_handlers.hpp<br>
+++ b/src/cxa_handlers.hpp<br>
@@ -13,7 +13,9 @@<br>
#ifndef _CXA_HANDLERS_H<br>
#define _CXA_HANDLERS_H<br>
<br>
+#include <atomic><br>
#include <exception><br>
+#include <new><br>
<br>
namespace std<br>
{<br>
@@ -28,27 +30,8 @@ __terminate(terminate_handler func) _NOEXCEPT;<br>
<br>
} // std<br>
<br>
-extern "C"<br>
-{<br>
-<br>
-extern void (*__cxa_terminate_handler)();<br>
-extern void (*__cxa_unexpected_handler)();<br>
-extern void (*__cxa_new_handler)();<br>
-<br>
-/*<br>
-<br>
- At some point in the future these three symbols will become<br>
- C++11 atomic variables:<br>
-<br>
- extern std::atomic<std::terminate_handler> __cxa_terminate_handler;<br>
- extern std::atomic<std::unexpected_handler> __cxa_unexpected_handler;<br>
- extern std::atomic<std::new_handler> __cxa_new_handler;<br>
-<br>
- This change will not impact their ABI. But it will allow for a<br>
- portable performance optimization.<br>
-<br>
-*/<br>
-<br>
-} // extern "C"<br>
+extern std::atomic<std::terminate_handler> __cxa_terminate_handler;<br>
+extern std::atomic<std::unexpected_handler> __cxa_unexpected_handler;<br>
+extern std::atomic<std::new_handler> __cxa_new_handler;<br>
<br>
#endif // _CXA_HANDLERS_H<br>
<span><font color="#888888">--<br>
1.9.2<br>
<br>
</font></span></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div>