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 #include <sdkddkver.h>
28
29 /*
30  * Mingw specific macros.
31  */
32
33 #define __MINGW_VERSION             4.0
34 #define __MINGW_MAJOR_VERSION       4
35 #define __MINGW_MINOR_VERSION       0
36 #define __MINGW_PATCHLEVEL          0
37
38 // These four macros are deprecated and will be removed in the next major
39 // version release.
40 #define __MINGW32_VERSION           3.20
41 #define __MINGW32_MAJOR_VERSION     3
42 #define __MINGW32_MINOR_VERSION     20
43 #define __MINGW32_PATCHLEVEL        0
44
45 #ifndef __GNUC__
46 #error ERROR: You must use a GNU Compiler.
47 #endif
48
49 #if (__GNUC__ < 3 || !defined(__GNUC_MINOR__) || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4 && __GNUC_PATCHLEVEL__ < 5))
50 #error ERROR: You must use a GNU Compiler version >= 3.4.5.
51 #endif
52
53 /* These are defined by the user (or the compiler)
54    to specify how identifiers are imported from a DLL.
55
56    __MINGW_IMPORT                  The attribute definition to specify imported
57                                    variables/functions.
58    _CRTIMP                         As above.  For MS compatibility.
59    __MINGW_VERSION                 Runtime version.
60    __MINGW_MAJOR_VERSION           Runtime major version.
61    __MINGW_MINOR_VERSION           Runtime minor version.
62    __MINGW_BUILD_DATE              Runtime build date.
63
64    Macros to enable MinGW features which deviate from standard MSVC
65    compatible behaviour; these may be specified directly in user code,
66    activated implicitly, (e.g. by specifying _POSIX_C_SOURCE or such),
67    or by inclusion in __MINGW_FEATURES__:
68
69    __USE_MINGW_ANSI_STDIO          Select a more ANSI C99 compatible
70                                    implementation of printf() and friends.
71
72    Other macros:
73
74    __int64                         define to be long long.  Using a typedef
75                                    doesn't work for "unsigned __int64"
76
77 /* Manifest definitions identifying the flag bits, controlling activation
78  * of MinGW features, as specified by the user in __MINGW_FEATURES__.
79  */
80 #define __MINGW_ANSI_STDIO__            0x0000000000000001ULL
81 /*
82  * The following three are not yet formally supported; they are
83  * included here, to document anticipated future usage.
84  */
85 #define __MINGW_LC_EXTENSIONS__         0x0000000000000050ULL
86 #define __MINGW_LC_MESSAGES__           0x0000000000000010ULL
87 #define __MINGW_LC_ENVVARS__            0x0000000000000040ULL
88
89 /* Try to avoid problems with outdated checks for GCC __attribute__ support.  */
90 #undef __attribute__
91
92 #ifndef __MINGW_IMPORT
93   /* Note the extern. This is needed to work around GCC's
94      limitations in handling dllimport attribute.  */
95 # define __MINGW_IMPORT  extern __attribute__ ((__dllimport__))
96 #endif
97 #ifndef _CRTIMP
98 # ifdef __USE_CRTIMP
99 #  define _CRTIMP  __attribute__ ((dllimport))
100 # else
101 #  define _CRTIMP
102 # endif
103 #endif
104
105 #ifndef __int64
106 # define __int64 long long
107 #endif
108 #ifndef __int32
109 # define __int32 long
110 #endif
111 #ifndef __int16
112 # define __int16 short
113 #endif
114 #ifndef __int8
115 # define __int8 char
116 #endif
117 #ifndef __small
118 # define __small char
119 #endif
120 #ifndef __hyper
121 # define __hyper long long
122 #endif
123
124 #define __MINGW_GNUC_PREREQ(major, minor) \
125   (__GNUC__ > (major) \
126    || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
127
128 #ifdef __cplusplus
129 # define __CRT_INLINE inline
130 #else
131 # if __GNUC_STDC_INLINE__
132 #  define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
133 # else
134 #  define __CRT_INLINE extern __inline__
135 # endif
136 #endif
137
138 #define _CRTALIAS __CRT_INLINE __attribute__ ((__always_inline__))
139
140 #ifdef __cplusplus
141 # define __UNUSED_PARAM(x)
142 #else
143 # define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
144 #endif
145
146 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
147 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
148 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
149 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
150 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
151 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
152 #define __MINGW_NOTHROW __attribute__ ((__nothrow__))
153
154
155 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW.  This will
156 allow GCC to optimize away some EH unwind code, at least in DW2 case.  */
157
158 #ifndef __MSVCRT_VERSION__
159 /*  High byte is the major version, low byte is the minor. */
160 # define __MSVCRT_VERSION__ 0x0600
161 #endif
162
163 /* Activation of MinGW specific extended features:
164  */
165 #ifndef __USE_MINGW_ANSI_STDIO
166 /*
167  * If user didn't specify it explicitly...
168  */
169 # if   defined __STRICT_ANSI__  ||  defined _ISOC99_SOURCE \
170    ||  defined _POSIX_SOURCE    ||  defined _POSIX_C_SOURCE \
171    ||  defined _XOPEN_SOURCE    ||  defined _XOPEN_SOURCE_EXTENDED \
172    ||  defined _GNU_SOURCE      ||  defined _BSD_SOURCE \
173    ||  defined _SVID_SOURCE
174    /*
175     * but where any of these source code qualifiers are specified,
176     * then assume ANSI I/O standards are preferred over Microsoft's...
177     */
178 #  define __USE_MINGW_ANSI_STDIO    1
179 # else
180    /*
181     * otherwise use whatever __MINGW_FEATURES__ specifies...
182     */
183 #  define __USE_MINGW_ANSI_STDIO    (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
184 # endif
185 #endif
186
187 struct threadlocalinfostruct;
188 struct threadmbinfostruct;
189 typedef struct threadlocalinfostruct *pthreadlocinfo;
190 typedef struct threadmbcinfostruct *pthreadmbcinfo;
191
192 typedef struct localeinfo_struct {
193   pthreadlocinfo locinfo;
194   pthreadmbcinfo mbcinfo;
195 } _locale_tstruct, *_locale_t;
196
197 /* The __AW() definition will be used for mapping UNICODE versus ASCII versions
198  * to the non represented names.  This is accomplished by macro expansion of
199  * the symbol passed and concantenating either A or W to the symbol.
200  */
201 #define __AW__(AW, AW_) AW ## AW_
202 #if ( \
203  (!defined(__TEST_SQL_NOUNICODEMAP) && defined(UNICODE)) || \
204  (!defined(__TEST_SQL_NOUNICODEMAP) && defined(_UNICODE)) || \
205  defined(FORCE_UNICODE) || \
206  (defined(__TEST_SQL_NOUNICODEMAP) && !defined(SQL_NOUNICODEMAP) && (defined(UNICODE) || defined(_UNICODE))) \
207 )
208 #define __AW(AW) __AW__(AW, W)
209 #define __STR(AW) __AW__(L, AW)
210 #else
211 #define __AW(AW) __AW__(AW, A)
212 #define __STR(AW) __AW__(, AW)
213 #endif
214
215 #endif /* __MINGW_H */