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