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