OSDN Git Service

Make dirent implementation namespace and time_t clean.
[mingw/mingw-org-wsl.git] / mingwrt / include / _mingw.h
1 #ifndef __MINGW_H
2 /*
3  * _mingw.h
4  *
5  * Mingw specific macros included by ALL include files.
6  *
7  * This file is part of the Mingw32 package.
8  *
9  * Contributors:
10  *  Created by Mumit Khan  <khan@xraylith.wisc.edu>
11  *
12  *  THIS SOFTWARE IS NOT COPYRIGHTED
13  *
14  *  This source code is offered for use in the public domain. You may
15  *  use, modify or distribute it freely.
16  *
17  *  This code is distributed in the hope that it will be useful but
18  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
19  *  DISCLAIMED. This includes but is not limited to warranties of
20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21  *
22  */
23 #define __MINGW_H
24
25 #define __MINGW32_VERSION           3.20
26 #define __MINGW32_MAJOR_VERSION     3
27 #define __MINGW32_MINOR_VERSION     20
28 #define __MINGW32_PATCHLEVEL        0
29
30 #if __GNUC__ >= 3
31 #ifndef __PCC__
32 #pragma GCC system_header
33 #endif
34 #endif
35
36 /* These are defined by the user (or the compiler)
37    to specify how identifiers are imported from a DLL.
38
39    __DECLSPEC_SUPPORTED            Defined if dllimport attribute is supported.
40    __MINGW_IMPORT                  The attribute definition to specify imported
41                                    variables/functions.
42    _CRTIMP                         As above.  For MS compatibility.
43    __MINGW32_VERSION               Runtime version.
44    __MINGW32_MAJOR_VERSION         Runtime major version.
45    __MINGW32_MINOR_VERSION         Runtime minor version.
46    __MINGW32_BUILD_DATE            Runtime build date.
47
48    Macros to enable MinGW features which deviate from standard MSVC
49    compatible behaviour; these may be specified directly in user code,
50    activated implicitly, (e.g. by specifying _POSIX_C_SOURCE or such),
51    or by inclusion in __MINGW_FEATURES__:
52
53    __USE_MINGW_ANSI_STDIO          Select a more ANSI C99 compatible
54                                    implementation of printf() and friends.
55
56    Other macros:
57
58    __int64                         define to be long long.  Using a typedef
59                                    doesn't work for "unsigned __int64"
60
61    All headers should include this first, and then use __DECLSPEC_SUPPORTED
62    to choose between the old ``__imp__name'' style or __MINGW_IMPORT
63    style declarations.  */
64
65
66 /* Manifest definitions identifying the flag bits, controlling activation
67  * of MinGW features, as specified by the user in __MINGW_FEATURES__.
68  */
69 #define __MINGW_ANSI_STDIO__            0x0000000000000001ULL
70 /*
71  * The following three are not yet formally supported; they are
72  * included here, to document anticipated future usage.
73  */
74 #define __MINGW_LC_EXTENSIONS__         0x0000000000000050ULL
75 #define __MINGW_LC_MESSAGES__           0x0000000000000010ULL
76 #define __MINGW_LC_ENVVARS__            0x0000000000000040ULL
77
78 /* Try to avoid problems with outdated checks for GCC __attribute__ support.  */
79 #undef __attribute__
80
81 #if defined (__PCC__)
82 #  undef __DECLSPEC_SUPPORTED
83 # ifndef __MINGW_IMPORT
84 #  define __MINGW_IMPORT extern
85 # endif
86 # ifndef _CRTIMP
87 #  define _CRTIMP
88 # endif
89 # ifndef __cdecl
90 #  define __cdecl  _Pragma("cdecl")
91 # endif
92 # ifndef __stdcall
93 #  define __stdcall _Pragma("stdcall")
94 # endif
95 # ifndef __int64
96 #  define __int64 long long
97 # endif
98 # ifndef __int32
99 #  define __int32 long
100 # endif
101 # ifndef __int16
102 #  define __int16 short
103 # endif
104 # ifndef __int8
105 #  define __int8 char
106 # endif
107 # ifndef __small
108 #  define __small char
109 # endif
110 # ifndef __hyper
111 #  define __hyper long long
112 # endif
113 # ifndef __volatile__
114 #  define __volatile__ volatile
115 # endif
116 # ifndef __restrict__
117 #  define __restrict__ restrict
118 # endif
119 # define NONAMELESSUNION
120 #elif defined(__GNUC__)
121 # ifdef __declspec
122 #  ifndef __MINGW_IMPORT
123    /* Note the extern. This is needed to work around GCC's
124       limitations in handling dllimport attribute.  */
125 #   define __MINGW_IMPORT  extern __attribute__ ((__dllimport__))
126 #  endif
127 #  ifndef _CRTIMP
128 #   ifdef __USE_CRTIMP
129 #    define _CRTIMP  __attribute__ ((dllimport))
130 #   else
131 #    define _CRTIMP
132 #   endif
133 #  endif
134 #  define __DECLSPEC_SUPPORTED
135 # else /* __declspec */
136 #  undef __DECLSPEC_SUPPORTED
137 #  undef __MINGW_IMPORT
138 #  ifndef _CRTIMP
139 #   define _CRTIMP
140 #  endif
141 # endif /* __declspec */
142 /*
143  * The next two defines can cause problems if user code adds the
144  * __cdecl attribute like so:
145  * void __attribute__ ((__cdecl)) foo(void);
146  */
147 # ifndef __cdecl
148 #  define __cdecl  __attribute__ ((__cdecl__))
149 # endif
150 # ifndef __stdcall
151 #  define __stdcall __attribute__ ((__stdcall__))
152 # endif
153 # ifndef __int64
154 #  define __int64 long long
155 # endif
156 # ifndef __int32
157 #  define __int32 long
158 # endif
159 # ifndef __int16
160 #  define __int16 short
161 # endif
162 # ifndef __int8
163 #  define __int8 char
164 # endif
165 # ifndef __small
166 #  define __small char
167 # endif
168 # ifndef __hyper
169 #  define __hyper long long
170 # endif
171 #else /* ! __GNUC__ && ! __PCC__ */
172 # ifndef __MINGW_IMPORT
173 #  define __MINGW_IMPORT  __declspec(dllimport)
174 # endif
175 # ifndef _CRTIMP
176 #  define _CRTIMP  __declspec(dllimport)
177 # endif
178 # define __DECLSPEC_SUPPORTED
179 # define __attribute__(x) /* nothing */
180 #endif
181
182 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
183 #define __MINGW_GNUC_PREREQ(major, minor) \
184   (__GNUC__ > (major) \
185    || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
186 #else
187 #define __MINGW_GNUC_PREREQ(major, minor)  0
188 #endif
189
190 #ifdef __cplusplus
191 # define _EXTERN_C       extern "C"
192 # define _BEGIN_C_DECLS  extern "C" {
193 # define _END_C_DECLS    }
194
195 # define __CRT_INLINE    inline
196
197 #else
198 # define _EXTERN_C       extern
199 # define _BEGIN_C_DECLS
200 # define _END_C_DECLS
201
202 # if __GNUC_STDC_INLINE__
203 #  define __CRT_INLINE   extern inline __attribute__((__gnu_inline__))
204 # else
205 #  define __CRT_INLINE   extern __inline__
206 # endif
207 #endif
208
209 # ifdef __GNUC__
210   /* A special form of __CRT_INLINE, to ALWAYS request inlining when
211    * possible is provided; originally specified as _CRTALIAS, this is
212    * now deprecated in favour of __CRT_ALIAS, for syntactic consistency
213    * with __CRT_INLINE itself.
214    */
215 #  define  _CRTALIAS   __CRT_INLINE __attribute__((__always_inline__))
216 #  define __CRT_ALIAS  __CRT_INLINE __attribute__((__always_inline__))
217 # else
218 #  define  _CRTALIAS   __CRT_INLINE     /* deprecated form */
219 #  define __CRT_ALIAS  __CRT_INLINE     /* preferred form */
220 # endif
221 /*
222  * Each function which is implemented as a __CRT_ALIAS should also be
223  * accompanied by an externally visible interface.  The following pair
224  * of macros provide a mechanism for implementing this, either as a stub
225  * redirecting to an alternative external function, or by compilation of
226  * the normally inlined code into free standing object code; each macro
227  * provides a way for us to offer arbitrary hints for use by the build
228  * system, while remaining transparent to the compiler.
229  */
230 #define __JMPSTUB__(__BUILD_HINT__)
231 #define __LIBIMPL__(__BUILD_HINT__)
232
233 #ifdef __cplusplus
234 # define __UNUSED_PARAM(x)
235 #else
236 # ifdef __GNUC__
237 #  define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
238 # else
239 #  define __UNUSED_PARAM(x) x
240 # endif
241 #endif
242
243 #ifdef __GNUC__
244 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
245 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
246 #else
247 #define __MINGW_ATTRIB_NORETURN
248 #define __MINGW_ATTRIB_CONST
249 #endif
250
251 #if __MINGW_GNUC_PREREQ (3, 0)
252 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
253 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
254 #else
255 #define __MINGW_ATTRIB_MALLOC
256 #define __MINGW_ATTRIB_PURE
257 #endif
258
259 /* Attribute `nonnull' was valid as of gcc 3.3.  We don't use GCC's
260    variadiac macro facility, because variadic macros cause syntax
261    errors with  --traditional-cpp.  */
262 #if  __MINGW_GNUC_PREREQ (3, 3)
263 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
264 #else
265 #define __MINGW_ATTRIB_NONNULL(arg)
266 #endif /* GNUC >= 3.3 */
267
268 #if  __MINGW_GNUC_PREREQ (3, 1)
269 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
270 #else
271 #define __MINGW_ATTRIB_DEPRECATED
272 #endif /* GNUC >= 3.1 */
273
274 #if  __MINGW_GNUC_PREREQ (3, 3)
275 #define __MINGW_NOTHROW __attribute__ ((__nothrow__))
276 #else
277 #define __MINGW_NOTHROW
278 #endif /* GNUC >= 3.3 */
279
280
281 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW.  This will
282 allow GCC to optimize away some EH unwind code, at least in DW2 case.  */
283
284 #ifndef __MSVCRT_VERSION__
285 /*  High byte is the major version, low byte is the minor. */
286 # define __MSVCRT_VERSION__ 0x0600
287 #endif
288
289 /* Activation of MinGW specific extended features:
290  */
291 #ifndef __USE_MINGW_ANSI_STDIO
292 /*
293  * If user didn't specify it explicitly...
294  */
295 # if   defined __STRICT_ANSI__  ||  defined _ISOC99_SOURCE \
296    ||  defined _POSIX_SOURCE    ||  defined _POSIX_C_SOURCE \
297    ||  defined _XOPEN_SOURCE    ||  defined _XOPEN_SOURCE_EXTENDED \
298    ||  defined _GNU_SOURCE      ||  defined _BSD_SOURCE \
299    ||  defined _SVID_SOURCE
300    /*
301     * but where any of these source code qualifiers are specified,
302     * then assume ANSI I/O standards are preferred over Microsoft's...
303     */
304 #  define __USE_MINGW_ANSI_STDIO    1
305 # else
306    /*
307     * otherwise use whatever __MINGW_FEATURES__ specifies...
308     */
309 #  define __USE_MINGW_ANSI_STDIO    (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
310 # endif
311 #endif
312
313 /* Only Microsoft could attempt to justify this insanity: when building
314  * a UTF-16LE application -- apparently their understanding of Unicode is
315  * limited to this -- the C/C++ runtime requires that the user must define
316  * the _UNICODE macro, while to use the Windows API's UTF-16LE capabilities,
317  * it is the UNICODE macro, (without the leading underscore), which must be
318  * defined.  The (bogus) explanation appears to be that it is the C standard
319  * which dictates the requirement for the leading underscore, to avoid any
320  * possible conflict with a user defined symbol; (bogus because the macro
321  * must be user defined anyway -- it is not a private symbol -- and in
322  * any case, the Windows API already reserves the UNICODE symbol as
323  * a user defined macro, with equivalent intent.
324  *
325  * The real explanation, of course, is that this is just another example
326  * of Microsoft irrationality; in any event, there seems to be no sane
327  * scenario in which defining one without the other would be required,
328  * or indeed would not raise potential for internal inconsistency, so we
329  * ensure that either both are, or neither is defined.
330  */
331 #if defined UNICODE && ! defined _UNICODE
332 # define _UNICODE  UNICODE
333 #endif
334 #if defined _UNICODE && ! defined UNICODE
335 # define UNICODE  _UNICODE
336 #endif
337
338 #endif /* __MINGW_H */