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