sync to trunk r38300
[reactos.git] / reactos / 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 // ROS HACK!
13 #ifndef _WIN64
14 #ifndef _USE_32BIT_TIME_T
15 #define _USE_32BIT_TIME_T
16 #endif
17 #endif
18
19 #ifndef MINGW64
20 #define MINGW64
21 #define MINGW64_VERSION 1.0
22 #define MINGW64_VERSION_MAJOR 1
23 #define MINGW64_VERSION_MINOR 0
24 #define MINGW64_VERSION_STATE "alpha"
25 #endif
26
27 #ifdef _WIN64
28 #ifdef __stdcall
29 #undef __stdcall
30 #endif
31 #define __stdcall
32 #endif
33
34 #ifdef __GNUC__
35 /* These compilers do support __declspec */
36 # if !defined(__MINGW32__) && !defined(__MINGW64__) && !defined(__CYGWIN32__)
37 # define __declspec(x) __attribute__((x))
38 # endif
39 #else
40 # define __attribute__(x) /* nothing */
41 #endif
42
43 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
44 #define __MINGW_GNUC_PREREQ(major, minor) \
45 (__GNUC__ > (major) \
46 || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
47 #else
48 #define __MINGW_GNUC_PREREQ(major, minor) 0
49 #endif
50
51 #if !defined (_MSC_VER)
52 #define __MINGW_MSC_PREREQ(major, minor) 0
53 #endif
54
55 #define USE___UUIDOF 0
56
57 #ifdef __cplusplus
58 # define __CRT_INLINE inline
59 #else
60 # if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L)
61 # define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
62 # else
63 # define __CRT_INLINE extern __inline__
64 # endif
65 #endif
66
67 #ifdef __cplusplus
68 # define __UNUSED_PARAM(x)
69 #else
70 # ifdef __GNUC__
71 # define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
72 # else
73 # define __UNUSED_PARAM(x) x
74 # endif
75 #endif
76
77 #ifdef __cplusplus
78 # define __unaligned
79 #else
80 # ifdef __GNUC__
81 # define __unaligned __attribute((packed))
82 # else
83 # define __UNUSED_PARAM(x) x
84 # endif
85 #endif
86
87 #ifdef __GNUC__
88 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
89 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
90 #elif __MINGW_MSC_PREREQ(12, 0)
91 #define __MINGW_ATTRIB_NORETURN __declspec(noreturn)
92 #define __MINGW_ATTRIB_CONST
93 #else
94 #define __MINGW_ATTRIB_NORETURN
95 #define __MINGW_ATTRIB_CONST
96 #endif
97
98 #if __MINGW_GNUC_PREREQ (3, 0)
99 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
100 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
101 #else
102 #define __MINGW_ATTRIB_MALLOC
103 #define __MINGW_ATTRIB_PURE
104 #endif
105
106 /* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
107 variadiac macro facility, because variadic macros cause syntax
108 errors with --traditional-cpp. */
109 #if __MINGW_GNUC_PREREQ (3, 3)
110 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
111 #else
112 #define __MINGW_ATTRIB_NONNULL(arg)
113 #endif /* GNUC >= 3.3 */
114
115 #if __MINGW_GNUC_PREREQ (3, 1)
116 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
117 #elif __MINGW_MSC_PREREQ(12, 0)
118 #define __MINGW_ATTRIB_DEPRECATED __declspec(deprecated)
119 #else
120 #define __MINGW_ATTRIB_DEPRECATED
121 #endif
122
123 #if __MINGW_GNUC_PREREQ (3, 3)
124 #define __MINGW_NOTHROW __attribute__ ((__nothrow__))
125 #elif __MINGW_MSC_PREREQ(12, 0) && defined (__cplusplus)
126 #define __MINGW_NOTHROW __declspec(nothrow)
127 #else
128 #define __MINGW_NOTHROW
129 #endif
130
131 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW. This will
132 allow GCC to optimize away some EH unwind code, at least in DW2 case. */
133
134 #ifndef __MSVCRT_VERSION__
135 /* High byte is the major version, low byte is the minor. */
136 # define __MSVCRT_VERSION__ 0x0700
137 #endif
138
139 //#ifndef WINVER
140 //#define WINVER 0x0502
141 //#endif
142
143 //#ifndef _WIN32_WINNT
144 //#define _WIN32_WINNT 0x502
145 //#endif
146
147 #ifdef __GNUC__
148 #define __int8 char
149 #define __int16 short
150 #define __int32 int
151 #define __int64 long long
152 #ifdef _WIN64
153 typedef int __int128 __attribute__ ((mode (TI)));
154 # endif
155 # define __ptr32
156 # define __ptr64
157 # define __forceinline extern __inline __attribute((always_inline))
158 #endif
159
160 #ifdef __cplusplus
161 #ifndef __nothrow
162 #define __nothrow __declspec(nothrow)
163 #endif
164 #else
165 #ifndef __nothrow
166 #define __nothrow
167 #endif
168 #endif
169
170 #ifdef _WIN64
171 #undef USE_MINGW_SETJMP_TWO_ARGS
172 #define USE_MINGW_SETJMP_TWO_ARGS
173 #endif
174
175 #ifdef __cplusplus
176 extern "C" {
177 #endif
178
179 #ifndef __GNUC_VA_LIST
180 #define __GNUC_VA_LIST
181 typedef __builtin_va_list __gnuc_va_list;
182 #endif
183
184 #ifndef _VA_LIST_DEFINED
185 #define _VA_LIST_DEFINED
186 typedef __gnuc_va_list va_list;
187 #endif
188
189 /* Diable deprecation for now! */
190 #define _CRT_SECURE_NO_DEPRECATE
191 #define _CRT_SECURE_NO_DEPRECATE_CORE
192 #ifdef __WINESRC__
193 #define _CRT_NONSTDC_NO_DEPRECATE
194 #endif
195
196 #if (defined(_MSC_VER) && __STDC__)// || !defined(__WINESRC__)
197 #define NO_OLDNAMES
198 #endif
199
200 #ifdef __cplusplus
201 }
202 #endif
203
204 #define __crt_typefix(ctype)
205
206 #ifndef _CRT_UNUSED
207 #define _CRT_UNUSED(x) (void)x
208 #endif
209
210 /* These are here for intrin.h */
211 #ifndef _SIZE_T_DEFINED
212 #define _SIZE_T_DEFINED
213 #ifdef _WIN64
214 typedef unsigned __int64 size_t;
215 #else
216 typedef unsigned int size_t;
217 #endif
218 #endif
219
220 #ifndef _UINTPTR_T_DEFINED
221 #define _UINTPTR_T_DEFINED
222 #ifdef _WIN64
223 typedef unsigned __int64 uintptr_t;
224 #else
225 typedef unsigned int uintptr_t;
226 #endif
227 #endif
228
229 #include <mingw32/intrin.h>
230
231 #endif /* !_INC_MINGW */
232