diff options
Diffstat (limited to 'system/lib/libcxx/new.cpp')
-rw-r--r-- | system/lib/libcxx/new.cpp | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/system/lib/libcxx/new.cpp b/system/lib/libcxx/new.cpp index b23a516f..fa0331a8 100644 --- a/system/lib/libcxx/new.cpp +++ b/system/lib/libcxx/new.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_NEW + #include <stdlib.h> #include "new" @@ -28,16 +30,18 @@ #if defined(LIBCXXRT) || __has_include(<cxxabi.h>) #include <cxxabi.h> #endif // __has_include(<cxxabi.h>) - #ifndef _LIBCPPABI_VERSION + #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) static std::new_handler __new_handler; #endif // _LIBCPPABI_VERSION #endif +#ifndef __GLIBCXX__ + // 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"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void * operator new(std::size_t size) #if !__has_feature(cxx_noexcept) @@ -64,7 +68,7 @@ operator new(std::size_t size) return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -83,7 +87,7 @@ operator new(size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size) #if !__has_feature(cxx_noexcept) @@ -93,7 +97,7 @@ operator new[](size_t size) return ::operator new(size); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -112,7 +116,7 @@ operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr) _NOEXCEPT { @@ -120,34 +124,40 @@ operator delete(void* ptr) _NOEXCEPT ::free(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr) _NOEXCEPT { ::operator delete (ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete[](ptr); } +#endif // !__GLIBCXX__ + namespace std { +#ifndef __GLIBCXX__ const nothrow_t nothrow = {}; +#endif #ifndef _LIBCPPABI_VERSION +#ifndef __GLIBCXX__ + new_handler set_new_handler(new_handler handler) _NOEXCEPT { @@ -160,12 +170,16 @@ get_new_handler() _NOEXCEPT return __sync_fetch_and_add(&__new_handler, (new_handler)0); } +#endif // !__GLIBCXX__ + #ifndef LIBCXXRT bad_alloc::bad_alloc() _NOEXCEPT { } +#ifndef __GLIBCXX__ + bad_alloc::~bad_alloc() _NOEXCEPT { } @@ -176,6 +190,8 @@ bad_alloc::what() const _NOEXCEPT return "std::bad_alloc"; } +#endif // !__GLIBCXX__ + #endif //LIBCXXRT bad_array_new_length::bad_array_new_length() _NOEXCEPT @@ -187,12 +203,28 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT } const char* +bad_array_length::what() const _NOEXCEPT +{ + return "bad_array_length"; +} + +bad_array_length::bad_array_length() _NOEXCEPT +{ +} + +bad_array_length::~bad_array_length() _NOEXCEPT +{ +} + +const char* bad_array_new_length::what() const _NOEXCEPT { return "bad_array_new_length"; } -#endif +#endif // _LIBCPPABI_VERSION + +#ifndef LIBSTDCXX void __throw_bad_alloc() @@ -202,4 +234,6 @@ __throw_bad_alloc() #endif } +#endif // !LIBSTDCXX + } // std |