| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | #ifndef _NEW |
| 35 | #define _NEW |
| 36 | |
| 37 | #pragma GCC system_header |
| 38 | |
| 39 | #include <bits/c++config.h> |
| 40 | #include <exception> |
| 41 | |
| 42 | #pragma GCC visibility push(default) |
| 43 | |
| 44 | extern "C++" { |
| 45 | |
| 46 | namespace std |
| 47 | { |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | class bad_alloc : public exception |
| 55 | { |
| 56 | public: |
| 57 | bad_alloc() throw() { } |
| 58 | |
| 59 | |
| 60 | |
| 61 | virtual ~bad_alloc() throw(); |
| 62 | |
| 63 | |
| 64 | virtual const char* what() const throw(); |
| 65 | }; |
| 66 | |
| 67 | #if __cplusplus >= 201103L |
| 68 | class bad_array_new_length : public bad_alloc |
| 69 | { |
| 70 | public: |
| 71 | bad_array_new_length() throw() { }; |
| 72 | |
| 73 | |
| 74 | |
| 75 | virtual ~bad_array_new_length() throw(); |
| 76 | |
| 77 | |
| 78 | virtual const char* what() const throw(); |
| 79 | }; |
| 80 | #endif |
| 81 | |
| 82 | #if __cpp_aligned_new |
| 83 | enum class align_val_t: size_t {}; |
| 84 | #endif |
| 85 | |
| 86 | struct nothrow_t |
| 87 | { |
| 88 | #if __cplusplus >= 201103L |
| 89 | explicit nothrow_t() = default; |
| 90 | #endif |
| 91 | }; |
| 92 | |
| 93 | extern const nothrow_t nothrow; |
| 94 | |
| 95 | |
| 96 | |
| 97 | typedef void (*new_handler)(); |
| 98 | |
| 99 | |
| 100 | |
| 101 | new_handler set_new_handler(new_handler) throw(); |
| 102 | |
| 103 | #if __cplusplus >= 201103L |
| 104 | |
| 105 | new_handler get_new_handler() noexcept; |
| 106 | #endif |
| 107 | } |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) |
| 121 | __attribute__((__externally_visible__)); |
| 122 | void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) |
| 123 | __attribute__((__externally_visible__)); |
| 124 | void operator delete(void*) _GLIBCXX_USE_NOEXCEPT |
| 125 | __attribute__((__externally_visible__)); |
| 126 | void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT |
| 127 | __attribute__((__externally_visible__)); |
| 128 | #if __cpp_sized_deallocation |
| 129 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT |
| 130 | __attribute__((__externally_visible__)); |
| 131 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT |
| 132 | __attribute__((__externally_visible__)); |
| 133 | #endif |
| 134 | void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT |
| 135 | __attribute__((__externally_visible__)); |
| 136 | void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT |
| 137 | __attribute__((__externally_visible__)); |
| 138 | void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT |
| 139 | __attribute__((__externally_visible__)); |
| 140 | void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT |
| 141 | __attribute__((__externally_visible__)); |
| 142 | #if __cpp_aligned_new |
| 143 | void* operator new(std::size_t, std::align_val_t) |
| 144 | __attribute__((__externally_visible__)); |
| 145 | void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) |
| 146 | _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); |
| 147 | void operator delete(void*, std::align_val_t) |
| 148 | _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); |
| 149 | void operator delete(void*, std::align_val_t, const std::nothrow_t&) |
| 150 | _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); |
| 151 | void* operator new[](std::size_t, std::align_val_t) |
| 152 | __attribute__((__externally_visible__)); |
| 153 | void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) |
| 154 | _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); |
| 155 | void operator delete[](void*, std::align_val_t) |
| 156 | _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); |
| 157 | void operator delete[](void*, std::align_val_t, const std::nothrow_t&) |
| 158 | _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); |
| 159 | #if __cpp_sized_deallocation |
| 160 | void operator delete(void*, std::size_t, std::align_val_t) |
| 161 | _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); |
| 162 | void operator delete[](void*, std::size_t, std::align_val_t) |
| 163 | _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); |
| 164 | #endif |
| 165 | #endif |
| 166 | |
| 167 | |
| 168 | inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT |
| 169 | { return __p; } |
| 170 | inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT |
| 171 | { return __p; } |
| 172 | |
| 173 | |
| 174 | inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } |
| 175 | inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } |
| 176 | |
| 177 | } |
| 178 | |
| 179 | #if __cplusplus > 201402L |
| 180 | #if __GNUC__ >= 7 |
| 181 | # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 |
| 182 | #elif defined __has_builtin |
| 183 | |
| 184 | # if __has_builtin(__builtin_launder) |
| 185 | # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 |
| 186 | # endif |
| 187 | #endif |
| 188 | |
| 189 | #ifdef _GLIBCXX_HAVE_BUILTIN_LAUNDER |
| 190 | namespace std |
| 191 | { |
| 192 | #define __cpp_lib_launder 201606 |
| 193 | |
| 194 | template<typename _Tp> |
| 195 | constexpr _Tp* |
| 196 | launder(_Tp* __p) noexcept |
| 197 | { return __builtin_launder(__p); } |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | template<typename _Ret, typename... _Args _GLIBCXX_NOEXCEPT_PARM> |
| 203 | void launder(_Ret (*)(_Args...) _GLIBCXX_NOEXCEPT_QUAL) = delete; |
| 204 | template<typename _Ret, typename... _Args _GLIBCXX_NOEXCEPT_PARM> |
| 205 | void launder(_Ret (*)(_Args......) _GLIBCXX_NOEXCEPT_QUAL) = delete; |
| 206 | |
| 207 | void launder(void*) = delete; |
| 208 | void launder(const void*) = delete; |
| 209 | void launder(volatile void*) = delete; |
| 210 | void launder(const volatile void*) = delete; |
| 211 | } |
| 212 | #endif |
| 213 | #undef _GLIBCXX_HAVE_BUILTIN_LAUNDER |
| 214 | #endif |
| 215 | |
| 216 | #pragma GCC visibility pop |
| 217 | |
| 218 | #endif |
| 219 | |