]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/56841 (ld: Unsatisfied symbol "__atomic_exchange_8" in file /test...
authorJonathan Wakely <jwakely.gcc@gmail.com>
Fri, 5 Apr 2013 10:03:04 +0000 (10:03 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 5 Apr 2013 10:03:04 +0000 (11:03 +0100)
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.

From-SVN: r197512

libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/eh_ptr.cc
libstdc++-v3/libsupc++/eh_terminate.cc
libstdc++-v3/libsupc++/eh_throw.cc
libstdc++-v3/libsupc++/new_handler.cc

index 2536dfb181b7da971929dc03fd720ac63c97c10e..bbd285c4069c2bbd4016c4614ea288f776b31a05 100644 (file)
@@ -1,3 +1,13 @@
+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.
index f0183cee726c177477d850c172d7f44292efd476..6bc3311020c877dd758517965ad82b307e43acb4 100644 (file)
@@ -212,8 +212,8 @@ std::rethrow_exception(std::exception_ptr ep)
   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;
 
index bc38e1d201d2627895c4591fb2264b89bbe677f7..b31d2e27f05d25d542f3efb9a016c848de4a4c27 100644 (file)
 #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;
 
@@ -65,7 +74,13 @@ std::terminate_handler
 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;
 }
 
@@ -73,7 +88,12 @@ std::terminate_handler
 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;
 }
 
@@ -81,7 +101,13 @@ std::unexpected_handler
 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;
 }
 
@@ -89,6 +115,11 @@ std::unexpected_handler
 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;
 }
index a79a025af19366f620fbd58f56700e82cfe26044..5d376983215d120d9bd54c5280224a461500cfc1 100644 (file)
@@ -68,8 +68,8 @@ __cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo,
   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;
 
index 2f6bb5e46c196391cba28a248760fb82a69c42b6..5253cfda7a0aeb5f750ccc5cb21e170726f114b8 100644 (file)
 // <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 = { };
 
@@ -37,8 +46,14 @@ new_handler
 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;
 }
 
@@ -46,6 +61,11 @@ new_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;
 }