xref: /reactos/sdk/include/vcruntime/crtdefs.h (revision 90e95d15)
1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the w64 mingw-runtime package.
4  * No warranty is given; refer to the file DISCLAIMER within this package.
5  */
6 #include <vcruntime.h>
7 #include <specstrings.h>
8 
9 #ifndef _INC_CRTDEFS
10 #define _INC_CRTDEFS
11 
12 #ifndef NULL
13 #ifdef __cplusplus
14 #define NULL 0
15 #else
16 #define NULL ((void *)0)
17 #endif
18 #endif
19 
20 #ifdef _USE_32BIT_TIME_T
21 #ifdef _WIN64
22 #error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64
23 #undef _USE_32BIT_TIME_T
24 #endif
25 #else
26 #if _INTEGRAL_MAX_BITS < 64
27 #define _USE_32BIT_TIME_T
28 #endif
29 #endif
30 
31 #pragma pack(push,_CRT_PACKING)
32 
33 /* Disable non-ANSI C definitions if compiling with __STDC__ */
34 #if (!defined _CRT_DECLARE_NONSTDC_NAMES || !_CRT_DECLARE_NONSTDC_NAMES) && (defined _CRT_DECLARE_NONSTDC_NAMES || __STDC__)
35 #define NO_OLDNAMES
36 #endif
37 
38 #if defined(__GNUC__) && !defined(__clang__)
39   #define _CRT_DISABLE_GCC_WARNINGS \
40             _Pragma("GCC diagnostic push") \
41             _Pragma("GCC diagnostic ignored \"-Wbuiltin-declaration-mismatch\"") \
42             _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
43   #define _CRT_RESTORE_GCC_WARNINGS _Pragma("GCC diagnostic pop")
44 #else // __GNUC__
45   #define _CRT_DISABLE_GCC_WARNINGS
46   #define _CRT_RESTORE_GCC_WARNINGS
47 #endif // __GNUC__
48 
49 /** Properties ***************************************************************/
50 
51 
52 #ifndef _CRT_DEFER_MACRO
53 #define _CRT_DEFER_MACRO(M,...) M(__VA_ARGS__)
54 #endif
55 
56 #ifndef _W64
57  #if !defined(_midl) && defined(_X86_) && _MSC_VER >= 1300
58   #define _W64 __w64
59  #else
60   #define _W64
61  #endif
62 #endif
63 
64 //#define _CRT_ALTERNATIVE_INLINES
65 
66 #ifndef _CRTIMP_ALT
67  #ifdef _DLL
68   #ifdef _CRT_ALTERNATIVE_INLINES
69    #define _CRTIMP_ALT
70   #else
71    #define _CRTIMP_ALT _CRTIMP
72    #define _CRT_ALTERNATIVE_IMPORTED
73   #endif
74  #else
75   #define _CRTIMP_ALT
76  #endif
77 #endif
78 
79 #ifndef _CRTDATA
80  #ifdef _M_CEE_PURE
81   #define _CRTDATA(x) x
82  #else
83   #define _CRTDATA(x) _CRTIMP x
84  #endif
85 #endif
86 
87 #ifndef _CRTIMP2
88  #define _CRTIMP2 _CRTIMP
89 #endif
90 
91 #ifndef _CRTIMP_PURE
92  #define _CRTIMP_PURE _CRTIMP
93 #endif
94 
95 #ifndef _CRTIMP_ALTERNATIVE
96  #define _CRTIMP_ALTERNATIVE _CRTIMP
97  #define _CRT_ALTERNATIVE_IMPORTED
98 #endif
99 
100 #ifndef _CRTIMP_NOIA64
101  #ifdef __ia64__
102   #define _CRTIMP_NOIA64
103  #else
104   #define _CRTIMP_NOIA64 _CRTIMP
105  #endif
106 #endif
107 
108 #ifndef _MRTIMP2
109  #define _MRTIMP2  _CRTIMP
110 #endif
111 
112 #ifndef _MCRTIMP
113  #define _MCRTIMP _CRTIMP
114 #endif
115 
116 #ifndef _PGLOBAL
117  #define _PGLOBAL
118 #endif
119 
120 #ifndef _AGLOBAL
121  #define _AGLOBAL
122 #endif
123 
124 #ifndef UNALIGNED
125 #if defined(__ia64__) || defined(__x86_64) || defined(__arm__) || defined(__arm64__)
126 #define UNALIGNED __unaligned
127 #else
128 #define UNALIGNED
129 #endif
130 #endif
131 
132 #ifndef _CRTNOALIAS
133 #define _CRTNOALIAS
134 #endif
135 
136 #ifndef _CRT_UNUSED
137 #define _CRT_UNUSED(x) (void)x
138 #endif
139 
140 #define __crt_typefix(ctype)
141 
142 #ifndef _STATIC_ASSERT
143   #ifdef __cplusplus
144     #define _STATIC_ASSERT(expr) static_assert((expr), #expr)
145   #elif defined(__clang__) || defined(__GNUC__)
146     #define _STATIC_ASSERT(expr) _Static_assert((expr), #expr)
147   #else
148     #define _STATIC_ASSERT(expr) extern char (*__static_assert__(void)) [(expr) ? 1 : -1]
149   #endif
150 #endif /* _STATIC_ASSERT */
151 
152 /** Deprecated ***************************************************************/
153 
154 #ifndef __STDC_WANT_SECURE_LIB__
155 #define __STDC_WANT_SECURE_LIB__ 1
156 #endif
157 
158 #ifndef _CRT_INSECURE_DEPRECATE_CORE
159 # ifdef _CRT_SECURE_NO_DEPRECATE_CORE
160 #  define _CRT_INSECURE_DEPRECATE_CORE(_Replacement)
161 # else
162 #  define _CRT_INSECURE_DEPRECATE_CORE(_Replacement) \
163     _CRT_DEPRECATE_TEXT("This may be unsafe, Try " #_Replacement " instead! Enable _CRT_SECURE_NO_DEPRECATE to avoid thie warning.")
164 # endif
165 #endif
166 
167 #ifndef _CRT_NONSTDC_DEPRECATE
168 # ifdef _CRT_NONSTDC_NO_DEPRECATE
169 #  define _CRT_NONSTDC_DEPRECATE(_Replacement)
170 # else
171 #  define _CRT_NONSTDC_DEPRECATE(_Replacement) \
172     _CRT_DEPRECATE_TEXT("Deprecated POSIX name, Try " #_Replacement " instead!")
173 # endif
174 #endif
175 
176 #ifndef _CRT_INSECURE_DEPRECATE_GLOBALS
177 #define _CRT_INSECURE_DEPRECATE_GLOBALS(_Replacement)
178 #endif
179 
180 #ifndef _CRT_MANAGED_HEAP_DEPRECATE
181 #define _CRT_MANAGED_HEAP_DEPRECATE
182 #endif
183 
184 #ifndef _CRT_OBSOLETE
185 #define _CRT_OBSOLETE(_NewItem)
186 #endif
187 
188 #ifndef _CRT_JIT_INTRINSIC
189 #define _CRT_JIT_INTRINSIC
190 #endif
191 
192 
193 /** Constants ****************************************************************/
194 
195 #define _ARGMAX 100
196 
197 #ifndef _TRUNCATE
198 #define _TRUNCATE ((size_t)-1)
199 #endif
200 
201 #ifndef __REACTOS__
202 #define __STDC_SECURE_LIB__ 200411L
203 #define __GOT_SECURE_LIB__ __STDC_SECURE_LIB__
204 #define _SECURECRT_FILL_BUFFER_PATTERN 0xFD
205 #endif
206 
207 
208 /** Type definitions *********************************************************/
209 
210 #ifdef __cplusplus
211 extern "C" {
212 #endif
213 
214 #ifndef _WCTYPE_T_DEFINED
215 #define _WCTYPE_T_DEFINED
216   typedef unsigned short wint_t;
217   typedef unsigned short wctype_t;
218 #endif
219 
220 #ifndef _ERRCODE_DEFINED
221 #define _ERRCODE_DEFINED
222   typedef int errcode;
223   typedef int errno_t;
224 #endif
225 
226 #ifndef _TIME32_T_DEFINED
227 #define _TIME32_T_DEFINED
228   typedef long __time32_t;
229 #endif
230 
231 #ifndef _TIME64_T_DEFINED
232 #define _TIME64_T_DEFINED
233 #if _INTEGRAL_MAX_BITS >= 64
234   __MINGW_EXTENSION typedef __int64 __time64_t;
235 #endif
236 #endif
237 
238 #ifndef _TIME_T_DEFINED
239 #define _TIME_T_DEFINED
240 #ifdef _USE_32BIT_TIME_T
241   typedef __time32_t time_t;
242 #else
243   typedef __time64_t time_t;
244 #endif
245 #endif
246 
247 struct threadmbcinfostruct;
248 typedef struct threadmbcinfostruct *pthreadmbcinfo;
249 
250 #ifndef _TAGLC_ID_DEFINED
251 #define _TAGLC_ID_DEFINED
252   typedef struct tagLC_ID {
253     unsigned short wLanguage;
254     unsigned short wCountry;
255     unsigned short wCodePage;
256   } LC_ID,*LPLC_ID;
257 #endif
258 
259 #ifndef _THREADLOCALEINFO
260 #define _THREADLOCALEINFO
261   typedef struct threadlocaleinfostruct {
262     int refcount;
263     unsigned int lc_codepage;
264     unsigned int lc_collate_cp;
265     unsigned long lc_handle[6];
266     LC_ID lc_id[6];
267     struct {
268       char *locale;
269       wchar_t *wlocale;
270       int *refcount;
271       int *wrefcount;
272     } lc_category[6];
273     int lc_clike;
274     int mb_cur_max;
275     int *lconv_intl_refcount;
276     int *lconv_num_refcount;
277     int *lconv_mon_refcount;
278     struct lconv *lconv;
279     int *ctype1_refcount;
280     unsigned short *ctype1;
281     const unsigned short *pctype;
282     const unsigned char *pclmap;
283     const unsigned char *pcumap;
284     struct __lc_time_data *lc_time_curr;
285   } threadlocinfo, *pthreadlocinfo;
286 #endif
287 
288 struct __lc_time_data;
289 
290 #ifdef __cplusplus
291 }
292 #endif
293 
294 #if defined(_PREFAST_) && defined(_PFT_SHOULD_CHECK_RETURN)
295 #define _Check_return_opt_ _Check_return_
296 #else
297 #define _Check_return_opt_
298 #endif
299 
300 #if defined(_PREFAST_) && defined(_PFT_SHOULD_CHECK_RETURN_WAT)
301 #define _Check_return_wat_ _Check_return_
302 #else
303 #define _Check_return_wat_
304 #endif
305 
306 #pragma pack(pop)
307 
308 /* GCC-style diagnostics */
309 #ifndef PRAGMA_DIAGNOSTIC_IGNORED
310 # ifdef __clang__
311 #  define PRAGMA_DIAGNOSTIC_PUSH() _Pragma("clang diagnostic push")
312 #  define PRAGMA_DIAGNOSTIC_IGNORED(__x) \
313     _Pragma(_CRT_STRINGIZE(clang diagnostic ignored _CRT_DEFER_MACRO(_CRT_STRINGIZE,__x)))
314 #  define PRAGMA_DIAGNOSTIC_POP() _Pragma("clang diagnostic pop")
315 # elif defined (__GNUC__)
316 #  define PRAGMA_DIAGNOSTIC_PUSH() _Pragma("GCC diagnostic push")
317 #  define PRAGMA_DIAGNOSTIC_IGNORED(__x) \
318     _Pragma("GCC diagnostic ignored \"-Wpragmas\"") /* This allows us to use it for unkonwn warnings */ \
319     _Pragma(_CRT_STRINGIZE(GCC diagnostic ignored _CRT_DEFER_MACRO(_CRT_STRINGIZE,__x))) \
320     _Pragma("GCC diagnostic error \"-Wpragmas\"") /* This makes sure that we don't have side effects because we disabled it for our own use. This will be popped anyway. */
321 #  define PRAGMA_DIAGNOSTIC_POP() _Pragma("GCC diagnostic pop")
322 # else
323 #  define PRAGMA_DIAGNOSTIC_PUSH()
324 #  define PRAGMA_DIAGNOSTIC_IGNORED(__x)
325 #  define PRAGMA_DIAGNOSTIC_POP()
326 # endif
327 #endif
328 
329 #endif /* !_INC_CRTDEFS */
330