Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 1 | //===------------------------ exception.cpp -------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | #include <stdlib.h> |
Howard Hinnant | ed14a76 | 2013-07-23 16:05:56 +0000 | [diff] [blame] | 10 | #include <stdio.h> |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 11 | |
| 12 | #include "exception" |
| 13 | |
Richard Smith | 591e32d | 2012-07-11 09:35:47 +0000 | [diff] [blame] | 14 | #ifndef __has_include |
| 15 | #define __has_include(inc) 0 |
| 16 | #endif |
| 17 | |
Marshall Clow | dece7fe | 2013-03-18 17:45:34 +0000 | [diff] [blame] | 18 | #ifdef __APPLE__ |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 19 | #include <cxxabi.h> |
Howard Hinnant | dea7f39 | 2012-02-02 20:48:35 +0000 | [diff] [blame] | 20 | |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 21 | using namespace __cxxabiv1; |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 22 | #define HAVE_DEPENDENT_EH_ABI 1 |
Howard Hinnant | dea7f39 | 2012-02-02 20:48:35 +0000 | [diff] [blame] | 23 | #ifndef _LIBCPPABI_VERSION |
| 24 | using namespace __cxxabiapple; |
| 25 | // On Darwin, there are two STL shared libraries and a lower level ABI |
| 26 | // shared libray. The globals holding the current terminate handler and |
| 27 | // current unexpected handler are in the ABI library. |
| 28 | #define __terminate_handler __cxxabiapple::__cxa_terminate_handler |
| 29 | #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler |
| 30 | #endif // _LIBCPPABI_VERSION |
Richard Smith | 591e32d | 2012-07-11 09:35:47 +0000 | [diff] [blame] | 31 | #elif defined(LIBCXXRT) || __has_include(<cxxabi.h>) |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 32 | #include <cxxabi.h> |
| 33 | using namespace __cxxabiv1; |
Richard Smith | 591e32d | 2012-07-11 09:35:47 +0000 | [diff] [blame] | 34 | #if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION) |
| 35 | #define HAVE_DEPENDENT_EH_ABI 1 |
| 36 | #endif |
Howard Hinnant | e0f0bfb | 2013-01-22 14:48:10 +0000 | [diff] [blame] | 37 | #elif !defined(__GLIBCXX__) // __has_include(<cxxabi.h>) |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 38 | static std::terminate_handler __terminate_handler; |
| 39 | static std::unexpected_handler __unexpected_handler; |
Richard Smith | 591e32d | 2012-07-11 09:35:47 +0000 | [diff] [blame] | 40 | #endif // __has_include(<cxxabi.h>) |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 41 | |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 42 | namespace std |
| 43 | { |
| 44 | |
Michael J. Spencer | a358fbe | 2012-11-30 21:02:29 +0000 | [diff] [blame] | 45 | #if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) |
Howard Hinnant | dea7f39 | 2012-02-02 20:48:35 +0000 | [diff] [blame] | 46 | |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 47 | // libcxxrt provides implementations of these functions itself. |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 48 | unexpected_handler |
| 49 | set_unexpected(unexpected_handler func) _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 50 | { |
Howard Hinnant | a445151 | 2010-12-02 16:45:21 +0000 | [diff] [blame] | 51 | return __sync_lock_test_and_set(&__unexpected_handler, func); |
| 52 | } |
| 53 | |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 54 | unexpected_handler |
| 55 | get_unexpected() _NOEXCEPT |
Howard Hinnant | a445151 | 2010-12-02 16:45:21 +0000 | [diff] [blame] | 56 | { |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 57 | return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0); |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Richard Smith | 0405cc4 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 60 | _LIBCPP_NORETURN |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 61 | void |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 62 | unexpected() |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 63 | { |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 64 | (*get_unexpected())(); |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 65 | // unexpected handler should not return |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 66 | terminate(); |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 67 | } |
| 68 | |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 69 | terminate_handler |
| 70 | set_terminate(terminate_handler func) _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 71 | { |
Howard Hinnant | a445151 | 2010-12-02 16:45:21 +0000 | [diff] [blame] | 72 | return __sync_lock_test_and_set(&__terminate_handler, func); |
| 73 | } |
| 74 | |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 75 | terminate_handler |
| 76 | get_terminate() _NOEXCEPT |
Howard Hinnant | a445151 | 2010-12-02 16:45:21 +0000 | [diff] [blame] | 77 | { |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 78 | return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0); |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Howard Hinnant | fc2f021 | 2013-03-29 18:27:28 +0000 | [diff] [blame] | 81 | #ifndef EMSCRIPTEN // We provide this in JS |
Richard Smith | 0405cc4 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 82 | _LIBCPP_NORETURN |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 83 | void |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 84 | terminate() _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 85 | { |
Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 86 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 87 | try |
| 88 | { |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 89 | #endif // _LIBCPP_NO_EXCEPTIONS |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 90 | (*get_terminate())(); |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 91 | // handler should not return |
Howard Hinnant | ed14a76 | 2013-07-23 16:05:56 +0000 | [diff] [blame] | 92 | printf("terminate_handler unexpectedly returned\n"); |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 93 | ::abort (); |
Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 94 | #ifndef _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 95 | } |
Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 96 | catch (...) |
| 97 | { |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 98 | // handler should not throw exception |
Howard Hinnant | ed14a76 | 2013-07-23 16:05:56 +0000 | [diff] [blame] | 99 | printf("terminate_handler unexpectedly threw an exception\n"); |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 100 | ::abort (); |
| 101 | } |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 102 | #endif // _LIBCPP_NO_EXCEPTIONS |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 103 | } |
Howard Hinnant | fc2f021 | 2013-03-29 18:27:28 +0000 | [diff] [blame] | 104 | #endif // !EMSCRIPTEN |
Howard Hinnant | dea7f39 | 2012-02-02 20:48:35 +0000 | [diff] [blame] | 105 | #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 106 | |
Howard Hinnant | fc2f021 | 2013-03-29 18:27:28 +0000 | [diff] [blame] | 107 | #if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(EMSCRIPTEN) |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 108 | bool uncaught_exception() _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 109 | { |
Marshall Clow | dece7fe | 2013-03-18 17:45:34 +0000 | [diff] [blame] | 110 | #if defined(__APPLE__) || defined(_LIBCPPABI_VERSION) |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 111 | // on Darwin, there is a helper function so __cxa_get_globals is private |
Howard Hinnant | dea7f39 | 2012-02-02 20:48:35 +0000 | [diff] [blame] | 112 | return __cxa_uncaught_exception(); |
Howard Hinnant | d0ed21e | 2012-02-29 15:37:30 +0000 | [diff] [blame] | 113 | #else // __APPLE__ |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 114 | #warning uncaught_exception not yet implemented |
Howard Hinnant | ed14a76 | 2013-07-23 16:05:56 +0000 | [diff] [blame] | 115 | printf("uncaught_exception not yet implemented\n"); |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 116 | ::abort(); |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 117 | #endif // __APPLE__ |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 118 | } |
| 119 | |
Howard Hinnant | dea7f39 | 2012-02-02 20:48:35 +0000 | [diff] [blame] | 120 | #ifndef _LIBCPPABI_VERSION |
| 121 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 122 | exception::~exception() _NOEXCEPT |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 123 | { |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 124 | } |
| 125 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 126 | const char* exception::what() const _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 127 | { |
| 128 | return "std::exception"; |
| 129 | } |
| 130 | |
David Chisnall | 21a84cf | 2012-03-14 14:11:13 +0000 | [diff] [blame] | 131 | #endif // _LIBCPPABI_VERSION |
| 132 | #endif //LIBCXXRT |
Michael J. Spencer | a358fbe | 2012-11-30 21:02:29 +0000 | [diff] [blame] | 133 | #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) |
David Chisnall | 21a84cf | 2012-03-14 14:11:13 +0000 | [diff] [blame] | 134 | |
| 135 | bad_exception::~bad_exception() _NOEXCEPT |
| 136 | { |
| 137 | } |
| 138 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 139 | const char* bad_exception::what() const _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 140 | { |
| 141 | return "std::bad_exception"; |
| 142 | } |
| 143 | |
David Chisnall | 21a84cf | 2012-03-14 14:11:13 +0000 | [diff] [blame] | 144 | #endif |
| 145 | |
Howard Hinnant | dea7f39 | 2012-02-02 20:48:35 +0000 | [diff] [blame] | 146 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 147 | exception_ptr::~exception_ptr() _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 148 | { |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 149 | #if HAVE_DEPENDENT_EH_ABI |
| 150 | __cxa_decrement_exception_refcount(__ptr_); |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 151 | #else |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 152 | #warning exception_ptr not yet implemented |
Howard Hinnant | ed14a76 | 2013-07-23 16:05:56 +0000 | [diff] [blame] | 153 | printf("exception_ptr not yet implemented\n"); |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 154 | ::abort(); |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 155 | #endif // __APPLE__ |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 156 | } |
| 157 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 158 | exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 159 | : __ptr_(other.__ptr_) |
| 160 | { |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 161 | #if HAVE_DEPENDENT_EH_ABI |
| 162 | __cxa_increment_exception_refcount(__ptr_); |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 163 | #else |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 164 | #warning exception_ptr not yet implemented |
Howard Hinnant | ed14a76 | 2013-07-23 16:05:56 +0000 | [diff] [blame] | 165 | printf("exception_ptr not yet implemented\n"); |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 166 | ::abort(); |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 167 | #endif // __APPLE__ |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 168 | } |
| 169 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 170 | exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 171 | { |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 172 | #if HAVE_DEPENDENT_EH_ABI |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 173 | if (__ptr_ != other.__ptr_) |
| 174 | { |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 175 | __cxa_increment_exception_refcount(other.__ptr_); |
| 176 | __cxa_decrement_exception_refcount(__ptr_); |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 177 | __ptr_ = other.__ptr_; |
| 178 | } |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 179 | return *this; |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 180 | #else // __APPLE__ |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 181 | #warning exception_ptr not yet implemented |
Howard Hinnant | ed14a76 | 2013-07-23 16:05:56 +0000 | [diff] [blame] | 182 | printf("exception_ptr not yet implemented\n"); |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 183 | ::abort(); |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 184 | #endif // __APPLE__ |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 185 | } |
| 186 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 187 | nested_exception::nested_exception() _NOEXCEPT |
Howard Hinnant | ed2c291 | 2010-05-27 17:06:52 +0000 | [diff] [blame] | 188 | : __ptr_(current_exception()) |
| 189 | { |
| 190 | } |
| 191 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 192 | nested_exception::~nested_exception() _NOEXCEPT |
Howard Hinnant | ed2c291 | 2010-05-27 17:06:52 +0000 | [diff] [blame] | 193 | { |
| 194 | } |
| 195 | |
Richard Smith | 0405cc4 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 196 | _LIBCPP_NORETURN |
Howard Hinnant | ed2c291 | 2010-05-27 17:06:52 +0000 | [diff] [blame] | 197 | void |
Howard Hinnant | 4b7a43d | 2011-05-26 17:07:32 +0000 | [diff] [blame] | 198 | nested_exception::rethrow_nested() const |
Howard Hinnant | ed2c291 | 2010-05-27 17:06:52 +0000 | [diff] [blame] | 199 | { |
| 200 | if (__ptr_ == nullptr) |
| 201 | terminate(); |
| 202 | rethrow_exception(__ptr_); |
| 203 | } |
| 204 | |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 205 | |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 206 | exception_ptr current_exception() _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 207 | { |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 208 | #if HAVE_DEPENDENT_EH_ABI |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 209 | // be nicer if there was a constructor that took a ptr, then |
| 210 | // this whole function would be just: |
| 211 | // return exception_ptr(__cxa_current_primary_exception()); |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 212 | exception_ptr ptr; |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 213 | ptr.__ptr_ = __cxa_current_primary_exception(); |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 214 | return ptr; |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 215 | #else // __APPLE__ |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 216 | #warning exception_ptr not yet implemented |
Howard Hinnant | ed14a76 | 2013-07-23 16:05:56 +0000 | [diff] [blame] | 217 | printf("exception_ptr not yet implemented\n"); |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 218 | ::abort(); |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 219 | #endif // __APPLE__ |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 220 | } |
| 221 | |
Richard Smith | 0405cc4 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 222 | _LIBCPP_NORETURN |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 223 | void rethrow_exception(exception_ptr p) |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 224 | { |
David Chisnall | c512df1 | 2011-09-21 08:39:44 +0000 | [diff] [blame] | 225 | #if HAVE_DEPENDENT_EH_ABI |
| 226 | __cxa_rethrow_primary_exception(p.__ptr_); |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 227 | // if p.__ptr_ is NULL, above returns so we terminate |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 228 | terminate(); |
| 229 | #else // __APPLE__ |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 230 | #warning exception_ptr not yet implemented |
Howard Hinnant | ed14a76 | 2013-07-23 16:05:56 +0000 | [diff] [blame] | 231 | printf("exception_ptr not yet implemented\n"); |
Howard Hinnant | d510977 | 2010-08-22 13:53:14 +0000 | [diff] [blame] | 232 | ::abort(); |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 233 | #endif // __APPLE__ |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 234 | } |
David Chisnall | 1e8b3f9 | 2012-02-29 12:59:17 +0000 | [diff] [blame] | 235 | } // std |