sync to trunk head (37853) (except rbuild changes)
[reactos.git] / reactos / include / crt / _mingw.h
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
7 #ifndef _INC_CRTDEFS
8 #define _INC_CRTDEFS
9
10 #ifndef MINGW64
11 #define MINGW64
12 #define MINGW64_VERSION 1.0
13 #define MINGW64_VERSION_MAJOR 1
14 #define MINGW64_VERSION_MINOR 0
15 #define MINGW64_VERSION_STATE "alpha"
16 #endif
17
18 #ifdef _WIN64
19 #ifdef __stdcall
20 #undef __stdcall
21 #endif
22 #define __stdcall
23 #endif
24
25 #if defined(_MSC_VER)
26 # ifdef _DLL
27 # ifndef __MINGW_IMPORT
28 # define __MINGW_IMPORT __declspec(dllimport)
29 # endif
30 # ifndef _CRTIMP
31 # define _CRTIMP __declspec(dllimport)
32 # endif
33 # else
34 # ifndef __MINGW_IMPORT
35 # define __MINGW_IMPORT
36 # endif
37 # ifndef _CRTIMP
38 # define _CRTIMP
39 # endif
40 #endif
41 # define __DECLSPEC_SUPPORTED
42 # define __attribute__(x) /* nothing */
43 # define __restrict__/* nothing */
44 #elif defined(__GNUC__)
45 # ifdef __declspec
46 # ifndef __MINGW_IMPORT
47 # ifdef _DLL
48 /* Note the extern. This is needed to work around GCC's
49 limitations in handling dllimport attribute. */
50 # define __MINGW_IMPORT extern __attribute__ ((__dllimport__))
51 # else
52 # define __MINGW_IMPORT extern
53 # endif
54 # endif
55 # ifndef _CRTIMP
56 # undef __USE_CRTIMP
57 # if !defined (_CRTBLD) && !defined (_SYSCRT)
58 # define __USE_CRTIMP 1
59 # endif
60 # ifdef __USE_CRTIMP
61 # ifdef _DLL
62 # define _CRTIMP __attribute__ ((dllimport))
63 # else
64 # define _CRTIMP
65 # endif
66 # else
67 # define _CRTIMP
68 # endif
69 # endif
70 # define __DECLSPEC_SUPPORTED
71 # else /* __declspec */
72 # undef __DECLSPEC_SUPPORTED
73 # undef __MINGW_IMPORT
74 # ifndef _CRTIMP
75 # define _CRTIMP
76 # endif
77 # endif /* __declspec */
78 #else
79 # ifndef __MINGW_IMPORT
80 # define __MINGW_IMPORT __declspec(dllimport)
81 # endif
82 # ifndef _CRTIMP
83 # define _CRTIMP __declspec(dllimport)
84 # endif
85 # define __DECLSPEC_SUPPORTED
86 # define __attribute__(x)/* nothing */
87 #endif
88
89 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
90 #define __MINGW_GNUC_PREREQ(major, minor) \
91 (__GNUC__ > (major) \
92 || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
93 #else
94 #define __MINGW_GNUC_PREREQ(major, minor) 0
95 #endif
96
97 #if defined (_MSC_VER)
98 #define __MINGW_MSC_PREREQ(major,minor) \
99 ((_MSC_VER /100) > (major) \
100 || ((_MSC)VER /100) == (major) && (_MSC_VER) % 100) >=(minor)))
101 #else
102 #define __MINGW_MSC_PREREQ(major, minor) 0
103 #endif
104
105 #define USE___UUIDOF 0
106
107 #ifdef __cplusplus
108 # define __CRT_INLINE inline
109 #else
110 # if defined(_MSC_VER)
111 # define __CRT_INLINE __inline
112 # elif __GNUC_STDC_INLINE__
113 # define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
114 # else
115 # define __CRT_INLINE extern __inline__
116 # endif
117 #endif
118
119 #ifdef __cplusplus
120 # define __UNUSED_PARAM(x)
121 #else
122 # ifdef __GNUC__
123 # define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
124 # else
125 # define __UNUSED_PARAM(x) x
126 # endif
127 #endif
128
129 #ifdef __GNUC__
130 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
131 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
132 #elif __MINGW_MSC_PREREQ(12, 0)
133 #define __MINGW_ATTRIB_NORETURN __declspec(noreturn)
134 #define __MINGW_ATTRIB_CONST
135 #else
136 #define __MINGW_ATTRIB_NORETURN
137 #define __MINGW_ATTRIB_CONST
138 #endif
139
140 #if __MINGW_GNUC_PREREQ (3, 0)
141 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
142 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
143 #else
144 #define __MINGW_ATTRIB_MALLOC
145 #define __MINGW_ATTRIB_PURE
146 #endif
147
148 /* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
149 variadiac macro facility, because variadic macros cause syntax
150 errors with --traditional-cpp. */
151 #if __MINGW_GNUC_PREREQ (3, 3)
152 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
153 #else
154 #define __MINGW_ATTRIB_NONNULL(arg)
155 #endif /* GNUC >= 3.3 */
156
157 #if __MINGW_GNUC_PREREQ (3, 1)
158 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
159 #elif __MINGW_MSC_PREREQ(12, 0)
160 #define __MINGW_ATTRIB_DEPRECATED __declspec(deprecated)
161 #else
162 #define __MINGW_ATTRIB_DEPRECATED
163 #endif
164
165 #if __MINGW_GNUC_PREREQ (3, 3)
166 #define __MINGW_NOTHROW __attribute__ ((__nothrow__))
167 #elif __MINGW_MSC_PREREQ(12, 0) && defined (__cplusplus)
168 #define __MINGW_NOTHROW __declspec(nothrow)
169 #else
170 #define __MINGW_NOTHROW
171 #endif
172
173 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW. This will
174 allow GCC to optimize away some EH unwind code, at least in DW2 case. */
175
176 #ifndef __MSVCRT_VERSION__
177 /* High byte is the major version, low byte is the minor. */
178 # define __MSVCRT_VERSION__ 0x0700
179 #endif
180
181 #if defined(__GNUC__)
182 #define __mingw_va_start(v,l) __builtin_va_start(v,l)
183 #define __mingw_va_end(v) __builtin_va_end(v)
184 #define __mingw_va_arg(v,l) __builtin_va_arg(v,l)
185 #define __mingw_va_copy(d,s) __builtin_va_copy(d,s)
186 #elif defined(_MSC_VER)
187 #define __mingw_va_start(v,l) __msc_va_start(v,l)
188 #define __mingw_va_end(v) __msc_va_end(v)
189 #define __mingw_va_arg(v,l) __msc_va_arg(v,l)
190 #define __mingw_va_copy(d,s) __msc_va_copy(d,s)
191 #endif
192
193 //#ifndef WINVER
194 //#define WINVER 0x0502
195 //#endif
196
197 #ifndef _WIN32_WINNT
198 #define _WIN32_WINNT 0x502
199 #endif
200
201 #ifndef _INT128_DEFINED
202 #define _INT128_DEFINED
203 #ifdef __GNUC__
204 #define __int8 char
205 #define __int16 short
206 #define __int32 int
207 #define __int64 long long
208 #ifdef _WIN64
209
210 typedef int __int128 __attribute__ ((mode (TI)));
211
212 #endif
213
214 #define __ptr32
215 #define __ptr64
216 #define __unaligned __attribute ((packed))
217 #define __forceinline extern __inline
218 #endif
219 #endif
220
221 #ifndef _WIN32
222 #error Only Win32 target is supported!
223 #endif
224
225 #ifdef __cplusplus
226 #ifndef __nothrow
227 #define __nothrow __declspec(nothrow)
228 #endif
229 #else
230 #ifndef __nothrow
231 #define __nothrow
232 #endif
233 #endif
234
235 #undef _CRT_PACKING
236 #define _CRT_PACKING 8
237
238 #ifdef _WIN64
239 #undef USE_MINGW_SETJMP_TWO_ARGS
240 #define USE_MINGW_SETJMP_TWO_ARGS
241 #endif
242
243 #pragma pack(push,_CRT_PACKING)
244
245 #include <vadefs.h>
246
247 #ifdef __cplusplus
248 extern "C" {
249 #endif
250
251 #ifndef _CRT_STRINGIZE
252 #define __CRT_STRINGIZE(_Value) #_Value
253 #define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value)
254 #endif
255
256 #ifndef _CRT_WIDE
257 #define __CRT_WIDE(_String) L ## _String
258 #define _CRT_WIDE(_String) __CRT_WIDE(_String)
259 #endif
260 #ifndef _W64
261 #define _W64
262 #endif
263
264 #ifndef _CRTIMP_NOIA64
265 #ifdef __ia64__
266 #define _CRTIMP_NOIA64
267 #else
268 #define _CRTIMP_NOIA64 _CRTIMP
269 #endif
270 #endif
271
272 #ifndef _CRTIMP2
273 #define _CRTIMP2 _CRTIMP
274 #endif
275
276 #ifndef _CRTIMP_ALTERNATIVE
277 #define _CRTIMP_ALTERNATIVE _CRTIMP
278 #define _CRT_ALTERNATIVE_IMPORTED
279 #endif
280
281 #ifndef _MRTIMP2
282 #define _MRTIMP2 _CRTIMP
283 #endif
284
285 #ifndef _DLL
286 #define _DLL
287 #endif
288
289 #ifndef _MT
290 #define _MT
291 #endif
292
293 #ifndef _MCRTIMP
294 #define _MCRTIMP _CRTIMP
295 #endif
296
297 #ifndef _CRTIMP_PURE
298 #define _CRTIMP_PURE _CRTIMP
299 #endif
300
301 #ifndef _PGLOBAL
302 #define _PGLOBAL
303 #endif
304
305 #ifndef _AGLOBAL
306 #define _AGLOBAL
307 #endif
308
309 #define __STDC_SECURE_LIB__ 200411L
310 #define __GOT_SECURE_LIB__ __STDC_SECURE_LIB__
311 #define _SECURECRT_FILL_BUFFER_PATTERN 0xFD
312 #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated)
313
314 #ifndef _CRT_INSECURE_DEPRECATE_MEMORY
315 #define _CRT_INSECURE_DEPRECATE_MEMORY(_Replacement)
316 #endif
317 #ifndef _CRT_INSECURE_DEPRECATE_GLOBALS
318 #define _CRT_INSECURE_DEPRECATE_GLOBALS(_Replacement)
319 #endif
320 #ifndef _CRT_MANAGED_HEAP_DEPRECATE
321 #define _CRT_MANAGED_HEAP_DEPRECATE
322 #endif
323
324 #ifndef _CRT_OBSOLETE
325 #define _CRT_OBSOLETE(_NewItem)
326 #endif
327
328 #ifndef _SIZE_T_DEFINED
329 #define _SIZE_T_DEFINED
330 #undef size_t
331 #ifdef _WIN64
332 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
333 typedef unsigned int size_t __attribute__ ((mode (DI)));
334 #else
335 typedef unsigned __int64 size_t;
336 #endif
337 #else
338 typedef unsigned int size_t;
339 #endif
340 #endif
341
342 #ifndef _SSIZE_T_DEFINED
343 #define _SSIZE_T_DEFINED
344 #undef ssize_t
345 #ifdef _WIN64
346 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
347 typedef int ssize_t __attribute__ ((mode (DI)));
348 #else
349 typedef __int64 ssize_t;
350 #endif
351 #else
352 typedef int ssize_t;
353 #endif
354 #endif
355
356 #ifndef _INTPTR_T_DEFINED
357 #define _INTPTR_T_DEFINED
358 #ifndef __intptr_t_defined
359 #define __intptr_t_defined
360 #undef intptr_t
361 #ifdef _WIN64
362 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
363 typedef int intptr_t __attribute__ ((mode (DI)));
364 #else
365 typedef __int64 intptr_t;
366 #endif
367 #else
368 typedef int intptr_t;
369 #endif
370 #endif
371 #endif
372
373 #ifndef _UINTPTR_T_DEFINED
374 #define _UINTPTR_T_DEFINED
375 #ifndef __uintptr_t_defined
376 #define __uintptr_t_defined
377 #undef uintptr_t
378 #ifdef _WIN64
379 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
380 typedef unsigned int uintptr_t __attribute__ ((mode (DI)));
381 #else
382 typedef unsigned __int64 uintptr_t;
383 #endif
384 #else
385 typedef unsigned int uintptr_t;
386 #endif
387 #endif
388 #endif
389
390 #ifndef _PTRDIFF_T_DEFINED
391 #define _PTRDIFF_T_DEFINED
392 #ifndef _PTRDIFF_T_
393 #undef ptrdiff_t
394 #ifdef _WIN64
395 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
396 typedef int ptrdiff_t __attribute__ ((mode (DI)));
397 #else
398 typedef __int64 ptrdiff_t;
399 #endif
400 #else
401 typedef int ptrdiff_t;
402 #endif
403 #endif
404 #endif
405
406 #ifndef _WCHAR_T_DEFINED
407 #define _WCHAR_T_DEFINED
408 #ifndef __cplusplus
409 typedef unsigned short wchar_t;
410 #endif
411 #endif
412
413 #ifndef _WCTYPE_T_DEFINED
414 #define _WCTYPE_T_DEFINED
415 typedef unsigned short wint_t;
416 typedef unsigned short wctype_t;
417 #endif
418
419 #ifndef __GNUC_VA_LIST
420 #define __GNUC_VA_LIST
421 typedef __builtin_va_list __gnuc_va_list;
422 #endif
423
424 #ifndef _VA_LIST_DEFINED
425 #define _VA_LIST_DEFINED
426 typedef __gnuc_va_list va_list;
427 #endif
428
429 #ifdef _USE_32BIT_TIME_T
430 #ifdef _WIN64
431 #error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64
432 #undef _USE_32BIT_TIME_T
433 #endif
434 #else
435 #if _INTEGRAL_MAX_BITS < 64
436 #define _USE_32BIT_TIME_T
437 #endif
438 #endif
439
440 #ifndef _ERRCODE_DEFINED
441 #define _ERRCODE_DEFINED
442 typedef int errcode;
443 typedef int errno_t;
444 #endif
445
446 #ifndef _TIME32_T_DEFINED
447 #define _TIME32_T_DEFINED
448 typedef long __time32_t;
449 #endif
450
451 #ifndef _TIME64_T_DEFINED
452 #define _TIME64_T_DEFINED
453 //#if _INTEGRAL_MAX_BITS >= 64
454 typedef __int64 __time64_t;
455 #endif
456 //#endif
457
458 #ifndef _TIME_T_DEFINED
459 #define _TIME_T_DEFINED
460 #ifdef _USE_32BIT_TIME_T
461 typedef __time32_t time_t;
462 #else
463 typedef __time64_t time_t;
464 #endif
465 #endif
466
467 #ifndef _CONST_RETURN
468 #define _CONST_RETURN
469 #endif
470
471 #ifndef __CRT_UNALIGNED
472 #define __CRT_UNALIGNED
473 #endif
474
475 #ifndef UNALIGNED
476 #if defined(__ia64__) || defined(__x86_64)
477 //#define UNALIGNED __CRT_UNALIGNED
478 #else
479 #define UNALIGNED
480 #endif
481 #endif
482
483 #ifndef _CRT_ALIGN
484 #define _CRT_ALIGN(x) __attribute__ ((aligned(x)))
485 #endif
486
487 #ifndef _CRTNOALIAS
488 #define _CRTNOALIAS
489 #endif
490
491 #ifndef _CRTRESTRICT
492 #define _CRTRESTRICT
493 #endif
494
495 #ifndef __CRTDECL
496 #define __CRTDECL __cdecl
497 #endif
498
499 #define _ARGMAX 100
500
501 #ifndef _TRUNCATE
502 #define _TRUNCATE ((size_t)-1)
503 #endif
504 struct threadlocaleinfostruct;
505 struct threadmbcinfostruct;
506 typedef struct threadlocaleinfostruct *pthreadlocinfo;
507 typedef struct threadmbcinfostruct *pthreadmbcinfo;
508 struct __lc_time_data;
509
510 typedef struct localeinfo_struct {
511 pthreadlocinfo locinfo;
512 pthreadmbcinfo mbcinfo;
513 } _locale_tstruct,*_locale_t;
514
515 #ifndef _TAGLC_ID_DEFINED
516 #define _TAGLC_ID_DEFINED
517 typedef struct tagLC_ID {
518 unsigned short wLanguage;
519 unsigned short wCountry;
520 unsigned short wCodePage;
521 } LC_ID,*LPLC_ID;
522 #endif
523
524 #ifndef _THREADLOCALEINFO
525 #define _THREADLOCALEINFO
526 typedef struct threadlocaleinfostruct {
527 int refcount;
528 unsigned int lc_codepage;
529 unsigned int lc_collate_cp;
530 unsigned long lc_handle[6];
531 LC_ID lc_id[6];
532 struct {
533 char *locale;
534 wchar_t *wlocale;
535 int *refcount;
536 int *wrefcount;
537 } lc_category[6];
538 int lc_clike;
539 int mb_cur_max;
540 int *lconv_intl_refcount;
541 int *lconv_num_refcount;
542 int *lconv_mon_refcount;
543 struct lconv *lconv;
544 int *ctype1_refcount;
545 unsigned short *ctype1;
546 const unsigned short *pctype;
547 const unsigned char *pclmap;
548 const unsigned char *pcumap;
549 struct __lc_time_data *lc_time_curr;
550 } threadlocinfo;
551 #endif
552
553 #ifdef __cplusplus
554 }
555 #endif
556
557 #define __crt_typefix(ctype)
558
559 #ifndef _CRT_UNUSED
560 #define _CRT_UNUSED(x) (void)x
561 #endif
562
563 #pragma pack(pop)
564 #endif
565