diff options
Diffstat (limited to 'gnu/llvm/libcxx/src/support/runtime')
12 files changed, 832 insertions, 0 deletions
diff --git a/gnu/llvm/libcxx/src/support/runtime/exception_fallback.ipp b/gnu/llvm/libcxx/src/support/runtime/exception_fallback.ipp new file mode 100644 index 00000000000..376a0381f54 --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/exception_fallback.ipp @@ -0,0 +1,164 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include <cstdio> + +namespace std { + +_LIBCPP_SAFE_STATIC static std::terminate_handler __terminate_handler; +_LIBCPP_SAFE_STATIC static std::unexpected_handler __unexpected_handler; + + +// libcxxrt provides implementations of these functions itself. +unexpected_handler +set_unexpected(unexpected_handler func) _NOEXCEPT +{ + return __libcpp_atomic_exchange(&__unexpected_handler, func); +} + +unexpected_handler +get_unexpected() _NOEXCEPT +{ + return __libcpp_atomic_load(&__unexpected_handler); + +} + +_LIBCPP_NORETURN +void unexpected() +{ + (*get_unexpected())(); + // unexpected handler should not return + terminate(); +} + +terminate_handler +set_terminate(terminate_handler func) _NOEXCEPT +{ + return __libcpp_atomic_exchange(&__terminate_handler, func); +} + +terminate_handler +get_terminate() _NOEXCEPT +{ + return __libcpp_atomic_load(&__terminate_handler); +} + +#ifndef __EMSCRIPTEN__ // We provide this in JS +_LIBCPP_NORETURN +void +terminate() _NOEXCEPT +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif // _LIBCPP_NO_EXCEPTIONS + (*get_terminate())(); + // handler should not return + fprintf(stderr, "terminate_handler unexpectedly returned\n"); + ::abort(); +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch (...) + { + // handler should not throw exception + fprintf(stderr, "terminate_handler unexpectedly threw an exception\n"); + ::abort(); + } +#endif // _LIBCPP_NO_EXCEPTIONS +} +#endif // !__EMSCRIPTEN__ + +#if !defined(__EMSCRIPTEN__) +bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; } + +int uncaught_exceptions() _NOEXCEPT +{ +#warning uncaught_exception not yet implemented + fprintf(stderr, "uncaught_exceptions not yet implemented\n"); + ::abort(); +} +#endif // !__EMSCRIPTEN__ + + +exception::~exception() _NOEXCEPT +{ +} + +const char* exception::what() const _NOEXCEPT +{ + return "std::exception"; +} + +bad_exception::~bad_exception() _NOEXCEPT +{ +} + +const char* bad_exception::what() const _NOEXCEPT +{ + return "std::bad_exception"; +} + + +bad_alloc::bad_alloc() _NOEXCEPT +{ +} + +bad_alloc::~bad_alloc() _NOEXCEPT +{ +} + +const char* +bad_alloc::what() const _NOEXCEPT +{ + return "std::bad_alloc"; +} + +bad_array_new_length::bad_array_new_length() _NOEXCEPT +{ +} + +bad_array_new_length::~bad_array_new_length() _NOEXCEPT +{ +} + +const char* +bad_array_new_length::what() const _NOEXCEPT +{ + return "bad_array_new_length"; +} + +bad_cast::bad_cast() _NOEXCEPT +{ +} + +bad_typeid::bad_typeid() _NOEXCEPT +{ +} + +bad_cast::~bad_cast() _NOEXCEPT +{ +} + +const char* +bad_cast::what() const _NOEXCEPT +{ + return "std::bad_cast"; +} + +bad_typeid::~bad_typeid() _NOEXCEPT +{ +} + +const char* +bad_typeid::what() const _NOEXCEPT +{ + return "std::bad_typeid"; +} + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/exception_glibcxx.ipp b/gnu/llvm/libcxx/src/support/runtime/exception_glibcxx.ipp new file mode 100644 index 00000000000..4bf3c4d8775 --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/exception_glibcxx.ipp @@ -0,0 +1,32 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __GLIBCXX__ +#error header can only be used when targeting libstdc++ or libsupc++ +#endif + +namespace std { + +bad_alloc::bad_alloc() _NOEXCEPT +{ +} + +bad_array_new_length::bad_array_new_length() _NOEXCEPT +{ +} + +bad_cast::bad_cast() _NOEXCEPT +{ +} + +bad_typeid::bad_typeid() _NOEXCEPT +{ +} + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/exception_libcxxabi.ipp b/gnu/llvm/libcxx/src/support/runtime/exception_libcxxabi.ipp new file mode 100644 index 00000000000..6bc049bf382 --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/exception_libcxxabi.ipp @@ -0,0 +1,27 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPPABI_VERSION +#error this header can only be used with libc++abi +#endif + +namespace std { + +bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; } + +int uncaught_exceptions() _NOEXCEPT +{ +# if _LIBCPPABI_VERSION > 1001 + return __cxa_uncaught_exceptions(); +# else + return __cxa_uncaught_exception() ? 1 : 0; +# endif +} + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/exception_libcxxrt.ipp b/gnu/llvm/libcxx/src/support/runtime/exception_libcxxrt.ipp new file mode 100644 index 00000000000..0ebffdedba9 --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/exception_libcxxrt.ipp @@ -0,0 +1,25 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LIBCXXRT +#error this header may only be used when targeting libcxxrt +#endif + +namespace std { + +bad_exception::~bad_exception() _NOEXCEPT +{ +} + +const char* bad_exception::what() const _NOEXCEPT +{ + return "std::bad_exception"; +} + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/exception_msvc.ipp b/gnu/llvm/libcxx/src/support/runtime/exception_msvc.ipp new file mode 100644 index 00000000000..7315b8261b7 --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/exception_msvc.ipp @@ -0,0 +1,163 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_ABI_MICROSOFT +#error this header can only be used when targeting the MSVC ABI +#endif + +#include <stdio.h> +#include <stdlib.h> + +extern "C" { +typedef void (__cdecl* terminate_handler)(); +_LIBCPP_CRT_FUNC terminate_handler __cdecl set_terminate( + terminate_handler _NewTerminateHandler) throw(); +_LIBCPP_CRT_FUNC terminate_handler __cdecl _get_terminate(); + +typedef void (__cdecl* unexpected_handler)(); +unexpected_handler __cdecl set_unexpected( + unexpected_handler _NewUnexpectedHandler) throw(); +unexpected_handler __cdecl _get_unexpected(); + +int __cdecl __uncaught_exceptions(); +} + +namespace std { + +unexpected_handler +set_unexpected(unexpected_handler func) _NOEXCEPT { + return ::set_unexpected(func); +} + +unexpected_handler get_unexpected() _NOEXCEPT { + return ::_get_unexpected(); +} + +_LIBCPP_NORETURN +void unexpected() { + (*get_unexpected())(); + // unexpected handler should not return + terminate(); +} + +terminate_handler set_terminate(terminate_handler func) _NOEXCEPT { + return ::set_terminate(func); +} + +terminate_handler get_terminate() _NOEXCEPT { + return ::_get_terminate(); +} + +_LIBCPP_NORETURN +void terminate() _NOEXCEPT +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif // _LIBCPP_NO_EXCEPTIONS + (*get_terminate())(); + // handler should not return + fprintf(stderr, "terminate_handler unexpectedly returned\n"); + ::abort(); +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch (...) + { + // handler should not throw exception + fprintf(stderr, "terminate_handler unexpectedly threw an exception\n"); + ::abort(); + } +#endif // _LIBCPP_NO_EXCEPTIONS +} + +bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; } + +int uncaught_exceptions() _NOEXCEPT { + return __uncaught_exceptions(); +} + +#if !defined(_LIBCPP_ABI_VCRUNTIME) +bad_cast::bad_cast() _NOEXCEPT +{ +} + +bad_cast::~bad_cast() _NOEXCEPT +{ +} + +const char * +bad_cast::what() const _NOEXCEPT +{ + return "std::bad_cast"; +} + +bad_typeid::bad_typeid() _NOEXCEPT +{ +} + +bad_typeid::~bad_typeid() _NOEXCEPT +{ +} + +const char * +bad_typeid::what() const _NOEXCEPT +{ + return "std::bad_typeid"; +} + +exception::~exception() _NOEXCEPT +{ +} + +const char* exception::what() const _NOEXCEPT +{ + return "std::exception"; +} + + +bad_exception::~bad_exception() _NOEXCEPT +{ +} + +const char* bad_exception::what() const _NOEXCEPT +{ + return "std::bad_exception"; +} + + +bad_alloc::bad_alloc() _NOEXCEPT +{ +} + +bad_alloc::~bad_alloc() _NOEXCEPT +{ +} + +const char* +bad_alloc::what() const _NOEXCEPT +{ + return "std::bad_alloc"; +} + +bad_array_new_length::bad_array_new_length() _NOEXCEPT +{ +} + +bad_array_new_length::~bad_array_new_length() _NOEXCEPT +{ +} + +const char* +bad_array_new_length::what() const _NOEXCEPT +{ + return "bad_array_new_length"; +} +#endif // !_LIBCPP_ABI_VCRUNTIME + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/gnu/llvm/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp new file mode 100644 index 00000000000..82a8e6972fa --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp @@ -0,0 +1,73 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef HAVE_DEPENDENT_EH_ABI +#error this header may only be used with libc++abi or libcxxrt +#endif + +namespace std { + +exception_ptr::~exception_ptr() _NOEXCEPT { + __cxa_decrement_exception_refcount(__ptr_); +} + +exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT + : __ptr_(other.__ptr_) +{ + __cxa_increment_exception_refcount(__ptr_); +} + +exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT +{ + if (__ptr_ != other.__ptr_) + { + __cxa_increment_exception_refcount(other.__ptr_); + __cxa_decrement_exception_refcount(__ptr_); + __ptr_ = other.__ptr_; + } + return *this; +} + +nested_exception::nested_exception() _NOEXCEPT + : __ptr_(current_exception()) +{ +} + +nested_exception::~nested_exception() _NOEXCEPT +{ +} + +_LIBCPP_NORETURN +void +nested_exception::rethrow_nested() const +{ + if (__ptr_ == nullptr) + terminate(); + rethrow_exception(__ptr_); +} + +exception_ptr current_exception() _NOEXCEPT +{ + // be nicer if there was a constructor that took a ptr, then + // this whole function would be just: + // return exception_ptr(__cxa_current_primary_exception()); + exception_ptr ptr; + ptr.__ptr_ = __cxa_current_primary_exception(); + return ptr; +} + +_LIBCPP_NORETURN +void rethrow_exception(exception_ptr p) +{ + __cxa_rethrow_primary_exception(p.__ptr_); + // if p.__ptr_ is NULL, above returns so we terminate + terminate(); +} + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/gnu/llvm/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp new file mode 100644 index 00000000000..3abc137c67b --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp @@ -0,0 +1,77 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// libsupc++ does not implement the dependent EH ABI and the functionality +// it uses to implement std::exception_ptr (which it declares as an alias of +// std::__exception_ptr::exception_ptr) is not directly exported to clients. So +// we have little choice but to hijack std::__exception_ptr::exception_ptr's +// (which fortunately has the same layout as our std::exception_ptr) copy +// constructor, assignment operator and destructor (which are part of its +// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr) +// function. + +namespace std { + +namespace __exception_ptr +{ + +struct exception_ptr +{ + void* __ptr_; + + exception_ptr(const exception_ptr&) _NOEXCEPT; + exception_ptr& operator=(const exception_ptr&) _NOEXCEPT; + ~exception_ptr() _NOEXCEPT; +}; + +} + +_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr); + +exception_ptr::~exception_ptr() _NOEXCEPT +{ + reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); +} + +exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT + : __ptr_(other.__ptr_) +{ + new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr( + reinterpret_cast<const __exception_ptr::exception_ptr&>(other)); +} + +exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT +{ + *reinterpret_cast<__exception_ptr::exception_ptr*>(this) = + reinterpret_cast<const __exception_ptr::exception_ptr&>(other); + return *this; +} + +nested_exception::nested_exception() _NOEXCEPT + : __ptr_(current_exception()) +{ +} + + +_LIBCPP_NORETURN +void +nested_exception::rethrow_nested() const +{ + if (__ptr_ == nullptr) + terminate(); + rethrow_exception(__ptr_); +} + +_LIBCPP_NORETURN +void rethrow_exception(exception_ptr p) +{ + rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p)); +} + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/exception_pointer_msvc.ipp b/gnu/llvm/libcxx/src/support/runtime/exception_pointer_msvc.ipp new file mode 100644 index 00000000000..b1a36952232 --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/exception_pointer_msvc.ipp @@ -0,0 +1,86 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include <stdio.h> +#include <stdlib.h> + +_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCreate(void*); +_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrDestroy(void*); +_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCopy(void*, const void*); +_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrAssign(void*, const void*); +_LIBCPP_CRT_FUNC bool __cdecl __ExceptionPtrCompare(const void*, const void*); +_LIBCPP_CRT_FUNC bool __cdecl __ExceptionPtrToBool(const void*); +_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrSwap(void*, void*); +_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCurrentException(void*); +[[noreturn]] _LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrRethrow(const void*); +_LIBCPP_CRT_FUNC void __cdecl +__ExceptionPtrCopyException(void*, const void*, const void*); + +namespace std { + +exception_ptr::exception_ptr() _NOEXCEPT { __ExceptionPtrCreate(this); } +exception_ptr::exception_ptr(nullptr_t) _NOEXCEPT { __ExceptionPtrCreate(this); } + +exception_ptr::exception_ptr(const exception_ptr& __other) _NOEXCEPT { + __ExceptionPtrCopy(this, &__other); +} +exception_ptr& exception_ptr::operator=(const exception_ptr& __other) _NOEXCEPT { + __ExceptionPtrAssign(this, &__other); + return *this; +} + +exception_ptr& exception_ptr::operator=(nullptr_t) _NOEXCEPT { + exception_ptr dummy; + __ExceptionPtrAssign(this, &dummy); + return *this; +} + +exception_ptr::~exception_ptr() _NOEXCEPT { __ExceptionPtrDestroy(this); } + +exception_ptr::operator bool() const _NOEXCEPT { + return __ExceptionPtrToBool(this); +} + +bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT { + return __ExceptionPtrCompare(&__x, &__y); +} + + +void swap(exception_ptr& lhs, exception_ptr& rhs) _NOEXCEPT { + __ExceptionPtrSwap(&rhs, &lhs); +} + +exception_ptr __copy_exception_ptr(void* __except, const void* __ptr) { + exception_ptr __ret = nullptr; + if (__ptr) + __ExceptionPtrCopyException(&__ret, __except, __ptr); + return __ret; +} + +exception_ptr current_exception() _NOEXCEPT { + exception_ptr __ret; + __ExceptionPtrCurrentException(&__ret); + return __ret; +} + +_LIBCPP_NORETURN +void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); } + +nested_exception::nested_exception() _NOEXCEPT : __ptr_(current_exception()) {} + +nested_exception::~nested_exception() _NOEXCEPT {} + +_LIBCPP_NORETURN +void nested_exception::rethrow_nested() const { + if (__ptr_ == nullptr) + terminate(); + rethrow_exception(__ptr_); +} + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp b/gnu/llvm/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp new file mode 100644 index 00000000000..991bca9ecfe --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp @@ -0,0 +1,79 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include <stdio.h> +#include <stdlib.h> + +namespace std { + +exception_ptr::~exception_ptr() _NOEXCEPT +{ +# warning exception_ptr not yet implemented + fprintf(stderr, "exception_ptr not yet implemented\n"); + ::abort(); +} + +exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT + : __ptr_(other.__ptr_) +{ +# warning exception_ptr not yet implemented + fprintf(stderr, "exception_ptr not yet implemented\n"); + ::abort(); +} + +exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT +{ +# warning exception_ptr not yet implemented + fprintf(stderr, "exception_ptr not yet implemented\n"); + ::abort(); +} + +nested_exception::nested_exception() _NOEXCEPT + : __ptr_(current_exception()) +{ +} + +#if !defined(__GLIBCXX__) + +nested_exception::~nested_exception() _NOEXCEPT +{ +} + +#endif + +_LIBCPP_NORETURN +void +nested_exception::rethrow_nested() const +{ +# warning exception_ptr not yet implemented + fprintf(stderr, "exception_ptr not yet implemented\n"); + ::abort(); +#if 0 + if (__ptr_ == nullptr) + terminate(); + rethrow_exception(__ptr_); +#endif // FIXME +} + +exception_ptr current_exception() _NOEXCEPT +{ +# warning exception_ptr not yet implemented + fprintf(stderr, "exception_ptr not yet implemented\n"); + ::abort(); +} + +_LIBCPP_NORETURN +void rethrow_exception(exception_ptr p) +{ +# warning exception_ptr not yet implemented + fprintf(stderr, "exception_ptr not yet implemented\n"); + ::abort(); +} + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/new_handler_fallback.ipp b/gnu/llvm/libcxx/src/support/runtime/new_handler_fallback.ipp new file mode 100644 index 00000000000..72050939429 --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/new_handler_fallback.ipp @@ -0,0 +1,26 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +namespace std { + +_LIBCPP_SAFE_STATIC static std::new_handler __new_handler; + +new_handler +set_new_handler(new_handler handler) _NOEXCEPT +{ + return __libcpp_atomic_exchange(&__new_handler, handler); +} + +new_handler +get_new_handler() _NOEXCEPT +{ + return __libcpp_atomic_load(&__new_handler); +} + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/stdexcept_default.ipp b/gnu/llvm/libcxx/src/support/runtime/stdexcept_default.ipp new file mode 100644 index 00000000000..c827ca4c513 --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/stdexcept_default.ipp @@ -0,0 +1,64 @@ +//===--------------------- stdexcept_default.ipp --------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "../../include/refstring.h" + +/* For _LIBCPPABI_VERSION */ +#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \ + (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(LIBCXXRT)) +#include <cxxabi.h> +#endif + +static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char*), ""); + +namespace std // purposefully not using versioning namespace +{ + +logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) {} + +logic_error::logic_error(const char* msg) : __imp_(msg) {} + +logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_) {} + +logic_error& logic_error::operator=(const logic_error& le) _NOEXCEPT { + __imp_ = le.__imp_; + return *this; +} + +runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) {} + +runtime_error::runtime_error(const char* msg) : __imp_(msg) {} + +runtime_error::runtime_error(const runtime_error& re) _NOEXCEPT + : __imp_(re.__imp_) {} + +runtime_error& runtime_error::operator=(const runtime_error& re) _NOEXCEPT { + __imp_ = re.__imp_; + return *this; +} + +#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) + +const char* logic_error::what() const _NOEXCEPT { return __imp_.c_str(); } + +const char* runtime_error::what() const _NOEXCEPT { return __imp_.c_str(); } + +logic_error::~logic_error() _NOEXCEPT {} +domain_error::~domain_error() _NOEXCEPT {} +invalid_argument::~invalid_argument() _NOEXCEPT {} +length_error::~length_error() _NOEXCEPT {} +out_of_range::~out_of_range() _NOEXCEPT {} + +runtime_error::~runtime_error() _NOEXCEPT {} +range_error::~range_error() _NOEXCEPT {} +overflow_error::~overflow_error() _NOEXCEPT {} +underflow_error::~underflow_error() _NOEXCEPT {} + +#endif + +} // namespace std diff --git a/gnu/llvm/libcxx/src/support/runtime/stdexcept_vcruntime.ipp b/gnu/llvm/libcxx/src/support/runtime/stdexcept_vcruntime.ipp new file mode 100644 index 00000000000..94eed465ae9 --- /dev/null +++ b/gnu/llvm/libcxx/src/support/runtime/stdexcept_vcruntime.ipp @@ -0,0 +1,16 @@ +//===------------------- stdexcept_vcruntime.ipp --------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_ABI_VCRUNTIME +#error This file may only be used when defering to vcruntime +#endif + +namespace std { +logic_error::logic_error(std::string const& s) : exception(s.c_str()) {} +runtime_error::runtime_error(std::string const& s) : exception(s.c_str()) {} +} // namespace std |