OSDN Git Service

Redo the filters based on assumptions discussed in mingw-dvlpr list.
[mingw/mingw-org-wsl.git] / include / _mingw.h
1 /**
2  * @file _mingw.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _MINGW_H
25 #define _MINGW_H
26 #pragma GCC system_header
27
28 /*
29  * Mingw specific macros.
30  */
31
32 #define __MINGW_VERSION             4.0
33 #define __MINGW_MAJOR_VERSION       4
34 #define __MINGW_MINOR_VERSION       0
35 #define __MINGW_PATCHLEVEL          0
36
37 // These four macros are deprecated and will be removed in the next major
38 // version release.
39 #define __MINGW32_VERSION           3.20
40 #define __MINGW32_MAJOR_VERSION     3
41 #define __MINGW32_MINOR_VERSION     20
42 #define __MINGW32_PATCHLEVEL        0
43
44 #ifndef __GNUC__
45 #error ERROR: You must use a GNU Compiler.
46 #endif
47
48 #if (__GNUC__ < 3 || !defined(__GNUC_MINOR__) || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4 && __GNUC_PATCHLEVEL__ < 5))
49 #error ERROR: You must use a GNU Compiler version >= 3.4.5.
50 #endif
51
52 /* These are defined by the user (or the compiler)
53    to specify how identifiers are imported from a DLL.
54
55    __MINGW_IMPORT                  The attribute definition to specify imported
56                                    variables/functions.
57    _CRTIMP                         As above.  For MS compatibility.
58    __MINGW_VERSION                 Runtime version.
59    __MINGW_MAJOR_VERSION           Runtime major version.
60    __MINGW_MINOR_VERSION           Runtime minor version.
61    __MINGW_BUILD_DATE              Runtime build date.
62
63    Macros to enable MinGW features which deviate from standard MSVC
64    compatible behaviour; these may be specified directly in user code,
65    activated implicitly, (e.g. by specifying _POSIX_C_SOURCE or such),
66    or by inclusion in __MINGW_FEATURES__:
67
68    __USE_MINGW_ANSI_STDIO          Select a more ANSI C99 compatible
69                                    implementation of printf() and friends.
70
71    Other macros:
72
73    __int64                         define to be long long.  Using a typedef
74                                    doesn't work for "unsigned __int64"
75
76 /* Manifest definitions identifying the flag bits, controlling activation
77  * of MinGW features, as specified by the user in __MINGW_FEATURES__.
78  */
79 #define __MINGW_ANSI_STDIO__            0x0000000000000001ULL
80 /*
81  * The following three are not yet formally supported; they are
82  * included here, to document anticipated future usage.
83  */
84 #define __MINGW_LC_EXTENSIONS__         0x0000000000000050ULL
85 #define __MINGW_LC_MESSAGES__           0x0000000000000010ULL
86 #define __MINGW_LC_ENVVARS__            0x0000000000000040ULL
87
88 /* Try to avoid problems with outdated checks for GCC __attribute__ support.  */
89 #undef __attribute__
90
91 #ifndef __MINGW_IMPORT
92   /* Note the extern. This is needed to work around GCC's
93      limitations in handling dllimport attribute.  */
94 # define __MINGW_IMPORT  extern __attribute__ ((__dllimport__))
95 #endif
96 #ifndef _CRTIMP
97 # ifdef __USE_CRTIMP
98 #  define _CRTIMP  __attribute__ ((dllimport))
99 # else
100 #  define _CRTIMP
101 # endif
102 #endif
103
104 #ifndef __int64
105 # define __int64 long long
106 #endif
107 #ifndef __int32
108 # define __int32 long
109 #endif
110 #ifndef __int16
111 # define __int16 short
112 #endif
113 #ifndef __int8
114 # define __int8 char
115 #endif
116 #ifndef __small
117 # define __small char
118 #endif
119 #ifndef __hyper
120 # define __hyper long long
121 #endif
122
123 #define __MINGW_GNUC_PREREQ(major, minor) \
124   (__GNUC__ > (major) \
125    || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
126
127 #ifdef __cplusplus
128 # define __CRT_INLINE inline
129 #else
130 # if __GNUC_STDC_INLINE__
131 #  define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
132 # else
133 #  define __CRT_INLINE extern __inline__
134 # endif
135 #endif
136
137 #define _CRTALIAS __CRT_INLINE __attribute__ ((__always_inline__))
138
139 #ifdef __cplusplus
140 # define __UNUSED_PARAM(x)
141 #else
142 # define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
143 #endif
144
145 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
146 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
147 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
148 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
149 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
150 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
151 #define __MINGW_NOTHROW __attribute__ ((__nothrow__))
152
153
154 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW.  This will
155 allow GCC to optimize away some EH unwind code, at least in DW2 case.  */
156
157 #ifndef __MSVCRT_VERSION__
158 /*  High byte is the major version, low byte is the minor. */
159 # define __MSVCRT_VERSION__ 0x0600
160 #endif
161
162 /* Activation of MinGW specific extended features:
163  */
164 #ifndef __USE_MINGW_ANSI_STDIO
165 /*
166  * If user didn't specify it explicitly...
167  */
168 # if   defined __STRICT_ANSI__  ||  defined _ISOC99_SOURCE \
169    ||  defined _POSIX_SOURCE    ||  defined _POSIX_C_SOURCE \
170    ||  defined _XOPEN_SOURCE    ||  defined _XOPEN_SOURCE_EXTENDED \
171    ||  defined _GNU_SOURCE      ||  defined _BSD_SOURCE \
172    ||  defined _SVID_SOURCE
173    /*
174     * but where any of these source code qualifiers are specified,
175     * then assume ANSI I/O standards are preferred over Microsoft's...
176     */
177 #  define __USE_MINGW_ANSI_STDIO    1
178 # else
179    /*
180     * otherwise use whatever __MINGW_FEATURES__ specifies...
181     */
182 #  define __USE_MINGW_ANSI_STDIO    (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
183 # endif
184 #endif
185
186 struct threadlocalinfostruct;
187 struct threadmbinfostruct;
188 typedef struct threadlocalinfostruct *pthreadlocinfo;
189 typedef struct threadmbcinfostruct *pthreadmbcinfo;
190
191 typedef struct localeinfo_struct {
192   pthreadlocinfo locinfo;
193   pthreadmbcinfo mbcinfo;
194 } _locale_tstruct, *_locale_t;
195
196 /* The __AW() definition will be used for mapping UNICODE versus ASCII versions
197  * to the non represented names.  This is accomplished by macro expansion of
198  * the symbol passed and concantenating either A or W to the symbol.
199  */
200 #define __AW__(AW, AW_) AW ## AW_
201 #if (defined(UNICODE) || defined(_UNICODE))
202 #define __AW(AW) __AW__(AW, W)
203 #else
204 #define __AW(AW) __AW__(AW, A)
205 #endif
206
207 #endif /* __MINGW_H */