brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 49c21d8 Raw
40 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include <new>10 11#include "include/atomic_support.h"12 13#if defined(_LIBCPP_ABI_MICROSOFT)14#  if !defined(_LIBCPP_ABI_VCRUNTIME)15#    define _LIBPCPP_DEFINE_NEW_HANDLER16#  endif17#elif defined(LIBCXX_BUILDING_LIBCXXABI)18// nothing to do, we use the one from libc++abi19#elif defined(LIBCXXRT)20#  define _LIBPCPP_DEFINE_NEW_HANDLER21#elif defined(__GLIBCXX__)22// nothing to do, we use the one from libstdc++/libsupc++23#else24#  define _LIBPCPP_DEFINE_NEW_HANDLER25#endif26 27#if defined(_LIBPCPP_DEFINE_NEW_HANDLER)28 29namespace std { // purposefully not versioned30 31static constinit std::new_handler __new_handler = nullptr;32 33new_handler set_new_handler(new_handler handler) noexcept { return __libcpp_atomic_exchange(&__new_handler, handler); }34 35new_handler get_new_handler() noexcept { return __libcpp_atomic_load(&__new_handler); }36 37} // namespace std38 39#endif // _LIBPCPP_DEFINE_NEW_HANDLER40