source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/_mingw.h@ 1175

Last change on this file since 1175 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 16.8 KB
Line 
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#ifndef _INC__MINGW_H
8#define _INC__MINGW_H
9
10#include "_mingw_mac.h"
11#include "_mingw_secapi.h"
12
13/* Include _cygwin.h if we're building a Cygwin application. */
14#ifdef __CYGWIN__
15#include "_cygwin.h"
16#endif
17
18/* Target specific macro replacement for type "long". In the Windows API,
19 the type long is always 32 bit, even if the target is 64 bit (LLP64).
20 On 64 bit Cygwin, the type long is 64 bit (LP64). So, to get the right
21 sized definitions and declarations, all usage of type long in the Windows
22 headers have to be replaced by the below defined macro __LONG32. */
23#ifndef __LP64__ /* 32 bit target, 64 bit Mingw target */
24#define __LONG32 long
25#else /* 64 bit Cygwin target */
26#define __LONG32 int
27#endif
28
29/* C/C++ specific language defines. */
30#ifdef _WIN64
31#ifdef __stdcall
32#undef __stdcall
33#endif
34#define __stdcall
35#endif
36
37#ifndef __GNUC__
38# ifndef __MINGW_IMPORT
39# define __MINGW_IMPORT __declspec(dllimport)
40# endif
41# ifndef _CRTIMP
42# define _CRTIMP __declspec(dllimport)
43# endif
44# define __DECLSPEC_SUPPORTED
45# define __attribute__(x) /* nothing */
46#else /* __GNUC__ */
47# ifdef __declspec
48# ifndef __MINGW_IMPORT
49/* Note the extern. This is needed to work around GCC's
50limitations in handling dllimport attribute. */
51# define __MINGW_IMPORT extern __attribute__ ((__dllimport__))
52# endif
53# ifndef _CRTIMP
54# undef __USE_CRTIMP
55# if !defined (_CRTBLD) && !defined (_SYSCRT)
56# define __USE_CRTIMP 1
57# endif
58# ifdef __USE_CRTIMP
59# define _CRTIMP __attribute__ ((__dllimport__))
60# else
61# define _CRTIMP
62# endif
63# endif
64# define __DECLSPEC_SUPPORTED
65# else /* __declspec */
66# undef __DECLSPEC_SUPPORTED
67# undef __MINGW_IMPORT
68# ifndef _CRTIMP
69# define _CRTIMP
70# endif
71# endif /* __declspec */
72#endif /* __GNUC__ */
73
74#ifdef _MSC_VER
75#define USE___UUIDOF 1
76#else
77#define USE___UUIDOF 0
78#endif
79
80#if !defined(_MSC_VER) && !defined(_inline)
81#define _inline __inline
82#endif
83
84#ifdef __cplusplus
85# define __CRT_INLINE inline
86#elif defined(_MSC_VER)
87# define __CRT_INLINE __inline
88#else
89# if ((__MINGW_GNUC_PREREQ(4, 3) || defined(__clang__)) && __STDC_VERSION__ >= 199901L)
90# define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
91# else
92# define __CRT_INLINE extern __inline__
93# endif
94#endif
95
96#if !defined(__MINGW_INTRIN_INLINE) && defined(__GNUC__)
97#define __MINGW_INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__))
98#endif
99
100#ifndef __CYGWIN__
101#ifdef __NO_INLINE__
102#undef __CRT__NO_INLINE
103#define __CRT__NO_INLINE 1
104#endif
105#endif
106
107#ifdef __cplusplus
108# define __UNUSED_PARAM(x)
109#else
110# ifdef __GNUC__
111# define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
112# else
113# define __UNUSED_PARAM(x) x
114# endif
115#endif
116
117#ifndef __GNUC__
118# ifdef _MSC_VER
119# define __restrict__ __restrict
120# else
121# define __restrict__ /* nothing */
122# endif
123#endif /* !__GNUC__ */
124
125#if __MINGW_GNUC_PREREQ (3,1) && !defined __GNUG__
126# define __restrict_arr __restrict
127#elif defined(_MSC_VER)
128# define __restrict_arr __restrict
129#else
130# ifdef __GNUC__
131# define __restrict_arr /* Not supported in old GCC. */
132# else
133# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
134# define __restrict_arr restrict
135# else
136# define __restrict_arr /* Not supported. */
137# endif
138# endif
139#endif
140
141#ifdef __GNUC__
142#define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
143#define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
144#elif __MINGW_MSC_PREREQ(12, 0)
145#define __MINGW_ATTRIB_NORETURN __declspec(noreturn)
146#define __MINGW_ATTRIB_CONST
147#else
148#define __MINGW_ATTRIB_NORETURN
149#define __MINGW_ATTRIB_CONST
150#endif
151
152#if __MINGW_GNUC_PREREQ (3, 0)
153#define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
154#define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
155#elif __MINGW_MSC_PREREQ(14, 0)
156#define __MINGW_ATTRIB_MALLOC __declspec(noalias) __declspec(restrict)
157#define __MINGW_ATTRIB_PURE
158#else
159#define __MINGW_ATTRIB_MALLOC
160#define __MINGW_ATTRIB_PURE
161#endif
162
163/* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
164 variadiac macro facility, because variadic macros cause syntax
165 errors with --traditional-cpp. */
166#if __MINGW_GNUC_PREREQ (3, 3)
167#define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
168#else
169#define __MINGW_ATTRIB_NONNULL(arg)
170#endif /* GNUC >= 3.3 */
171
172#ifdef __GNUC__
173#define __MINGW_ATTRIB_UNUSED __attribute__ ((__unused__))
174#else
175#define __MINGW_ATTRIB_UNUSED
176#endif /* ATTRIBUTE_UNUSED */
177
178#if __MINGW_GNUC_PREREQ (3, 1)
179#define __MINGW_ATTRIB_USED __attribute__ ((__used__))
180#define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
181#if __MINGW_GNUC_PREREQ (4, 5) || defined (__clang__)
182#define __MINGW_ATTRIB_DEPRECATED_MSG(x) __attribute__ ((__deprecated__(x)))
183#endif
184#elif __MINGW_MSC_PREREQ(12, 0)
185#define __MINGW_ATTRIB_USED
186#define __MINGW_ATTRIB_DEPRECATED __declspec(deprecated)
187#else
188#define __MINGW_ATTRIB_USED __MINGW_ATTRIB_UNUSED
189#define __MINGW_ATTRIB_DEPRECATED
190#endif /* GNUC >= 3.1 */
191
192#ifndef __MINGW_ATTRIB_DEPRECATED_MSG
193#define __MINGW_ATTRIB_DEPRECATED_MSG(x) __MINGW_ATTRIB_DEPRECATED
194#endif
195
196#if __MINGW_GNUC_PREREQ (3, 3)
197#define __MINGW_NOTHROW __attribute__ ((__nothrow__))
198#elif __MINGW_MSC_PREREQ(12, 0) && defined (__cplusplus)
199#define __MINGW_NOTHROW __declspec(nothrow)
200#else
201#define __MINGW_NOTHROW
202#endif
203
204#if __MINGW_GNUC_PREREQ (4, 4)
205#define __MINGW_ATTRIB_NO_OPTIMIZE __attribute__((__optimize__ ("0")))
206#else
207#define __MINGW_ATTRIB_NO_OPTIMIZE
208#endif
209
210#if __MINGW_GNUC_PREREQ (4, 4)
211#define __MINGW_PRAGMA_PARAM(x) _Pragma (#x)
212#elif __MINGW_MSC_PREREQ (13, 1)
213#define __MINGW_PRAGMA_PARAM(x) __pragma (x)
214#else
215#define __MINGW_PRAGMA_PARAM(x)
216#endif
217
218#define __MINGW_BROKEN_INTERFACE(x) \
219 __MINGW_PRAGMA_PARAM(message ("Interface " _CRT_STRINGIZE(x) \
220 " has unverified layout."))
221
222#ifndef __MSVCRT_VERSION__
223/* High byte is the major version, low byte is the minor. */
224# ifndef _UCRT
225# define __MSVCRT_VERSION__ 0x700
226# else
227# define __MSVCRT_VERSION__ 0xE00
228# endif
229#endif
230
231#if !defined(_UCRT) && ((__MSVCRT_VERSION__ >= 0x1400) || (__MSVCRT_VERSION__ >= 0xE00 && __MSVCRT_VERSION__ < 0x1000))
232/* Allow both 0x1400 and 0xE00 to identify UCRT */
233#define _UCRT
234#endif
235
236#ifndef _WIN32_WINNT
237#define _WIN32_WINNT 0x601
238#endif
239
240#ifndef _INT128_DEFINED
241#define _INT128_DEFINED
242#ifdef __GNUC__
243#define __int8 char
244#define __int16 short
245#define __int32 int
246#define __int64 long long
247#ifdef _WIN64
248#if (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1)) && \
249 !defined(__SIZEOF_INT128__) /* clang >= 3.1 has __int128 but no size macro */
250#define __SIZEOF_INT128__ 16
251#endif
252#ifndef __SIZEOF_INT128__
253typedef int __int128 __attribute__ ((__mode__ (TI)));
254#endif
255#endif
256#endif /* __GNUC__ */
257#endif /* _INT128_DEFINED */
258
259#ifdef __GNUC__
260#define __ptr32
261#define __ptr64
262#ifndef __unaligned
263#define __unaligned
264#endif
265#ifndef __w64
266#define __w64
267#endif
268#ifdef __cplusplus
269#define __forceinline inline __attribute__((__always_inline__))
270#else
271#define __forceinline extern __inline__ __attribute__((__always_inline__,__gnu_inline__))
272#endif /* __cplusplus */
273#endif /* __GNUC__ */
274
275#if !defined(_WIN32) && !defined(__CYGWIN__)
276#error Only Win32 target is supported!
277#endif
278
279#ifndef __nothrow
280#ifdef __cplusplus
281#define __nothrow __MINGW_NOTHROW
282#else
283#define __nothrow
284#endif
285#endif /* __nothrow */
286
287#include <vadefs.h> /* other headers depend on this include */
288
289#ifndef _CRT_STRINGIZE
290#define __CRT_STRINGIZE(_Value) #_Value
291#define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value)
292#endif /* _CRT_STRINGIZE */
293
294#ifndef _CRT_WIDE
295#define __CRT_WIDE(_String) L ## _String
296#define _CRT_WIDE(_String) __CRT_WIDE(_String)
297#endif /* _CRT_WIDE */
298
299#ifndef _W64
300#define _W64
301#endif
302
303#ifndef _CRTIMP_NOIA64
304#ifdef __ia64__
305#define _CRTIMP_NOIA64
306#else
307#define _CRTIMP_NOIA64 _CRTIMP
308#endif
309#endif /* _CRTIMP_NOIA64 */
310
311#ifndef _CRTIMP2
312#define _CRTIMP2 _CRTIMP
313#endif
314
315#ifndef _CRTIMP_ALTERNATIVE
316#define _CRTIMP_ALTERNATIVE _CRTIMP
317#define _CRT_ALTERNATIVE_IMPORTED
318#endif /* _CRTIMP_ALTERNATIVE */
319
320#ifndef _MRTIMP2
321#define _MRTIMP2 _CRTIMP
322#endif
323
324/* We have to define _DLL for gcc based mingw version. This define is set
325 by VC, when DLL-based runtime is used. So, gcc based runtime just have
326 DLL-base runtime, therefore this define has to be set.
327 As our headers are possibly used by windows compiler having a static
328 C-runtime, we make this definition gnu compiler specific here. */
329#if !defined (_DLL) && defined (__GNUC__)
330#define _DLL
331#endif
332
333#ifndef _MT
334#define _MT
335#endif
336
337#ifndef _MCRTIMP
338#define _MCRTIMP _CRTIMP
339#endif
340
341#ifndef _CRTIMP_PURE
342#define _CRTIMP_PURE _CRTIMP
343#endif
344
345#ifndef _PGLOBAL
346#define _PGLOBAL
347#endif
348
349#ifndef _AGLOBAL
350#define _AGLOBAL
351#endif
352
353#define _SECURECRT_FILL_BUFFER_PATTERN 0xFD
354#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated)
355
356#ifndef _CRT_INSECURE_DEPRECATE_MEMORY
357#define _CRT_INSECURE_DEPRECATE_MEMORY(_Replacement)
358#endif
359
360#ifndef _CRT_INSECURE_DEPRECATE_GLOBALS
361#define _CRT_INSECURE_DEPRECATE_GLOBALS(_Replacement)
362#endif
363
364#ifndef _CRT_MANAGED_HEAP_DEPRECATE
365#define _CRT_MANAGED_HEAP_DEPRECATE
366#endif
367
368#ifndef _CRT_OBSOLETE
369#define _CRT_OBSOLETE(_NewItem)
370#endif
371
372#ifndef __WIDL__
373
374#if defined (_WIN32) && !defined (_WIN64) && !defined (__MINGW_USE_VC2005_COMPAT) && !defined (_UCRT)
375#ifndef _USE_32BIT_TIME_T
376#define _USE_32BIT_TIME_T
377#endif
378#endif
379
380#ifndef _CONST_RETURN
381#define _CONST_RETURN
382#endif
383
384#ifndef UNALIGNED
385#if defined(__ia64__) || defined(__x86_64__)
386#define UNALIGNED __unaligned
387#else
388#define UNALIGNED
389#endif
390#endif /* UNALIGNED */
391
392#ifndef _CRT_ALIGN
393#ifdef _MSC_VER
394#define _CRT_ALIGN(x) __declspec(align(x))
395#else /* __GNUC__ */
396#define _CRT_ALIGN(x) __attribute__ ((__aligned__ (x)))
397#endif
398#endif /* _CRT_ALIGN */
399
400#endif /* __WIDL__ */
401
402#ifndef __CRTDECL
403#define __CRTDECL __cdecl
404#endif
405
406#define _ARGMAX 100
407
408#ifndef _TRUNCATE
409#define _TRUNCATE ((size_t)-1)
410#endif
411
412#ifndef _CRT_UNUSED
413#define _CRT_UNUSED(x) (void)x
414#endif
415
416/* MSVC defines _NATIVE_NULLPTR_SUPPORTED when nullptr is supported. We emulate it here for GCC. */
417#if __MINGW_GNUC_PREREQ(4, 6)
418#if defined(__GNUC__) && (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
419#define _NATIVE_NULLPTR_SUPPORTED
420#endif
421#endif
422
423/* We are activating __USE_MINGW_ANSI_STDIO for various define indicators.
424 * printf ll modifier (unsupported by msvcrt.dll) is required by C99 and C++11 standards. */
425#if (defined (_POSIX) || defined (_POSIX_SOURCE) || defined (_POSIX_C_SOURCE) \
426 || defined (_ISOC99_SOURCE) \
427 || (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && __MSVCRT_VERSION__ < 0xE00) \
428 || (defined (__cplusplus) && __cplusplus >= 201103L && __MSVCRT_VERSION__ < 0xE00) \
429 || defined (_XOPEN_SOURCE) || defined (_XOPEN_SOURCE_EXTENDED) \
430 || defined (_GNU_SOURCE) \
431 || defined (_SVID_SOURCE)) \
432 && !defined(__USE_MINGW_ANSI_STDIO)
433/* Enable __USE_MINGW_ANSI_STDIO if user did _not_ specify it explicitly... */
434# define __USE_MINGW_ANSI_STDIO 1
435#endif
436
437/* We are defining __USE_MINGW_ANSI_STDIO as 0 or 1 */
438#if !defined(__USE_MINGW_ANSI_STDIO)
439#define __USE_MINGW_ANSI_STDIO 0 /* was not defined so it should be 0 */
440#elif (__USE_MINGW_ANSI_STDIO + 0) != 0 || (1 - __USE_MINGW_ANSI_STDIO - 1) == 2
441#define __USE_MINGW_ANSI_STDIO 1 /* was defined as nonzero or empty so it should be 1 */
442#else
443#define __USE_MINGW_ANSI_STDIO 0 /* was defined as (int)zero and non-empty so it should be 0 */
444#endif
445
446/* _dowildcard is an int that controls the globbing of the command line.
447 * The MinGW32 (mingw.org) runtime calls it _CRT_glob, so we are adding
448 * a compatibility definition here: you can use either of _CRT_glob or
449 * _dowildcard .
450 * If _dowildcard is non-zero, the command line will be globbed: *.*
451 * will be expanded to be all files in the startup directory.
452 * In the mingw-w64 library a _dowildcard variable is defined as being
453 * 0, therefore command line globbing is DISABLED by default. To turn it
454 * on and to leave wildcard command line processing MS's globbing code,
455 * include a line in one of your source modules defining _dowildcard and
456 * setting it to -1, like so:
457 * int _dowildcard = -1;
458 */
459#undef _CRT_glob
460#define _CRT_glob _dowildcard
461
462
463#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
464#define NONAMELESSUNION 1
465#endif
466#if defined(NONAMELESSSTRUCT) && \
467 !defined(NONAMELESSUNION)
468#define NONAMELESSUNION 1
469#endif
470#if defined(NONAMELESSUNION) && \
471 !defined(NONAMELESSSTRUCT)
472#define NONAMELESSSTRUCT 1
473#endif
474
475#ifndef __ANONYMOUS_DEFINED
476#define __ANONYMOUS_DEFINED
477#define _ANONYMOUS_UNION __MINGW_EXTENSION
478#define _ANONYMOUS_STRUCT __MINGW_EXTENSION
479#ifndef NONAMELESSUNION
480#define _UNION_NAME(x)
481#define _STRUCT_NAME(x)
482#else /* NONAMELESSUNION */
483#define _UNION_NAME(x) x
484#define _STRUCT_NAME(x) x
485#endif
486#endif /* __ANONYMOUS_DEFINED */
487
488#ifndef DUMMYUNIONNAME
489# ifdef NONAMELESSUNION
490# define DUMMYUNIONNAME u
491# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
492# define DUMMYUNIONNAME2 u2
493# define DUMMYUNIONNAME3 u3
494# define DUMMYUNIONNAME4 u4
495# define DUMMYUNIONNAME5 u5
496# define DUMMYUNIONNAME6 u6
497# define DUMMYUNIONNAME7 u7
498# define DUMMYUNIONNAME8 u8
499# define DUMMYUNIONNAME9 u9
500# else /* NONAMELESSUNION */
501# define DUMMYUNIONNAME
502# define DUMMYUNIONNAME1 /* Wine uses this variant */
503# define DUMMYUNIONNAME2
504# define DUMMYUNIONNAME3
505# define DUMMYUNIONNAME4
506# define DUMMYUNIONNAME5
507# define DUMMYUNIONNAME6
508# define DUMMYUNIONNAME7
509# define DUMMYUNIONNAME8
510# define DUMMYUNIONNAME9
511# endif
512#endif /* DUMMYUNIONNAME */
513
514#ifndef DUMMYSTRUCTNAME
515# ifdef NONAMELESSUNION
516# define DUMMYSTRUCTNAME s
517# define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */
518# define DUMMYSTRUCTNAME2 s2
519# define DUMMYSTRUCTNAME3 s3
520# define DUMMYSTRUCTNAME4 s4
521# define DUMMYSTRUCTNAME5 s5
522# else
523# define DUMMYSTRUCTNAME
524# define DUMMYSTRUCTNAME1 /* Wine uses this variant */
525# define DUMMYSTRUCTNAME2
526# define DUMMYSTRUCTNAME3
527# define DUMMYSTRUCTNAME4
528# define DUMMYSTRUCTNAME5
529# endif
530#endif /* DUMMYSTRUCTNAME */
531
532
533/* Macros for __uuidof template-based emulation */
534#if defined(__cplusplus) && (USE___UUIDOF == 0)
535
536#if __cpp_constexpr >= 200704l && __cpp_inline_variables >= 201606L
537#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
538 extern "C++" { \
539 template<> struct __mingw_uuidof_s<type> { \
540 static constexpr IID __uuid_inst = { \
541 l,w1,w2, {b1,b2,b3,b4,b5,b6,b7,b8} \
542 }; \
543 }; \
544 template<> constexpr const GUID &__mingw_uuidof<type>() { \
545 return __mingw_uuidof_s<type>::__uuid_inst; \
546 } \
547 template<> constexpr const GUID &__mingw_uuidof<type*>() { \
548 return __mingw_uuidof_s<type>::__uuid_inst; \
549 } \
550 }
551#else
552#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
553 extern "C++" { \
554 template<> inline const GUID &__mingw_uuidof<type>() { \
555 static const IID __uuid_inst = {l,w1,w2, {b1,b2,b3,b4,b5,b6,b7,b8}}; \
556 return __uuid_inst; \
557 } \
558 template<> inline const GUID &__mingw_uuidof<type*>() { \
559 return __mingw_uuidof<type>(); \
560 } \
561 }
562#endif
563
564#define __uuidof(type) __mingw_uuidof<__typeof(type)>()
565
566#else
567
568#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
569
570#endif
571
572#ifdef __cplusplus
573extern "C" {
574#endif
575
576
577#ifdef __MINGW_INTRIN_INLINE
578#ifdef __has_builtin
579#define __MINGW_DEBUGBREAK_IMPL !__has_builtin(__debugbreak)
580#else
581#define __MINGW_DEBUGBREAK_IMPL 1
582#endif
583#if __MINGW_DEBUGBREAK_IMPL == 1
584void __cdecl __debugbreak(void);
585__MINGW_INTRIN_INLINE void __cdecl __debugbreak(void)
586{
587#if defined(__i386__) || defined(__x86_64__)
588 __asm__ __volatile__("int {$}3":);
589#elif defined(__arm__)
590 __asm__ __volatile__("udf #0xfe");
591#elif defined(__aarch64__)
592 __asm__ __volatile__("brk #0xf000");
593#else
594 __asm__ __volatile__("unimplemented");
595#endif
596}
597#endif
598#endif
599
600/* mingw-w64 specific functions: */
601const char *__mingw_get_crt_info (void);
602
603#ifdef __cplusplus
604}
605#endif
606
607#endif /* _INC__MINGW_H */
608
609#ifndef MINGW_SDK_INIT
610#define MINGW_SDK_INIT
611
612/* for backward compatibility */
613#ifndef MINGW_HAS_SECURE_API
614#define MINGW_HAS_SECURE_API 1
615#endif
616
617#define __STDC_SECURE_LIB__ 200411L
618#define __GOT_SECURE_LIB__ __STDC_SECURE_LIB__
619
620#ifndef __WIDL__
621#include "sdks/_mingw_ddk.h"
622#endif
623
624#endif /* MINGW_SDK_INIT */
Note: See TracBrowser for help on using the repository browser.