Path: blob/main/contrib/llvm-project/libcxx/src/new_handler.cpp
35154 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include <new>910#include "include/atomic_support.h"1112#if defined(_LIBCPP_ABI_MICROSOFT)13# if !defined(_LIBCPP_ABI_VCRUNTIME)14# define _LIBPCPP_DEFINE_NEW_HANDLER15# endif16#elif defined(LIBCXX_BUILDING_LIBCXXABI)17// nothing to do, we use the one from libc++abi18#elif defined(LIBCXXRT)19# define _LIBPCPP_DEFINE_NEW_HANDLER20#elif defined(__GLIBCXX__)21// nothing to do, we use the one from libstdc++/libsupc++22#else23# define _LIBPCPP_DEFINE_NEW_HANDLER24#endif2526#if defined(_LIBPCPP_DEFINE_NEW_HANDLER)2728namespace std { // purposefully not versioned2930static constinit std::new_handler __new_handler = nullptr;3132new_handler set_new_handler(new_handler handler) noexcept { return __libcpp_atomic_exchange(&__new_handler, handler); }3334new_handler get_new_handler() noexcept { return __libcpp_atomic_load(&__new_handler); }3536} // namespace std3738#endif // _LIBPCPP_DEFINE_NEW_HANDLER394041