diff --git a/include/__config b/include/__config index e0b9582cd08e..6b2901458587 100644 --- a/include/__config +++ b/include/__config @@ -1,439 +1,443 @@ // -*- C++ -*- //===--------------------------- __config ---------------------------------===// // // 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_CONFIG #define _LIBCPP_CONFIG #if !_MSC_VER // explicit macro necessary because it is only defined below in this file #pragma GCC system_header #endif #define _LIBCPP_VERSION 1001 #define _LIBCPP_ABI_VERSION 1 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) #ifdef __LITTLE_ENDIAN__ #if __LITTLE_ENDIAN__ #define _LIBCPP_LITTLE_ENDIAN 1 #define _LIBCPP_BIG_ENDIAN 0 #endif // __LITTLE_ENDIAN__ #endif // __LITTLE_ENDIAN__ #ifdef __BIG_ENDIAN__ #if __BIG_ENDIAN__ #define _LIBCPP_LITTLE_ENDIAN 0 #define _LIBCPP_BIG_ENDIAN 1 #endif // __BIG_ENDIAN__ #endif // __BIG_ENDIAN__ #ifdef __FreeBSD__ # include # if _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # endif // _BYTE_ORDER == _LITTLE_ENDIAN #endif // __FreeBSD__ #ifdef _WIN32 # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 // Compiler intrinsics (GCC or MSVC) # if (defined(_MSC_VER) && _MSC_VER >= 1400) || (__GNUC__ >= 4 && __GNUC_MINOR__ > 3) # define _LIBCP_HAS_IS_BASE_OF # endif #endif // _WIN32 #ifdef __sun__ # include # ifdef _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # else # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # endif #endif // __sun__ #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) # include # if __BYTE_ORDER == __LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # elif __BYTE_ORDER == __BIG_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # else // __BYTE_ORDER == __BIG_ENDIAN # error unable to determine endian # endif #endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) #if _WIN32 // only really useful for a DLL #ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally... # ifdef cxx_EXPORTS # define _LIBCPP_HIDDEN # define _LIBCPP_VISIBLE __declspec(dllexport) # else # define _LIBCPP_HIDDEN # define _LIBCPP_VISIBLE __declspec(dllimport) # endif #else # define _LIBCPP_HIDDEN # define _LIBCPP_VISIBLE #endif #ifndef _LIBCPP_INLINE_VISIBILITY # if _MSC_VER # define _LIBCPP_INLINE_VISIBILITY __forceinline # else // MinGW GCC and Clang # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) # endif #endif #ifndef _LIBCPP_EXCEPTION_ABI #define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBLE #endif #ifndef _LIBCPP_ALWAYS_INLINE # if _MSC_VER # define _LIBCPP_ALWAYS_INLINE __forceinline # endif #endif #endif // _WIN32 #ifndef _LIBCPP_HIDDEN #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) #endif #ifndef _LIBCPP_VISIBLE #define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default"))) #endif #ifndef _LIBCPP_INLINE_VISIBILITY #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) #endif #ifndef _LIBCPP_EXCEPTION_ABI #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) #endif #ifndef _LIBCPP_CANTTHROW #define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__)) #endif #ifndef _LIBCPP_ALWAYS_INLINE #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) #endif #if defined(__clang__) #if __has_feature(cxx_alignas) # define _ALIGNAS(x) alignas(x) #else # define _ALIGNAS(x) __attribute__((__aligned__(x))) #endif #if !__has_feature(cxx_alias_templates) #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif #ifndef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __linux__ #define _LIBCPP_HAS_NO_UNICODE_CHARS #else typedef __char16_t char16_t; typedef __char32_t char32_t; #endif #endif #if !(__has_feature(cxx_exceptions)) #define _LIBCPP_NO_EXCEPTIONS #endif #if !(__has_feature(cxx_rtti)) #define _LIBCPP_NO_RTTI #endif #if !(__has_feature(cxx_strong_enums)) #define _LIBCPP_HAS_NO_STRONG_ENUMS #endif #if !(__has_feature(cxx_decltype)) #define _LIBCPP_HAS_NO_DECLTYPE #endif #if __has_feature(cxx_attributes) # define _ATTRIBUTE(x) [[x]] #else # define _ATTRIBUTE(x) __attribute__ ((x)) #endif #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #if !(__has_feature(cxx_deleted_functions)) #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #endif // !(__has_feature(cxx_deleted_functions)) #if !(__has_feature(cxx_lambdas)) #define _LIBCPP_HAS_NO_LAMBDAS #endif #if !(__has_feature(cxx_nullptr)) #define _LIBCPP_HAS_NO_NULLPTR #endif #if !(__has_feature(cxx_rvalue_references)) #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif #if !(__has_feature(cxx_static_assert)) #define _LIBCPP_HAS_NO_STATIC_ASSERT #endif #if !(__has_feature(cxx_auto_type)) #define _LIBCPP_HAS_NO_AUTO_TYPE #endif #if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return) #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif #if !(__has_feature(cxx_variadic_templates)) #define _LIBCPP_HAS_NO_VARIADICS #endif #if !(__has_feature(cxx_trailing_return)) #define _LIBCPP_HAS_NO_TRAILING_RETURN #endif #if !(__has_feature(cxx_generalized_initializers)) #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif #if __has_feature(is_base_of) # define _LIBCP_HAS_IS_BASE_OF #endif // Objective-C++ features (opt-in) #if __has_feature(objc_arc) #define _LIBCPP_HAS_OBJC_ARC #endif #if __has_feature(objc_arc_weak) #define _LIBCPP_HAS_OBJC_ARC_WEAK #define _LIBCPP_HAS_NO_STRONG_ENUMS #endif #if !(__has_feature(cxx_constexpr)) #define _LIBCPP_HAS_NO_CONSTEXPR #endif +#if __FreeBSD__ +#define _LIBCPP_HAS_QUICK_EXIT +#endif + #if (__has_feature(cxx_noexcept)) # define _NOEXCEPT noexcept # define _NOEXCEPT_(x) noexcept(x) #else # define _NOEXCEPT throw() # define _NOEXCEPT_(x) #endif #if __has_feature(underlying_type) # define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T) #endif // Inline namespaces are available in Clang regardless of C++ dialect. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_NAMESPACE namespace std { inline namespace _LIBCPP_NAMESPACE { } } #elif defined(__GNUC__) #define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ATTRIBUTE(x) __attribute__((x)) #if !__EXCEPTIONS #define _LIBCPP_NO_EXCEPTIONS #endif #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_CONSTEXPR #define _NOEXCEPT throw() #define _NOEXCEPT_(x) #ifndef __GXX_EXPERIMENTAL_CXX0X__ #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_STATIC_ASSERT #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #else // __GXX_EXPERIMENTAL_CXX0X__ #define _LIBCPP_HAS_NO_TRAILING_RETURN #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3) #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif #if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3) #define _LIBCPP_HAS_NO_STATIC_ASSERT #endif #if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4) #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4) #if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 6) #define _LIBCPP_HAS_NO_NULLPTR #endif #endif // __GXX_EXPERIMENTAL_CXX0X__ #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_NAMESPACE namespace std { namespace _LIBCPP_NAMESPACE { } using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); } #elif defined(_MSC_VER) #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define __alignof__ __alignof #define _ATTRIBUTE __declspec #define _ALIGNAS(x) __declspec(align(x)) #define _LIBCPP_HAS_NO_VARIADICS #define _NOEXCEPT throw() #define _NOEXCEPT_(x) #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { #define _LIBCPP_END_NAMESPACE_STD } #define _VSTD std namespace std { } #endif // __clang__ || __GNUC___ || _MSC_VER #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; typedef unsigned int char32_t; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT template struct __static_assert_test; template <> struct __static_assert_test {}; template struct __static_assert_check {}; #define static_assert(__b, __m) \ typedef __static_assert_check)> \ _LIBCPP_CONCAT(__t, __LINE__) #endif // _LIBCPP_HAS_NO_STATIC_ASSERT #ifdef _LIBCPP_HAS_NO_DECLTYPE #define decltype(x) __typeof__(x) #endif #ifdef _LIBCPP_HAS_NO_CONSTEXPR #define constexpr const #endif #ifndef __has_feature #define __has_feature(__x) 0 #endif #if __has_feature(cxx_explicit_conversions) # define _LIBCPP_EXPLICIT explicit #else # define _LIBCPP_EXPLICIT #endif #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_VISIBLE x { enum _ #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ _ __v_; \ _LIBCPP_ALWAYS_INLINE x(_ __v) : __v_(__v) {} \ _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \ }; #else // _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_VISIBLE x #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #endif // _LIBCPP_HAS_NO_STRONG_ENUMS #if __APPLE__ || __FreeBSD__ || _WIN32 || __sun__ #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif #if __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 #endif #if __APPLE__ || __FreeBSD__ #define _LIBCPP_HAS_DEFAULTRUNELOCALE #endif #if __APPLE__ || __FreeBSD__ || __sun__ #define _LIBCPP_WCTYPE_IS_MASK #endif #ifdef _LIBCPP_DEBUG2 # if _LIBCPP_DEBUG2 == 0 # define _LIBCPP_DEBUG_LEVEL 1 # elif _LIBCPP_DEBUG2 == 1 # define _LIBCPP_DEBUG_LEVEL 2 # else # error Supported values for _LIBCPP_DEBUG2 are 0 and 1 # endif #endif #ifdef _LIBCPP_DEBUG2 # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) #endif #endif // _LIBCPP_CONFIG diff --git a/include/cstdlib b/include/cstdlib index 1158db2c0aca..a5c78e98274f 100644 --- a/include/cstdlib +++ b/include/cstdlib @@ -1,146 +1,150 @@ // -*- C++ -*- //===--------------------------- cstdlib ----------------------------------===// // // 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_CSTDLIB #define _LIBCPP_CSTDLIB /* cstdlib synopsis Macros: EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX NULL RAND_MAX namespace std { Types: size_t div_t ldiv_t lldiv_t // C99 double atof (const char* nptr); int atoi (const char* nptr); long atol (const char* nptr); long long atoll(const char* nptr); // C99 double strtod (const char* restrict nptr, char** restrict endptr); float strtof (const char* restrict nptr, char** restrict endptr); // C99 long double strtold (const char* restrict nptr, char** restrict endptr); // C99 long strtol (const char* restrict nptr, char** restrict endptr, int base); long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99 unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base); unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99 int rand(void); void srand(unsigned int seed); void* calloc(size_t nmemb, size_t size); void free(void* ptr); void* malloc(size_t size); void* realloc(void* ptr, size_t size); void abort(void); int atexit(void (*func)(void)); void exit(int status); void _Exit(int status); char* getenv(const char* name); int system(const char* string); void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); void qsort(void* base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); int abs( int j); long abs( long j); long long abs(long long j); // C++0X long labs( long j); long long llabs(long long j); // C99 div_t div( int numer, int denom); ldiv_t div( long numer, long denom); lldiv_t div(long long numer, long long denom); // C++0X ldiv_t ldiv( long numer, long denom); lldiv_t lldiv(long long numer, long long denom); // C99 int mblen(const char* s, size_t n); int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n); int wctomb(char* s, wchar_t wchar); size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n); size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n); } // std */ #include <__config> #include #ifdef _MSC_VER #include "support/win32/locale_win32.h" #endif // _MSC_VER #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD using ::size_t; using ::div_t; using ::ldiv_t; using ::lldiv_t; using ::atof; using ::atoi; using ::atol; using ::atoll; using ::strtod; using ::strtof; using ::strtold; using ::strtol; using ::strtoll; using ::strtoul; using ::strtoull; using ::rand; using ::srand; using ::calloc; using ::free; using ::malloc; using ::realloc; using ::abort; using ::atexit; using ::exit; using ::_Exit; using ::getenv; using ::system; using ::bsearch; using ::qsort; using ::abs; using ::labs; using ::llabs; using ::div; using ::ldiv; using ::lldiv; using ::mblen; using ::mbtowc; using ::wctomb; using ::mbstowcs; using ::wcstombs; +#ifdef _LIBCPP_HAS_QUICK_EXIT +using ::at_quick_exit; +using ::quick_exit; +#endif // MSVC already has the correct prototype in #ifdef __cplusplus #if !defined(_MSC_VER) && !defined(__sun__) inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) {return labs(__x);} inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) {return llabs(__x);} inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) {return ldiv(__x, __y);} inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) {return lldiv(__x, __y);} #endif // _MSC_VER _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CSTDLIB diff --git a/src/exception.cpp b/src/exception.cpp index 6b5e6984a606..6a5803d37745 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -1,217 +1,221 @@ //===------------------------ exception.cpp -------------------------------===// // // 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 #include "exception" #if __APPLE__ #include using namespace __cxxabiv1; #define HAVE_DEPENDENT_EH_ABI 1 #ifndef _LIBCPPABI_VERSION using namespace __cxxabiapple; // On Darwin, there are two STL shared libraries and a lower level ABI // shared libray. The globals holding the current terminate handler and // current unexpected handler are in the ABI library. #define __terminate_handler __cxxabiapple::__cxa_terminate_handler #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler #endif // _LIBCPPABI_VERSION #elif defined(LIBCXXRT) #include using namespace __cxxabiv1; #define HAVE_DEPENDENT_EH_ABI 1 #else // __APPLE__ static std::terminate_handler __terminate_handler; static std::unexpected_handler __unexpected_handler; #endif // __APPLE__ namespace std { #if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) // 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); } _ATTRIBUTE(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); } _ATTRIBUTE(noreturn) void terminate() _NOEXCEPT { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS (*get_terminate())(); // handler should not return ::abort (); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { // handler should not throw exception ::abort (); } #endif // _LIBCPP_NO_EXCEPTIONS } #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) #ifndef LIBCXXRT bool uncaught_exception() _NOEXCEPT { #if __APPLE__ // on Darwin, there is a helper function so __cxa_get_globals is private return __cxa_uncaught_exception(); #elif LIBCXXRT __cxa_eh_globals * globals = __cxa_get_globals(); return (globals->uncaughtExceptions != 0); #else // __APPLE__ #warning uncaught_exception not yet implemented ::abort(); #endif // __APPLE__ } #ifndef _LIBCPPABI_VERSION exception::~exception() _NOEXCEPT { } -bad_exception::~bad_exception() _NOEXCEPT +const char* exception::what() const _NOEXCEPT { + return "std::exception"; } -const char* exception::what() const _NOEXCEPT +#endif // _LIBCPPABI_VERSION +#endif //LIBCXXRT +#ifndef _LIBCPPABI_VERSION + +bad_exception::~bad_exception() _NOEXCEPT { - return "std::exception"; } const char* bad_exception::what() const _NOEXCEPT { return "std::bad_exception"; } -#endif // _LIBCPPABI_VERSION -#endif //LIBCXXRT +#endif + exception_ptr::~exception_ptr() _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI __cxa_decrement_exception_refcount(__ptr_); #else #warning exception_ptr not yet implemented ::abort(); #endif // __APPLE__ } exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT : __ptr_(other.__ptr_) { #if HAVE_DEPENDENT_EH_ABI __cxa_increment_exception_refcount(__ptr_); #else #warning exception_ptr not yet implemented ::abort(); #endif // __APPLE__ } exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI if (__ptr_ != other.__ptr_) { __cxa_increment_exception_refcount(other.__ptr_); __cxa_decrement_exception_refcount(__ptr_); __ptr_ = other.__ptr_; } return *this; #else // __APPLE__ #warning exception_ptr not yet implemented ::abort(); #endif // __APPLE__ } nested_exception::nested_exception() _NOEXCEPT : __ptr_(current_exception()) { } nested_exception::~nested_exception() _NOEXCEPT { } _ATTRIBUTE(noreturn) void nested_exception::rethrow_nested() const { if (__ptr_ == nullptr) terminate(); rethrow_exception(__ptr_); } exception_ptr current_exception() _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI // 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; #else // __APPLE__ #warning exception_ptr not yet implemented ::abort(); #endif // __APPLE__ } _ATTRIBUTE(noreturn) void rethrow_exception(exception_ptr p) { #if HAVE_DEPENDENT_EH_ABI __cxa_rethrow_primary_exception(p.__ptr_); // if p.__ptr_ is NULL, above returns so we terminate terminate(); #else // __APPLE__ #warning exception_ptr not yet implemented ::abort(); #endif // __APPLE__ } } // std diff --git a/src/new.cpp b/src/new.cpp index 1c171a871b9b..1fb4b2da40d7 100644 --- a/src/new.cpp +++ b/src/new.cpp @@ -1,199 +1,196 @@ //===--------------------------- new.cpp ----------------------------------===// // // 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 #include "new" #if __APPLE__ #include #ifndef _LIBCPPABI_VERSION // On Darwin, there are two STL shared libraries and a lower level ABI // shared libray. The global holding the current new handler is // in the ABI library and named __cxa_new_handler. #define __new_handler __cxxabiapple::__cxa_new_handler #endif #else // __APPLE__ static std::new_handler __new_handler; #endif -#if !defined (LIBCXXRT) // && !defined(_LIBCPPABI_VERSION) - // Implement all new and delete operators as weak definitions // in this shared library, so that they can be overriden by programs // that define non-weak copies of the functions. __attribute__((__weak__, __visibility__("default"))) void * operator new(std::size_t size) #if !__has_feature(cxx_noexcept) throw(std::bad_alloc) #endif { if (size == 0) size = 1; void* p; while ((p = ::malloc(size)) == 0) { // If malloc fails and there is a new_handler, // call it to try free up memory. std::new_handler nh = std::get_new_handler(); if (nh) nh(); else #ifndef _LIBCPP_NO_EXCEPTIONS throw std::bad_alloc(); #else break; #endif } return p; } __attribute__((__weak__, __visibility__("default"))) void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { void* p = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS p = ::operator new(size); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { } #endif // _LIBCPP_NO_EXCEPTIONS return p; } __attribute__((__weak__, __visibility__("default"))) void* operator new[](size_t size) #if !__has_feature(cxx_noexcept) throw(std::bad_alloc) #endif { return ::operator new(size); } __attribute__((__weak__, __visibility__("default"))) void* operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT { void* p = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS p = ::operator new[](size); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { } #endif // _LIBCPP_NO_EXCEPTIONS return p; } __attribute__((__weak__, __visibility__("default"))) void operator delete(void* ptr) _NOEXCEPT { if (ptr) ::free(ptr); } __attribute__((__weak__, __visibility__("default"))) void operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete(ptr); } __attribute__((__weak__, __visibility__("default"))) void operator delete[] (void* ptr) _NOEXCEPT { ::operator delete (ptr); } __attribute__((__weak__, __visibility__("default"))) void operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete[](ptr); } -#endif // !_LIBCPPABI_VERSION && !LIBCXXRT - namespace std { const nothrow_t nothrow = {}; #ifndef _LIBCPPABI_VERSION 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, (new_handler)0); } #ifndef LIBCXXRT bad_alloc::bad_alloc() _NOEXCEPT { } bad_alloc::~bad_alloc() _NOEXCEPT { } const char* bad_alloc::what() const _NOEXCEPT { return "std::bad_alloc"; } +#endif //LIBCXXRT + 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 -#endif //LIBCXXRT void __throw_bad_alloc() { #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); #endif } } // std