diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-02-10 07:43:08 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-02-10 07:43:08 +0000 |
commit | 8dcdeaeb35500dd309cf2ff315dd829501798027 (patch) | |
tree | 71a024602be7d4b685780ed3c3f8e3fdda26b6bb /libcxx/src/support | |
parent | 6677999e174b862eb17da64449bd04fba644e28f (diff) | |
download | bcm5719-llvm-8dcdeaeb35500dd309cf2ff315dd829501798027.tar.gz bcm5719-llvm-8dcdeaeb35500dd309cf2ff315dd829501798027.zip |
Revert "Split exception.cpp and new.cpp implementation into different files for different runtimes."
The compiler-rt CMake configuration needs some tweaking before this can land.
llvm-svn: 294727
Diffstat (limited to 'libcxx/src/support')
-rw-r--r-- | libcxx/src/support/runtime/exception_fallback.ipp | 182 | ||||
-rw-r--r-- | libcxx/src/support/runtime/exception_glibcxx.ipp | 38 | ||||
-rw-r--r-- | libcxx/src/support/runtime/exception_libcxxabi.ipp | 28 | ||||
-rw-r--r-- | libcxx/src/support/runtime/exception_libcxxrt.ipp | 41 | ||||
-rw-r--r-- | libcxx/src/support/runtime/exception_msvc.ipp | 89 | ||||
-rw-r--r-- | libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 74 | ||||
-rw-r--r-- | libcxx/src/support/runtime/exception_pointer_glibcxx.ipp | 74 | ||||
-rw-r--r-- | libcxx/src/support/runtime/exception_pointer_unimplemented.ipp | 80 | ||||
-rw-r--r-- | libcxx/src/support/runtime/new_handler_fallback.ipp | 27 |
9 files changed, 0 insertions, 633 deletions
diff --git a/libcxx/src/support/runtime/exception_fallback.ipp b/libcxx/src/support/runtime/exception_fallback.ipp deleted file mode 100644 index c58edcc5560..00000000000 --- a/libcxx/src/support/runtime/exception_fallback.ipp +++ /dev/null @@ -1,182 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -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 __sync_lock_test_and_set(&__unexpected_handler, func); -} - -unexpected_handler -get_unexpected() _NOEXCEPT -{ - return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0); - -} - -_LIBCPP_NORETURN -void unexpected() -{ - (*get_unexpected())(); - // unexpected handler should not return - terminate(); -} - -terminate_handler -set_terminate(terminate_handler func) _NOEXCEPT -{ - return __sync_lock_test_and_set(&__terminate_handler, func); -} - -terminate_handler -get_terminate() _NOEXCEPT -{ - return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0); - -} - -#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_array_length::bad_array_length() _NOEXCEPT -{ -} - -bad_array_length::~bad_array_length() _NOEXCEPT -{ -} - -const char* -bad_array_length::what() const _NOEXCEPT -{ - return "bad_array_length"; -} - - -bad_cast::bad_cast() _NOEXCEPT -{ -} - -bad_typeid::bad_typeid() _NOEXCEPT -{ -} - -#ifndef __GLIBCXX__ - -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/libcxx/src/support/runtime/exception_glibcxx.ipp b/libcxx/src/support/runtime/exception_glibcxx.ipp deleted file mode 100644 index 365dc40a7ea..00000000000 --- a/libcxx/src/support/runtime/exception_glibcxx.ipp +++ /dev/null @@ -1,38 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#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_array_length::bad_array_length() _NOEXCEPT -{ -} - - -bad_cast::bad_cast() _NOEXCEPT -{ -} - -bad_typeid::bad_typeid() _NOEXCEPT -{ -} - -} // namespace diff --git a/libcxx/src/support/runtime/exception_libcxxabi.ipp b/libcxx/src/support/runtime/exception_libcxxabi.ipp deleted file mode 100644 index c3dcf1ec591..00000000000 --- a/libcxx/src/support/runtime/exception_libcxxabi.ipp +++ /dev/null @@ -1,28 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#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 > 1101 - return __cxa_uncaught_exceptions(); -# else - return __cxa_uncaught_exception() ? 1 : 0; -# endif -} - -} // namespace std diff --git a/libcxx/src/support/runtime/exception_libcxxrt.ipp b/libcxx/src/support/runtime/exception_libcxxrt.ipp deleted file mode 100644 index 6d9e0cff58d..00000000000 --- a/libcxx/src/support/runtime/exception_libcxxrt.ipp +++ /dev/null @@ -1,41 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#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"; -} - - -bad_array_length::bad_array_length() _NOEXCEPT -{ -} - -bad_array_length::~bad_array_length() _NOEXCEPT -{ -} - -const char* -bad_array_length::what() const _NOEXCEPT -{ - return "bad_array_length"; -} - -} // namespace std diff --git a/libcxx/src/support/runtime/exception_msvc.ipp b/libcxx/src/support/runtime/exception_msvc.ipp deleted file mode 100644 index 950ec0cebfe..00000000000 --- a/libcxx/src/support/runtime/exception_msvc.ipp +++ /dev/null @@ -1,89 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_ABI_MICROSOFT -#error this header can only be used when targeting the MSVC ABI -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <eh.h> -#include <corecrt_terminate.h> - -namespace std { - -// libcxxrt provides implementations of these functions itself. -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(); -} - -bad_array_length::bad_array_length() _NOEXCEPT -{ -} - -bad_array_length::~bad_array_length() _NOEXCEPT -{ -} - -const char* -bad_array_length::what() const _NOEXCEPT -{ - return "bad_array_length"; -} - -} // namespace std diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp deleted file mode 100644 index dfac8648c49..00000000000 --- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp +++ /dev/null @@ -1,74 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#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/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp deleted file mode 100644 index 30bd6b61f08..00000000000 --- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp +++ /dev/null @@ -1,74 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// 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 __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)); -} diff --git a/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp b/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp deleted file mode 100644 index 21c182c8597..00000000000 --- a/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp +++ /dev/null @@ -1,80 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#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/libcxx/src/support/runtime/new_handler_fallback.ipp b/libcxx/src/support/runtime/new_handler_fallback.ipp deleted file mode 100644 index b7092d542d9..00000000000 --- a/libcxx/src/support/runtime/new_handler_fallback.ipp +++ /dev/null @@ -1,27 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace std { - -_LIBCPP_SAFE_STATIC static std::new_handler __new_handler; - -new_handler -set_new_handler(new_handler handler) _NOEXCEPT -{ - return __sync_lock_test_and_set(&__new_handler, handler); -} - -new_handler -get_new_handler() _NOEXCEPT -{ - return __sync_fetch_and_add(&__new_handler, nullptr); -} - -} // namespace std |