-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
new
121 lines (101 loc) · 5.09 KB
/
new
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// new standard header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _NEW_
#define _NEW_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <exception>
#include <vcruntime_new.h>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
#ifdef _BUILD_STD_MODULE
#pragma warning(push)
#pragma warning(disable : 28251) // Inconsistent annotation for 'new': this instance has no annotations.
// Mirroring <vcruntime_new.h> declarations:
_STD_BEGIN
_EXPORT_STD extern "C++" struct nothrow_t;
_EXPORT_STD extern "C++" const nothrow_t nothrow;
_STD_END
_EXPORT_STD extern "C++" _NODISCARD _VCRT_ALLOCATOR void* __CRTDECL operator new(size_t);
_EXPORT_STD extern "C++" _NODISCARD _VCRT_ALLOCATOR void* __CRTDECL operator new(
size_t, const _STD nothrow_t&) noexcept;
_EXPORT_STD extern "C++" _NODISCARD _VCRT_ALLOCATOR void* __CRTDECL operator new[](size_t);
_EXPORT_STD extern "C++" _NODISCARD _VCRT_ALLOCATOR void* __CRTDECL operator new[](
size_t, const _STD nothrow_t&) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete(void*) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete(void*, size_t) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete(void*, const _STD nothrow_t&) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete[](void*) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete[](void*, size_t) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete[](void*, const _STD nothrow_t&) noexcept;
#ifdef __cpp_aligned_new
_STD_BEGIN
#ifdef __EDG__ // TRANSITION, VSO-1618988
extern "C++" {
_EXPORT_STD enum class align_val_t : size_t;
}
#else // ^^^ workaround / no workaround vvv
_EXPORT_STD extern "C++" enum class align_val_t : size_t;
#endif // ^^^ no workaround ^^^
_STD_END
_EXPORT_STD extern "C++" _NODISCARD _VCRT_ALLOCATOR void* __CRTDECL operator new(size_t, _STD align_val_t);
_EXPORT_STD extern "C++" _NODISCARD _VCRT_ALLOCATOR void* __CRTDECL operator new(
size_t, _STD align_val_t, const _STD nothrow_t&) noexcept;
_EXPORT_STD extern "C++" _NODISCARD _VCRT_ALLOCATOR void* __CRTDECL operator new[](size_t, _STD align_val_t);
_EXPORT_STD extern "C++" _NODISCARD _VCRT_ALLOCATOR void* __CRTDECL operator new[](
size_t, _STD align_val_t, const _STD nothrow_t&) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete(void*, _STD align_val_t) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete(void*, size_t, _STD align_val_t) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete(void*, _STD align_val_t, const _STD nothrow_t&) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete[](void*, _STD align_val_t) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete[](void*, size_t, _STD align_val_t) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete[](void*, _STD align_val_t, const _STD nothrow_t&) noexcept;
#endif // defined(__cpp_aligned_new)
_EXPORT_STD extern "C++" _NODISCARD void* __CRTDECL operator new(size_t, void*) noexcept;
_EXPORT_STD extern "C++" _NODISCARD void* __CRTDECL operator new[](size_t, void*) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete(void*, void*) noexcept;
_EXPORT_STD extern "C++" void __CRTDECL operator delete[](void*, void*) noexcept;
#pragma warning(pop)
#endif // defined(_BUILD_STD_MODULE)
_STD_BEGIN
#if _HAS_EXCEPTIONS
_EXPORT_STD class bad_alloc;
_EXPORT_STD class bad_array_new_length;
#else // ^^^ _HAS_EXCEPTIONS / !_HAS_EXCEPTIONS vvv
// <exception> exports bad_alloc and bad_array_new_length.
#endif // ^^^ !_HAS_EXCEPTIONS ^^^
#if _HAS_CXX20
_EXPORT_STD struct destroying_delete_t {
explicit destroying_delete_t() = default;
};
_EXPORT_STD inline constexpr destroying_delete_t destroying_delete{};
#endif // _HAS_CXX20
#if _HAS_CXX17
_EXPORT_STD template <class _Ty>
_NODISCARD_LAUNDER constexpr _Ty* launder(_Ty* _Ptr) noexcept {
static_assert(!is_function_v<_Ty> && !is_void_v<_Ty>,
"N4950 [ptr.launder]/1: Mandates: !is_function_v<T> && !is_void_v<T> is true.");
return __builtin_launder(_Ptr);
}
#if defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64)
_EXPORT_STD inline constexpr size_t hardware_constructive_interference_size = 64;
_EXPORT_STD inline constexpr size_t hardware_destructive_interference_size = 64;
#else // ^^^ supported hardware / unsupported hardware vvv
#error Unsupported architecture
#endif // hardware
#endif // _HAS_CXX17
_EXPORT_STD using new_handler = void(__CLRCALL_PURE_OR_CDECL*)();
_EXPORT_STD extern "C++" _CRTIMP2 new_handler __cdecl set_new_handler(_In_opt_ new_handler) noexcept;
_EXPORT_STD extern "C++" _NODISCARD _CRTIMP2 new_handler __cdecl get_new_handler() noexcept;
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _NEW_