diff options
Diffstat (limited to 'libstdc++-v3/libsupc++/eh_throw.cc')
-rw-r--r-- | libstdc++-v3/libsupc++/eh_throw.cc | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/libstdc++-v3/libsupc++/eh_throw.cc b/libstdc++-v3/libsupc++/eh_throw.cc index 9aac218527..13428d92da 100644 --- a/libstdc++-v3/libsupc++/eh_throw.cc +++ b/libstdc++-v3/libsupc++/eh_throw.cc @@ -1,5 +1,5 @@ // -*- C++ -*- Exception handling routines for throwing. -// Copyright (C) 2001-2016 Free Software Foundation, Inc. +// Copyright (C) 2001-2017 Free Software Foundation, Inc. // // This file is part of GCC. // @@ -24,6 +24,7 @@ #include <bits/c++config.h> #include "unwind-cxx.h" +#include "eh_atomics.h" using namespace __cxxabiv1; @@ -42,19 +43,31 @@ __gxx_exception_cleanup (_Unwind_Reason_Code code, _Unwind_Exception *exc) if (code != _URC_FOREIGN_EXCEPTION_CAUGHT && code != _URC_NO_REASON) __terminate (header->exc.terminateHandler); -#if ATOMIC_INT_LOCK_FREE > 1 - if (__atomic_sub_fetch (&header->referenceCount, 1, __ATOMIC_ACQ_REL) == 0) + if (__gnu_cxx::__eh_atomic_dec (&header->referenceCount)) { -#endif if (header->exc.exceptionDestructor) header->exc.exceptionDestructor (header + 1); __cxa_free_exception (header + 1); -#if ATOMIC_INT_LOCK_FREE > 1 } -#endif } +extern "C" __cxa_refcounted_exception* +__cxxabiv1::__cxa_init_primary_exception(void *obj, std::type_info *tinfo, + void (_GLIBCXX_CDTOR_CALLABI *dest) (void *)) +{ + __cxa_refcounted_exception *header + = __get_refcounted_exception_header_from_obj (obj); + header->referenceCount = 0; + header->exc.exceptionType = tinfo; + header->exc.exceptionDestructor = dest; + 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; + + return header; +} extern "C" void __cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo, @@ -64,17 +77,10 @@ __cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo, __cxa_eh_globals *globals = __cxa_get_globals (); globals->uncaughtExceptions += 1; - // Definitely a primary. - __cxa_refcounted_exception *header - = __get_refcounted_exception_header_from_obj (obj); + __cxa_refcounted_exception *header = + __cxa_init_primary_exception(obj, tinfo, dest); header->referenceCount = 1; - header->exc.exceptionType = tinfo; - header->exc.exceptionDestructor = dest; - 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; #ifdef __USING_SJLJ_EXCEPTIONS__ _Unwind_SjLj_RaiseException (&header->exc.unwindHeader); |