chromium/third_party/libc++/src/src/new.cpp

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "include/overridable_function.h"
#include <__assert>
#include <__memory/aligned_alloc.h>
#include <cstddef>
#include <cstdlib>
#include <new>

#if !defined(__GLIBCXX__) && !defined(_LIBCPP_ABI_VCRUNTIME)

// The code below is copied as-is into libc++abi's libcxxabi/src/stdlib_new_delete.cpp
// file. The version in this file is the canonical one.

inline void __throw_bad_alloc_shim() {}

#define _LIBCPP_ASSERT_SHIM(expr, str)

// ------------------ BEGIN COPY ------------------
// Implement all new and delete operators as weak definitions
// in this shared library, so that they can be overridden by programs
// that define non-weak copies of the functions.

static void* operator_new_impl(std::size_t size) {}

_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC {}

_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {}

_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](size_t size) _THROW_BAD_ALLOC {}

_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {}

_LIBCPP_WEAK void operator delete(void* ptr) noexcept {}

_LIBCPP_WEAK void operator delete(void* ptr, const std::nothrow_t&) noexcept {}

_LIBCPP_WEAK void operator delete(void* ptr, size_t) noexcept {}

_LIBCPP_WEAK void operator delete[](void* ptr) noexcept {}

_LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept {}

_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept {}

#  if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)

static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) {}

_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*
operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {}

_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {}

_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*
operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {}

_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {}

_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t) noexcept {}

_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept {}

_LIBCPP_WEAK void operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept {}

_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment) noexcept {}

_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept {}

_LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignment) noexcept {}

#  endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
// ------------------ END COPY ------------------

#endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME