Debian Codegraph @

cores/arduino/new

raw
1 /*
2 Copyright (c) 2014 Arduino. All right reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 See the GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef NEW_H
20 #define NEW_H
21
22 #include <stdlib.h>
23
24 namespace std {
25 struct nothrow_t {};
26 extern const nothrow_t nothrow;
27
28 // These are not actually implemented, to prevent overhead and
29 // complexity. They are still declared to allow implementing
30 // them in user code if needed.
31 typedef void (*new_handler)();
32 new_handler set_new_handler(new_handler new_p) noexcept;
33 new_handler get_new_handler() noexcept;
34
35 // This is normally declared in various headers that we do not have
36 // available, so just define it here. We could also use ::size_t
37 // below, but then anyone including <new> can no longer assume
38 // std::size_t is available.
39 using size_t = ::size_t;
40 } // namespace std
41
42 [[gnu::weak]] void * operator new(std::size_t size);
43 [[gnu::weak]] void * operator new[](std::size_t size);
44
45 [[gnu::weak]] void * operator new(std::size_t size, const std::nothrow_t tag) noexcept;
46 [[gnu::weak]] void * operator new[](std::size_t size, const std::nothrow_t& tag) noexcept;
47
48 void * operator new(std::size_t size, void *place) noexcept;
49 void * operator new[](std::size_t size, void *place) noexcept;
50
51 [[gnu::weak]] void operator delete(void * ptr) noexcept;
52 [[gnu::weak]] void operator delete[](void * ptr) noexcept;
53
54 #if __cplusplus >= 201402L
55 [[gnu::weak]] void operator delete(void* ptr, std::size_t size) noexcept;
56 [[gnu::weak]] void operator delete[](void * ptr, std::size_t size) noexcept;
57 #endif // __cplusplus >= 201402L
58
59 [[gnu::weak]] void operator delete(void* ptr, const std::nothrow_t& tag) noexcept;
60 [[gnu::weak]] void operator delete[](void* ptr, const std::nothrow_t& tag) noexcept;
61
62 void operator delete(void* ptr, void* place) noexcept;
63 void operator delete[](void* ptr, void* place) noexcept;
64
65 #endif
66