diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt --- a/libcxx/src/CMakeLists.txt +++ b/libcxx/src/CMakeLists.txt @@ -35,6 +35,7 @@ mutex.cpp mutex_destructor.cpp new.cpp + new_handler.cpp optional.cpp random_shuffle.cpp ryu/d2fixed.cpp @@ -52,7 +53,6 @@ support/runtime/exception_pointer_glibcxx.ipp support/runtime/exception_pointer_msvc.ipp support/runtime/exception_pointer_unimplemented.ipp - support/runtime/new_handler_fallback.ipp support/runtime/stdexcept_default.ipp support/runtime/stdexcept_vcruntime.ipp system_error.cpp diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp --- a/libcxx/src/new.cpp +++ b/libcxx/src/new.cpp @@ -10,23 +10,6 @@ #include #include -#include "include/atomic_support.h" - -#if defined(_LIBCPP_ABI_MICROSOFT) -# if !defined(_LIBCPP_ABI_VCRUNTIME) -# include "support/runtime/new_handler_fallback.ipp" -# endif -#elif defined(LIBCXX_BUILDING_LIBCXXABI) -# include -#elif defined(LIBCXXRT) -# include -# include "support/runtime/new_handler_fallback.ipp" -#elif defined(__GLIBCXX__) - // nothing to do -#else -# include "support/runtime/new_handler_fallback.ipp" -#endif - namespace std { diff --git a/libcxx/src/support/runtime/new_handler_fallback.ipp b/libcxx/src/new_handler.cpp rename from libcxx/src/support/runtime/new_handler_fallback.ipp rename to libcxx/src/new_handler.cpp --- a/libcxx/src/support/runtime/new_handler_fallback.ipp +++ b/libcxx/src/new_handler.cpp @@ -1,4 +1,3 @@ -// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -7,7 +6,27 @@ // //===----------------------------------------------------------------------===// -namespace std { +#include + +#include "include/atomic_support.h" + +#if defined(_LIBCPP_ABI_MICROSOFT) +# if !defined(_LIBCPP_ABI_VCRUNTIME) +# define _LIBPCPP_DEFINE_NEW_HANDLER +# endif +#elif defined(LIBCXX_BUILDING_LIBCXXABI) + // nothing to do, we use the one from libc++abi +#elif defined(LIBCXXRT) +# define _LIBPCPP_DEFINE_NEW_HANDLER +#elif defined(__GLIBCXX__) + // nothing to do, we use the one from libstdc++/libsupc++ +#else +# define _LIBPCPP_DEFINE_NEW_HANDLER +#endif + +#if defined(_LIBPCPP_DEFINE_NEW_HANDLER) + +namespace std { // purposefully not versioned static constinit std::new_handler __new_handler = nullptr; @@ -24,3 +43,5 @@ } } // namespace std + +#endif // _LIBPCPP_DEFINE_NEW_HANDLER diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt --- a/libcxx/utils/data/ignore_format.txt +++ b/libcxx/utils/data/ignore_format.txt @@ -809,6 +809,7 @@ libcxx/src/mutex.cpp libcxx/src/mutex_destructor.cpp libcxx/src/new.cpp +libcxx/src/new_handler.cpp libcxx/src/optional.cpp libcxx/src/random.cpp libcxx/src/random_shuffle.cpp @@ -830,7 +831,6 @@ libcxx/src/support/runtime/exception_pointer_glibcxx.ipp libcxx/src/support/runtime/exception_pointer_msvc.ipp libcxx/src/support/runtime/exception_pointer_unimplemented.ipp -libcxx/src/support/runtime/new_handler_fallback.ipp libcxx/src/support/runtime/stdexcept_default.ipp libcxx/src/support/runtime/stdexcept_vcruntime.ipp libcxx/src/support/win32/locale_win32.cpp