| 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-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef _LIBCPP___NEW_GLOBAL_NEW_DELETE_H |
| 10 | #define _LIBCPP___NEW_GLOBAL_NEW_DELETE_H |
| 11 | |
| 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> |
| 14 | #include <__new/align_val_t.h> |
| 15 | #include <__new/exceptions.h> |
| 16 | #include <__new/nothrow_t.h> |
| 17 | |
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | # pragma GCC system_header |
| 20 | #endif |
| 21 | |
| 22 | #if defined(_LIBCPP_CXX03_LANG) |
| 23 | # define _THROW_BAD_ALLOC throw(std::bad_alloc) |
| 24 | #else |
| 25 | # define _THROW_BAD_ALLOC |
| 26 | #endif |
| 27 | |
| 28 | #if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L |
| 29 | # define _LIBCPP_HAS_SIZED_DEALLOCATION 1 |
| 30 | #else |
| 31 | # define _LIBCPP_HAS_SIZED_DEALLOCATION 0 |
| 32 | #endif |
| 33 | |
| 34 | #if defined(_LIBCPP_ABI_VCRUNTIME) |
| 35 | # include <new.h> |
| 36 | #else |
| 37 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC; |
| 38 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT |
| 39 | _LIBCPP_NOALIAS; |
| 40 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; |
| 41 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; |
| 42 | # if _LIBCPP_HAS_SIZED_DEALLOCATION |
| 43 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; |
| 44 | # endif |
| 45 | |
| 46 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC; |
| 47 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT |
| 48 | _LIBCPP_NOALIAS; |
| 49 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; |
| 50 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; |
| 51 | # if _LIBCPP_HAS_SIZED_DEALLOCATION |
| 52 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT; |
| 53 | # endif |
| 54 | |
| 55 | # if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION |
| 56 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; |
| 57 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* |
| 58 | operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; |
| 59 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; |
| 60 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; |
| 61 | # if _LIBCPP_HAS_SIZED_DEALLOCATION |
| 62 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; |
| 63 | # endif |
| 64 | |
| 65 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* |
| 66 | operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; |
| 67 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* |
| 68 | operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; |
| 69 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; |
| 70 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; |
| 71 | # if _LIBCPP_HAS_SIZED_DEALLOCATION |
| 72 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; |
| 73 | # endif |
| 74 | # endif |
| 75 | #endif |
| 76 | |
| 77 | #endif // _LIBCPP___NEW_GLOBAL_NEW_DELETE_H |
| 78 | |