xref: /reactos/sdk/include/vcruntime/vcruntime.h (revision d6eebaa4)
1 
2 #pragma once
3 
4 #include <_mingw.h>
5 #include <sal.h>
6 #include <vadefs.h>
7 
8 #define _CRT_STRINGIZE_(_Value) #_Value
9 #define _CRT_STRINGIZE(_Value) _CRT_STRINGIZE_(_Value)
10 
11 #define _CRT_WIDE_(_String) L ## _String
12 #define _CRT_WIDE(_String) _CRT_WIDE_(_String)
13 
14 #define _CRT_CONCATENATE_(a, b) a ## b
15 #define _CRT_CONCATENATE(a, b)  _CRT_CONCATENATE_(a, b)
16 
17 #define _CRT_UNPARENTHESIZE_(...) __VA_ARGS__
18 #define _CRT_UNPARENTHESIZE(...)  _CRT_UNPARENTHESIZE_ __VA_ARGS__
19 
20 #ifndef _MSC_VER
21 #define __pragma(x) _Pragma(_CRT_STRINGIZE(x))
22 #endif
23 
24 #ifdef __cplusplus
25     #define _CRT_BEGIN_C_HEADER \
26         __pragma(pack(push, _CRT_PACKING_IDENTIFIER, _CRT_PACKING)) \
27         extern "C" {
28     #define _CRT_END_C_HEADER \
29         } \
30         __pragma(pack(pop, _CRT_PACKING_IDENTIFIER))
31 #else
32     #define _CRT_BEGIN_C_HEADER \
33         __pragma(pack(push, _CRT_PACKING_IDENTIFIER, _CRT_PACKING))
34     #define _CRT_END_C_HEADER \
35         __pragma(pack(pop, _CRT_PACKING_IDENTIFIER))
36 #endif
37 
38 _CRT_BEGIN_C_HEADER
39 
40 #ifndef _CRTIMP
41  #ifdef CRTDLL /* Defined for ntdll, crtdll, msvcrt, etc */
42   #define _CRTIMP
43  #elif defined(_DLL)
44   #define _CRTIMP __declspec(dllimport)
45  #else /* !CRTDLL && !_DLL */
46   #define _CRTIMP
47  #endif /* CRTDLL || _DLL */
48 #endif /* !_CRTIMP */
49 
50 #ifndef _VCRTIMP
51  #ifndef _VCRT_DEFINED_CRTIMP
52   #define _VCRTIMP _CRTIMP
53  #elif defined(_VCRT_BUILD) && defined(CRTDLL) && !defined(_VCRT_SAT_1)
54   #define _VCRTIMP __declspec(dllexport)
55  #else
56   #define _VCRTIMP
57  #endif
58 #endif
59 
60 #ifndef __CRTDECL
61 #define __CRTDECL __cdecl
62 #endif
63 
64 #ifndef _CONST_RETURN
65 #ifdef __cplusplus
66 #define _CONST_RETURN const
67 #define _CRT_CONST_CORRECT_OVERLOADS
68 #else
69 #define _CONST_RETURN
70 #endif
71 #endif
72 
73 #ifdef __GNUC__
74 #define _CRT_DEPRECATE_TEXT(_Text) __attribute__ ((deprecated))
75 #elif defined(_MSC_VER)
76 #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
77 #else
78 #define _CRT_DEPRECATE_TEXT(_Text)
79 #endif
80 
81 #ifndef _CRT_INSECURE_DEPRECATE
82 # ifdef _CRT_SECURE_NO_DEPRECATE
83 #  define _CRT_INSECURE_DEPRECATE(_Replacement)
84 # else
85 #  define _CRT_INSECURE_DEPRECATE(_Replacement) \
86     _CRT_DEPRECATE_TEXT("This may be unsafe, Try " #_Replacement " instead!")
87 # endif
88 #endif
89 
90 #ifndef _CRT_INSECURE_DEPRECATE_MEMORY
91 #define _CRT_INSECURE_DEPRECATE_MEMORY(_Replacement)
92 #endif
93 
94 #ifndef _SIZE_T_DEFINED
95 #define _SIZE_T_DEFINED
96 #undef size_t
97 #ifdef _WIN64
98 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
99   typedef unsigned int size_t __attribute__ ((mode (DI)));
100 #else
101   typedef unsigned __int64 size_t;
102 #endif
103 #else
104   typedef unsigned int size_t;
105 #endif
106 #endif
107 
108 #ifndef _INTPTR_T_DEFINED
109 #define _INTPTR_T_DEFINED
110 #ifndef __intptr_t_defined
111 #define __intptr_t_defined
112 #undef intptr_t
113 #ifdef _WIN64
114 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
115   typedef int intptr_t __attribute__ ((mode (DI)));
116 #else
117   typedef __int64 intptr_t;
118 #endif
119 #else
120   typedef int intptr_t;
121 #endif
122 #endif
123 #endif
124 
125 #ifndef _PTRDIFF_T_DEFINED
126 #define _PTRDIFF_T_DEFINED
127 #ifndef _PTRDIFF_T_
128 #undef ptrdiff_t
129 #ifdef _WIN64
130 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
131   typedef int ptrdiff_t __attribute__ ((mode (DI)));
132 #else
133   __MINGW_EXTENSION typedef __int64 ptrdiff_t;
134 #endif
135 #else
136   typedef int ptrdiff_t;
137 #endif
138 #endif
139 #endif
140 
141 #ifndef _WCHAR_T_DEFINED
142 #define _WCHAR_T_DEFINED
143 #if defined(_MSC_VER) || !defined(__cplusplus)
144   typedef unsigned short wchar_t;
145 #endif
146 #endif
147 
148 #ifndef _CRT_ALIGN
149  #if defined (__midl) || defined(__WIDL__)
150   #define _CRT_ALIGN(x)
151  #elif defined(_MSC_VER)
152   #define _CRT_ALIGN(x) __declspec(align(x))
153  #else
154   #define _CRT_ALIGN(x) __attribute__ ((aligned(x)))
155  #endif
156 #endif
157 
158 #if defined (__midl) || defined(__WIDL__)
159   #define _VCRT_ALIGN(x)
160 #elif defined(_MSC_VER)
161   #define _CRT_ALIGN(x) __declspec(align(x))
162 #else
163   #define _VCRT_ALIGN(x) __attribute__ ((aligned(x)))
164 #endif
165 
166 #if defined __cplusplus
167     typedef bool  __vcrt_bool;
168 #elif defined __midl
169     typedef char __vcrt_bool;
170 #else
171     typedef _Bool __vcrt_bool;
172 #endif
173 
174 #ifndef _HAS_NODISCARD
175  #ifndef __has_cpp_attribute
176   #define _HAS_NODISCARD 0
177  #elif __has_cpp_attribute(nodiscard) >= 201603L
178   #define _HAS_NODISCARD 1
179  #else
180   #define _HAS_NODISCARD 0
181  #endif
182 #endif // _HAS_NODISCARD
183 
184 #if _HAS_NODISCARD
185  #define _NODISCARD [[nodiscard]]
186 #else
187  #define _NODISCARD
188 #endif // _HAS_NODISCARD
189 
190 #if defined _M_X64 || defined _M_ARM || defined _M_ARM64
191     #define _UNALIGNED __unaligned
192 #else
193     #define _UNALIGNED
194 #endif
195 
196 #ifdef __cplusplus
197     // Safer than the C definition, as it ensures that the argument is not a pointer
198     extern "C++" template<typename _T, size_t _Size>
199     char (*__crt_countof_helper(_UNALIGNED _T(&_Array)[_Size]))[_Size];
200     #define __crt_countof(_Array) sizeof(*__crt_countof_helper(_Array))
201 #else
202     #define __crt_countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
203 #endif
204 
205 void __cdecl __security_init_cookie(void);
206 extern uintptr_t __security_cookie;
207 
208 _CRT_END_C_HEADER
209