* libsupc++/eh_ptr.cc (rethrow_exception): Use get_unexpected() and
get_terminate() accessors.
* libsupc++/eh_throw.cc (__cxa_throw): Likewise.
* libsupc++/eh_terminate.cc: Use mutex when atomic builtins not
available.
* libsupc++/new_handler.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@197512
138bc75d-0d04-0410-961f-
82ee72b054a4
+2013-04-05 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ PR libstdc++/56841
+ * libsupc++/eh_ptr.cc (rethrow_exception): Use get_unexpected() and
+ get_terminate() accessors.
+ * libsupc++/eh_throw.cc (__cxa_throw): Likewise.
+ * libsupc++/eh_terminate.cc: Use mutex when atomic builtins not
+ available.
+ * libsupc++/new_handler.cc: Likewise.
+
2013-04-04 Jonathan Wakely <jwakely.gcc@gmail.com>
* testsuite/util/testsuite_abi.cc: Add GLIBCXX_3.4.19 version.
dep->primaryException = obj;
__atomic_add_fetch (&eh->referenceCount, 1, __ATOMIC_ACQ_REL);
- dep->unexpectedHandler = __unexpected_handler;
- dep->terminateHandler = __terminate_handler;
+ dep->unexpectedHandler = get_unexpected ();
+ dep->terminateHandler = get_terminate ();
__GXX_INIT_DEPENDENT_EXCEPTION_CLASS(dep->unwindHeader.exception_class);
dep->unwindHeader.exception_cleanup = __gxx_dependent_exception_cleanup;
#include <cstdlib>
#include "unwind-cxx.h"
#include <bits/exception_defines.h>
+#include <bits/atomic_lockfree_defines.h>
+
+#if ATOMIC_POINTER_LOCK_FREE < 2
+#include <ext/concurrence.h>
+namespace
+{
+ __gnu_cxx::__mutex mx;
+}
+#endif
using namespace __cxxabiv1;
std::set_terminate (std::terminate_handler func) throw()
{
std::terminate_handler old;
+#if ATOMIC_POINTER_LOCK_FREE > 1
__atomic_exchange (&__terminate_handler, &func, &old, __ATOMIC_ACQ_REL);
+#else
+ __gnu_cxx::__scoped_lock l(mx);
+ old = __terminate_handler;
+ __terminate_handler = func;
+#endif
return old;
}
std::get_terminate () noexcept
{
std::terminate_handler func;
+#if ATOMIC_POINTER_LOCK_FREE > 1
__atomic_load (&__terminate_handler, &func, __ATOMIC_ACQUIRE);
+#else
+ __gnu_cxx::__scoped_lock l(mx);
+ func = __terminate_handler;
+#endif
return func;
}
std::set_unexpected (std::unexpected_handler func) throw()
{
std::unexpected_handler old;
+#if ATOMIC_POINTER_LOCK_FREE > 1
__atomic_exchange (&__unexpected_handler, &func, &old, __ATOMIC_ACQ_REL);
+#else
+ __gnu_cxx::__scoped_lock l(mx);
+ old = __unexpected_handler;
+ __unexpected_handler = func;
+#endif
return old;
}
std::get_unexpected () noexcept
{
std::unexpected_handler func;
+#if ATOMIC_POINTER_LOCK_FREE > 1
__atomic_load (&__unexpected_handler, &func, __ATOMIC_ACQUIRE);
+#else
+ __gnu_cxx::__scoped_lock l(mx);
+ func = __unexpected_handler;
+#endif
return func;
}
header->referenceCount = 1;
header->exc.exceptionType = tinfo;
header->exc.exceptionDestructor = dest;
- header->exc.unexpectedHandler = __unexpected_handler;
- header->exc.terminateHandler = __terminate_handler;
+ header->exc.unexpectedHandler = std::get_unexpected ();
+ header->exc.terminateHandler = std::get_terminate ();
__GXX_INIT_PRIMARY_EXCEPTION_CLASS(header->exc.unwindHeader.exception_class);
header->exc.unwindHeader.exception_cleanup = __gxx_exception_cleanup;
// <http://www.gnu.org/licenses/>.
#include "new"
+#include <bits/atomic_lockfree_defines.h>
+
+#if ATOMIC_POINTER_LOCK_FREE < 2
+#include <ext/concurrence.h>
+namespace
+{
+ __gnu_cxx::__mutex mx;
+}
+#endif
const std::nothrow_t std::nothrow = { };
std::set_new_handler (new_handler handler) throw()
{
new_handler prev_handler;
+#if ATOMIC_POINTER_LOCK_FREE > 1
__atomic_exchange (&__new_handler, &handler, &prev_handler,
__ATOMIC_ACQ_REL);
+#else
+ __gnu_cxx::__scoped_lock l(mx);
+ prev_handler = __new_handler;
+ __new_handler = handler;
+#endif
return prev_handler;
}
std::get_new_handler () noexcept
{
new_handler handler;
+#if ATOMIC_POINTER_LOCK_FREE > 1
__atomic_load (&__new_handler, &handler, __ATOMIC_ACQUIRE);
+#else
+ __gnu_cxx::__scoped_lock l(mx);
+ handler = __new_handler;
+#endif
return handler;
}