From 9055a62ed4f32c6b66f74580f4b20a10c17bd83c Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Thu, 21 Apr 2011 16:40:57 +0900 Subject: [PATCH] new: move __new_hander to _STD. --- include/new | 12 ++++++++++++ src/new.cpp | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/new b/include/new index 68f0274b..bd83731c 100644 --- a/include/new +++ b/include/new @@ -90,6 +90,18 @@ _LIBCPP_VISIBLE new_handler get_new_handler() throw(); } // std +#if __APPLE__ + #include + // 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 +#else // __APPLE__ + _LIBCPP_BEGIN_NAMESPACE_STD + extern ::std::new_handler __new_handler; + _LIBCPP_END_NAMESPACE_STD +#endif + _LIBCPP_VISIBLE void* operator new(std::size_t) throw(std::bad_alloc); _LIBCPP_VISIBLE void* operator new(std::size_t, const std::nothrow_t&) throw(); _LIBCPP_VISIBLE void operator delete(void*) throw(); diff --git a/src/new.cpp b/src/new.cpp index 55e70ad0..7e53230e 100644 --- a/src/new.cpp +++ b/src/new.cpp @@ -18,7 +18,9 @@ // in the ABI library and named __cxa_new_handler. #define __new_handler __cxxabiapple::__cxa_new_handler #else // __APPLE__ - static std::new_handler __new_handler; + _LIBCPP_BEGIN_NAMESPACE_STD + ::std::new_handler __new_handler; + _LIBCPP_END_NAMESPACE_STD #endif // Implement all new and delete operators as weak definitions