diff options
Diffstat (limited to 'libstdc++-v3/libsupc++/exception_ptr.h')
-rw-r--r-- | libstdc++-v3/libsupc++/exception_ptr.h | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index 783e539764..0ece81d813 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -1,6 +1,6 @@ // Exception Handling support header (exception_ptr class) for -*- C++ -*- -// Copyright (C) 2008-2016 Free Software Foundation, Inc. +// Copyright (C) 2008-2017 Free Software Foundation, Inc. // // This file is part of GCC. // @@ -35,10 +35,9 @@ #include <bits/c++config.h> #include <bits/exception_defines.h> - -#if ATOMIC_INT_LOCK_FREE < 2 -# error This platform does not support exception propagation. -#endif +#include <bits/cxxabi_init_exception.h> +#include <typeinfo> +#include <new> extern "C++" { @@ -63,6 +62,9 @@ namespace std */ exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT; + template<typename _Ex> + exception_ptr make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT; + /// Throw the object pointed to by the exception_ptr. void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__)); @@ -87,6 +89,8 @@ namespace std friend exception_ptr std::current_exception() _GLIBCXX_USE_NOEXCEPT; friend void std::rethrow_exception(exception_ptr); + template<typename _Ex> + friend exception_ptr std::make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT; public: exception_ptr() _GLIBCXX_USE_NOEXCEPT; @@ -162,8 +166,12 @@ namespace std swap(exception_ptr& __lhs, exception_ptr& __rhs) { __lhs.swap(__rhs); } - } // namespace __exception_ptr + template<typename _Ex> + inline void + __dest_thunk(void* __x) + { static_cast<_Ex*>(__x)->~_Ex(); } + } // namespace __exception_ptr /// Obtain an exception_ptr pointing to a copy of the supplied object. template<typename _Ex> @@ -173,7 +181,16 @@ namespace std #if __cpp_exceptions try { - throw __ex; +#if __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI + void *__e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex)); + (void)__cxxabiv1::__cxa_init_primary_exception( + __e, const_cast<std::type_info*>(&typeid(__ex)), + __exception_ptr::__dest_thunk<_Ex>); + ::new (__e) _Ex(__ex); + return exception_ptr(__e); +#else + throw __ex; +#endif } catch(...) { |