[MINGW32] Add some definitions to fix building with GLIBCXX
[reactos.git] / sdk / 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_MINGW
8 #define _INC_MINGW
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 #ifdef __GNUC__
28 /* These compilers do support __declspec */
29 # if !defined(__MINGW32__) && !defined(__MINGW64__) && !defined(__CYGWIN32__)
30 # define __declspec(x) __attribute__((x))
31 # endif
32 #endif
33
34 #ifdef _MSC_VER
35 #define __restrict__ /* nothing */
36 #endif
37
38 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
39 #define __MINGW_GNUC_PREREQ(major, minor) \
40 (__GNUC__ > (major) \
41 || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
42 #else
43 #define __MINGW_GNUC_PREREQ(major, minor) 0
44 #endif
45
46 #if defined (_MSC_VER)
47 #define __MINGW_MSC_PREREQ(major, minor) (_MSC_VER >= (major * 100 + minor * 10))
48 #else
49 #define __MINGW_MSC_PREREQ(major, minor) 0
50 #endif
51
52 #define USE___UUIDOF 0
53
54 #ifdef __cplusplus
55 # define __CRT_INLINE inline
56 #elif defined(_MSC_VER)
57 # define __CRT_INLINE __inline
58 #elif defined(__GNUC__)
59 # if defined(__clang__) || ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L)
60 # define __CRT_INLINE extern inline __attribute__((__always_inline__,__gnu_inline__))
61 # else
62 # define __CRT_INLINE extern __inline__ __attribute__((__always_inline__))
63 # endif
64 #endif
65
66 #ifdef __cplusplus
67 # define __UNUSED_PARAM(x)
68 #else
69 # ifdef __GNUC__
70 # define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
71 # else
72 # define __UNUSED_PARAM(x) x
73 # endif
74 #endif
75
76 #ifdef __cplusplus
77 # define __unaligned
78 #else
79 # ifdef __GNUC__
80 # define __unaligned
81 # elif defined(_MSC_VER) && !defined(_M_IA64) && !defined(_M_AMD64)
82 # define __unaligned
83 # else
84 # define __unaligned
85 # endif
86 #endif
87
88 #ifdef __GNUC__
89 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
90 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
91 #elif __MINGW_MSC_PREREQ(12, 0)
92 #define __MINGW_ATTRIB_NORETURN __declspec(noreturn)
93 #define __MINGW_ATTRIB_CONST
94 #else
95 #define __MINGW_ATTRIB_NORETURN
96 #define __MINGW_ATTRIB_CONST
97 #endif
98
99 #if __MINGW_GNUC_PREREQ (3, 0)
100 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
101 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
102 #elif __MINGW_MSC_PREREQ(14, 0)
103 #define __MINGW_ATTRIB_MALLOC __declspec(noalias) __declspec(restrict)
104 #define __MINGW_ATTRIB_PURE
105 #else
106 #define __MINGW_ATTRIB_MALLOC
107 #define __MINGW_ATTRIB_PURE
108 #endif
109
110 /* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
111 variadiac macro facility, because variadic macros cause syntax
112 errors with --traditional-cpp. */
113 #if __MINGW_GNUC_PREREQ (3, 3)
114 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
115 #else
116 #define __MINGW_ATTRIB_NONNULL(arg)
117 #endif /* GNUC >= 3.3 */
118
119 #ifdef __GNUC__
120 #define __MINGW_ATTRIB_UNUSED __attribute__ ((__unused__))
121 #else
122 #define __MINGW_ATTRIB_UNUSED
123 #endif /* ATTRIBUTE_UNUSED */
124
125 #if __MINGW_GNUC_PREREQ (3, 1)
126 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
127 #elif __MINGW_MSC_PREREQ(12, 0)
128 #define __MINGW_ATTRIB_DEPRECATED __declspec(deprecated)
129 #else
130 #define __MINGW_ATTRIB_DEPRECATED
131 #endif
132
133 #if __MINGW_GNUC_PREREQ (3, 1)
134 #define __MINGW_ATTRIB_DEPRECATED_SEC_WARN //__attribute__ ((__deprecated__))
135 #elif __MINGW_MSC_PREREQ(12, 0)
136 #define __MINGW_ATTRIB_DEPRECATED_SEC_WARN //__declspec(deprecated)
137 #else
138 #define __MINGW_ATTRIB_DEPRECATED_SEC_WARN
139 #endif
140
141 #if __MINGW_GNUC_PREREQ (3, 1)
142 #define __MINGW_ATTRIB_DEPRECATED_MSVC2005 //__attribute__ ((__deprecated__))
143 #elif __MINGW_MSC_PREREQ(12, 0)
144 #define __MINGW_ATTRIB_DEPRECATED_MSVC2005 //__declspec(deprecated)
145 #else
146 #define __MINGW_ATTRIB_DEPRECATED_MSVC2005
147 #endif
148
149 #if __MINGW_GNUC_PREREQ (3, 3)
150 #define __MINGW_NOTHROW __attribute__ ((__nothrow__))
151 #elif __MINGW_MSC_PREREQ(12, 0) && defined (__cplusplus)
152 #define __MINGW_NOTHROW __declspec(nothrow)
153 #else
154 #define __MINGW_NOTHROW
155 #endif
156
157 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW. This will
158 allow GCC to optimize away some EH unwind code, at least in DW2 case. */
159
160 #ifndef __MINGW_EXTENSION
161 #if defined(__GNUC__) || defined(__GNUG__)
162 #define __MINGW_EXTENSION __extension__
163 #else
164 #define __MINGW_EXTENSION
165 #endif
166 #endif
167
168 #ifndef __MSVCRT_VERSION__
169 /* High byte is the major version, low byte is the minor. */
170 # define __MSVCRT_VERSION__ 0x0700
171 #endif
172
173 //#ifndef WINVER
174 //#define WINVER 0x0502
175 //#endif
176
177 //#ifndef _WIN32_WINNT
178 //#define _WIN32_WINNT 0x502
179 //#endif
180
181 #ifdef __GNUC__
182 #define __int8 char
183 #define __int16 short
184 #define __int32 int
185 #define __int64 long long
186 #ifdef _WIN64
187 typedef int __int128 __attribute__ ((mode (TI)));
188 # endif
189 # define __ptr32
190 # define __ptr64
191 # if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L)
192 # define __forceinline extern inline __attribute__((__always_inline__,__gnu_inline__))
193 # else
194 # define __forceinline extern __inline__ __attribute__((__always_inline__))
195 # endif
196 #endif
197
198 #ifdef __cplusplus
199 #ifndef __nothrow
200 #define __nothrow __declspec(nothrow)
201 #endif
202 #else
203 #ifndef __nothrow
204 #define __nothrow
205 #endif
206 #endif
207
208 #if defined(_WIN64) && !defined(_MSC_VER)
209 #undef USE_MINGW_SETJMP_TWO_ARGS
210 #define USE_MINGW_SETJMP_TWO_ARGS
211 #endif
212
213 /* Disable deprecation for now! */
214 #define _CRT_SECURE_NO_DEPRECATE
215 #define _CRT_SECURE_NO_DEPRECATE_CORE
216 #ifdef __WINESRC__
217 #define _CRT_NONSTDC_NO_DEPRECATE
218 #endif
219
220 #define __crt_typefix(ctype)
221
222 #ifndef _CRT_UNUSED
223 #define _CRT_UNUSED(x) (void)x
224 #endif
225
226 #if defined(_MSC_VER) && !defined(__clang__)
227 #define ATTRIB_NORETURN
228 #define _DECLSPEC_INTRIN_TYPE __declspec(intrin_type)
229 #else
230 #define ATTRIB_NORETURN DECLSPEC_NORETURN
231 #define _DECLSPEC_INTRIN_TYPE
232 #endif
233
234 /* Define to a function attribute for Microsoft hotpatch assembly prefix. */
235 #ifndef DECLSPEC_HOTPATCH
236 #if defined(_MSC_VER) || defined(__clang__)
237 /* FIXME: http://llvm.org/bugs/show_bug.cgi?id=20888 */
238 #define DECLSPEC_HOTPATCH
239 #else
240 #define DECLSPEC_HOTPATCH __attribute__((__ms_hook_prologue__))
241 #endif
242 #endif /* DECLSPEC_HOTPATCH */
243
244 #ifdef __cplusplus
245 # define __mingw_ovr inline __cdecl
246 #elif defined (__GNUC__)
247 # define __mingw_ovr static \
248 __attribute__ ((__unused__)) __inline__ __cdecl
249 #else
250 # define __mingw_ovr static __cdecl
251 #endif /* __cplusplus */
252
253 #include "_mingw_mac.h"
254
255 #endif /* !_INC_MINGW */
256