2 //===----------------------------------------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_ABI_MICROSOFT
12 #error this header can only be used when targeting the MSVC ABI
18 #include <corecrt_terminate.h>
22 // libcxxrt provides implementations of these functions itself.
24 set_unexpected(unexpected_handler func) _NOEXCEPT {
25 return ::set_unexpected(func);
28 unexpected_handler get_unexpected() _NOEXCEPT {
29 return ::_get_unexpected();
34 (*get_unexpected())();
35 // unexpected handler should not return
39 terminate_handler set_terminate(terminate_handler func) _NOEXCEPT {
40 return ::set_terminate(func);
43 terminate_handler get_terminate() _NOEXCEPT {
44 return ::_get_terminate();
48 void terminate() _NOEXCEPT
50 #ifndef _LIBCPP_NO_EXCEPTIONS
53 #endif // _LIBCPP_NO_EXCEPTIONS
55 // handler should not return
56 fprintf(stderr, "terminate_handler unexpectedly returned\n");
58 #ifndef _LIBCPP_NO_EXCEPTIONS
62 // handler should not throw exception
63 fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
66 #endif // _LIBCPP_NO_EXCEPTIONS
69 bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
71 int uncaught_exceptions() _NOEXCEPT {
72 return __uncaught_exceptions();
75 bad_array_length::bad_array_length() _NOEXCEPT
79 bad_array_length::~bad_array_length() _NOEXCEPT
84 bad_array_length::what() const _NOEXCEPT
86 return "bad_array_length";