Debian Codegraph @

mingw-w64-headers/crt/_mingw_mac.h

raw
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7 #ifndef _INC_CRTDEFS_MACRO
8 #define _INC_CRTDEFS_MACRO
9
10 #define __MINGW64_PASTE2(x, y) x ## y
11 #define __MINGW64_PASTE(x, y) __MINGW64_PASTE2(x, y)
12
13 #define __STRINGIFY(x) #x
14 #define __MINGW64_STRINGIFY(x) \
15 __STRINGIFY(x)
16
17 #define __MINGW64_VERSION_MAJOR 14
18 #define __MINGW64_VERSION_MINOR 0
19 #define __MINGW64_VERSION_BUGFIX 0
20
21 /* This macro holds an monotonic increasing value, which indicates
22 a specific fix/patch is present on trunk. This value isn't related to
23 minor/major version-macros. It is increased on demand, if a big
24 fix was applied to trunk. This macro gets just increased on trunk. For
25 other branches its value won't be modified. */
26
27 #define __MINGW64_VERSION_RC 0
28
29 #define __MINGW64_VERSION_STR \
30 __MINGW64_STRINGIFY(__MINGW64_VERSION_MAJOR) \
31 "." \
32 __MINGW64_STRINGIFY(__MINGW64_VERSION_MINOR) \
33 "." \
34 __MINGW64_STRINGIFY(__MINGW64_VERSION_BUGFIX)
35
36 #define __MINGW64_VERSION_STATE "alpha"
37
38 /* mingw.org's version macros: these make gcc to define
39 MINGW32_SUPPORTS_MT_EH and to use the _CRT_MT global
40 and the __mingwthr_key_dtor() function from the MinGW
41 CRT in its private gthr-win32.h header. */
42 #define __MINGW32_MAJOR_VERSION 3
43 #define __MINGW32_MINOR_VERSION 11
44
45 /* Set VC specific compiler target macros. */
46 #if defined(__x86_64) && defined(_X86_)
47 # undef _X86_ /* _X86_ is not for __x86_64 */
48 #endif
49
50 #if defined(_X86_) && !defined(_M_IX86) && !defined(_M_IA64) \
51 && !defined(_M_AMD64) && !defined(__x86_64)
52 # if defined(__i486__)
53 # define _M_IX86 400
54 # elif defined(__i586__)
55 # define _M_IX86 500
56 # elif defined(__i686__)
57 # define _M_IX86 600
58 # else
59 # define _M_IX86 300
60 # endif
61 #endif /* if defined(_X86_) && !defined(_M_IX86) && !defined(_M_IA64) ... */
62
63 #if defined(__x86_64) && !defined(_M_IX86) && !defined(_M_IA64) \
64 && !defined(_M_AMD64)
65 # define _M_AMD64 100
66 # define _M_X64 100
67 #endif
68
69 #if defined(__ia64__) && !defined(_M_IX86) && !defined(_M_IA64) \
70 && !defined(_M_AMD64) && !defined(_X86_) && !defined(__x86_64)
71 # define _M_IA64 100
72 #endif
73
74 #if defined(__arm__) && !defined(_M_ARM) && !defined(_M_ARMT) \
75 && !defined(_M_THUMB)
76 # define _M_ARM 100
77 # define _M_ARMT 100
78 # define _M_THUMB 100
79 # ifndef _ARM_
80 # define _ARM_ 1
81 # endif
82 # ifndef _M_ARM_NT
83 # define _M_ARM_NT 1
84 # endif
85 #endif
86
87 #if defined(__aarch64__) && !defined(_M_ARM64)
88 # define _M_ARM64 1
89 # ifndef _ARM64_
90 # define _ARM64_ 1
91 # endif
92 #endif
93
94 #if defined(__arm64ec__) && !defined(_M_ARM64EC)
95 # define _M_ARM64EC 1
96 # ifndef _ARM64EC_
97 # define _ARM64EC_ 1
98 # endif
99 #endif
100
101 #ifndef _X86_
102 /* MS does not prefix symbols by underscores for 64-bit. */
103 # ifndef __MINGW_USE_UNDERSCORE_PREFIX
104 /* As we have to support older gcc version, which are using underscores
105 as symbol prefix for x64, we have to check here for the user label
106 prefix defined by gcc. */
107 # ifdef __USER_LABEL_PREFIX__
108 # pragma push_macro ("_")
109 # undef _
110 # define _ 1
111 # if (__USER_LABEL_PREFIX__ + 0) != 0
112 # define __MINGW_USE_UNDERSCORE_PREFIX 1
113 # else
114 # define __MINGW_USE_UNDERSCORE_PREFIX 0
115 # endif
116 # undef _
117 # pragma pop_macro ("_")
118 # else /* ! __USER_LABEL_PREFIX__ */
119 # define __MINGW_USE_UNDERSCORE_PREFIX 0
120 # endif /* __USER_LABEL_PREFIX__ */
121 # endif
122 #else /* ! ifndef _X86_ */
123 /* For x86 we have always to prefix by underscore. */
124 # undef __MINGW_USE_UNDERSCORE_PREFIX
125 # define __MINGW_USE_UNDERSCORE_PREFIX 1
126 #endif /* ifndef _X86_ */
127
128 #if __MINGW_USE_UNDERSCORE_PREFIX == 0
129 # define __MINGW_IMP_SYMBOL(sym) __MINGW64_PASTE(__imp_,sym)
130 # define __MINGW_IMP_LSYMBOL(sym) __MINGW64_PASTE(__imp_,sym)
131 # define __MINGW_USYMBOL(sym) sym
132 # define __MINGW_LSYMBOL(sym) __MINGW64_PASTE(_,sym)
133 #else /* ! if __MINGW_USE_UNDERSCORE_PREFIX == 0 */
134 # define __MINGW_IMP_SYMBOL(sym) __MINGW64_PASTE(_imp__,sym)
135 # define __MINGW_IMP_LSYMBOL(sym) __MINGW64_PASTE(__imp__,sym)
136 # define __MINGW_USYMBOL(sym) __MINGW64_PASTE(_,sym)
137 # define __MINGW_LSYMBOL(sym) sym
138 #endif /* if __MINGW_USE_UNDERSCORE_PREFIX == 0 */
139
140 #define __MINGW_ASM_CALL(func) __asm__(__MINGW64_STRINGIFY(__MINGW_USYMBOL(func)))
141 #define __MINGW_ASM_CRT_CALL(func) __asm__(__STRINGIFY(func))
142
143 #ifndef __PTRDIFF_TYPE__
144 # ifdef _WIN64
145 # define __PTRDIFF_TYPE__ long long int
146 # else
147 # define __PTRDIFF_TYPE__ long int
148 # endif
149 #endif
150
151 #ifndef __SIZE_TYPE__
152 # ifdef _WIN64
153 # define __SIZE_TYPE__ long long unsigned int
154 # else
155 # define __SIZE_TYPE__ long unsigned int
156 # endif
157 #endif
158
159 #ifndef __WCHAR_TYPE__
160 # define __WCHAR_TYPE__ unsigned short
161 #endif
162
163 #ifndef __WINT_TYPE__
164 # define __WINT_TYPE__ unsigned short
165 #endif
166
167 #undef __MINGW_EXTENSION
168
169 #ifdef __WIDL__
170 # define __MINGW_EXTENSION
171 #else
172 # if defined(__GNUC__) || defined(__GNUG__)
173 # define __MINGW_EXTENSION __extension__
174 # else
175 # define __MINGW_EXTENSION
176 # endif
177 #endif /* __WIDL__ */
178
179 /* Special case nameless struct/union. */
180 #ifndef __C89_NAMELESS
181 # define __C89_NAMELESS __MINGW_EXTENSION
182 # define __C89_NAMELESSSTRUCTNAME
183 # define __C89_NAMELESSSTRUCTNAME1
184 # define __C89_NAMELESSSTRUCTNAME2
185 # define __C89_NAMELESSSTRUCTNAME3
186 # define __C89_NAMELESSSTRUCTNAME4
187 # define __C89_NAMELESSSTRUCTNAME5
188 # define __C89_NAMELESSUNIONNAME
189 # define __C89_NAMELESSUNIONNAME1
190 # define __C89_NAMELESSUNIONNAME2
191 # define __C89_NAMELESSUNIONNAME3
192 # define __C89_NAMELESSUNIONNAME4
193 # define __C89_NAMELESSUNIONNAME5
194 # define __C89_NAMELESSUNIONNAME6
195 # define __C89_NAMELESSUNIONNAME7
196 # define __C89_NAMELESSUNIONNAME8
197 #endif
198
199 #ifndef __GNU_EXTENSION
200 # define __GNU_EXTENSION __MINGW_EXTENSION
201 #endif
202
203 /* MinGW-w64 has some additional C99 printf/scanf feature support.
204 So we add some helper macros to ease recognition of them. */
205 #define __MINGW_HAVE_ANSI_C99_PRINTF 1
206 #define __MINGW_HAVE_WIDE_C99_PRINTF 1
207 #define __MINGW_HAVE_ANSI_C99_SCANF 1
208 #define __MINGW_HAVE_WIDE_C99_SCANF 1
209
210 #ifdef __MINGW_USE_BROKEN_INTERFACE
211 # define __MINGW_POISON_NAME(__IFACE) __IFACE
212 #else
213 # define __MINGW_POISON_NAME(__IFACE) \
214 __IFACE##_layout_has_not_been_verified_and_its_declaration_is_most_likely_incorrect
215 #endif
216
217 #ifndef __MSABI_LONG
218 # ifndef __LP64__
219 # define __MSABI_LONG(x) x ## l
220 # else
221 # define __MSABI_LONG(x) x
222 # endif
223 #endif
224
225 #if __GNUC__
226 # define __MINGW_GCC_VERSION (__GNUC__ * 10000 + \
227 __GNUC_MINOR__ * 100 + \
228 __GNUC_PATCHLEVEL__)
229 #else
230 # define __MINGW_GCC_VERSION 0
231 #endif
232
233 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
234 # define __MINGW_GNUC_PREREQ(major, minor) \
235 (__GNUC__ > (major) \
236 || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
237 #else
238 # define __MINGW_GNUC_PREREQ(major, minor) 0
239 #endif
240
241 #if defined (_MSC_VER)
242 # define __MINGW_MSC_PREREQ(major, minor) \
243 (_MSC_VER >= (major * 100 + minor * 10))
244 #else
245 # define __MINGW_MSC_PREREQ(major, minor) 0
246 #endif
247
248 #ifdef __MINGW_MSVC_COMPAT_WARNINGS
249 # if __MINGW_GNUC_PREREQ (4, 5)
250 # define __MINGW_ATTRIB_DEPRECATED_STR(X) \
251 __attribute__ ((__deprecated__ (X)))
252 # else
253 # define __MINGW_ATTRIB_DEPRECATED_STR(X) \
254 __MINGW_ATTRIB_DEPRECATED
255 # endif
256 #else
257 # define __MINGW_ATTRIB_DEPRECATED_STR(X)
258 #endif /* ifdef __MINGW_MSVC_COMPAT_WARNINGS */
259
260 #define __MINGW_SEC_WARN_STR \
261 "This function or variable may be unsafe, use _CRT_SECURE_NO_WARNINGS to disable deprecation"
262
263 #define __MINGW_MSVC2005_DEPREC_STR \
264 "This POSIX function is deprecated beginning in Visual C++ 2005, use _CRT_NONSTDC_NO_DEPRECATE to disable deprecation"
265
266 #if !defined (_CRT_NONSTDC_NO_DEPRECATE)
267 # define __MINGW_ATTRIB_DEPRECATED_MSVC2005 \
268 __MINGW_ATTRIB_DEPRECATED_STR(__MINGW_MSVC2005_DEPREC_STR)
269 #else
270 # define __MINGW_ATTRIB_DEPRECATED_MSVC2005
271 #endif
272
273 #if !defined (_CRT_SECURE_NO_WARNINGS)
274 # define __MINGW_ATTRIB_DEPRECATED_SEC_WARN \
275 __MINGW_ATTRIB_DEPRECATED_STR(__MINGW_SEC_WARN_STR)
276 #else
277 # define __MINGW_ATTRIB_DEPRECATED_SEC_WARN
278 #endif
279
280 #ifdef __clang__
281 #define __MINGW_MS_PRINTF(__format,__args) \
282 __attribute__((__format__(__printf__, __format,__args)))
283
284 #define __MINGW_MS_SCANF(__format,__args) \
285 __attribute__((__format__(__scanf__, __format,__args)))
286
287 #define __MINGW_GNU_PRINTF(__format,__args) \
288 __attribute__((__format__(__printf__,__format,__args)))
289
290 #define __MINGW_GNU_SCANF(__format,__args) \
291 __attribute__((__format__(__scanf__, __format,__args)))
292 #else
293 #define __MINGW_MS_PRINTF(__format,__args) \
294 __attribute__((__format__(__ms_printf__, __format,__args)))
295
296 #define __MINGW_MS_SCANF(__format,__args) \
297 __attribute__((__format__(__ms_scanf__, __format,__args)))
298
299 #define __MINGW_GNU_PRINTF(__format,__args) \
300 __attribute__((__format__(__gnu_printf__,__format,__args)))
301
302 #define __MINGW_GNU_SCANF(__format,__args) \
303 __attribute__((__format__(__gnu_scanf__, __format,__args)))
304 #endif /* !__clang__ */
305
306 #undef __mingw_ovr
307
308 #ifdef __cplusplus
309 # define __mingw_ovr inline __cdecl
310 #elif defined (__GNUC__)
311 # define __mingw_ovr static \
312 __attribute__ ((__unused__)) __inline__ __cdecl
313 #else
314 # define __mingw_ovr static __cdecl
315 #endif /* __cplusplus */
316
317 #if __MINGW_GNUC_PREREQ(4, 3) || defined(__clang__)
318 # define __mingw_attribute_artificial \
319 __attribute__((__artificial__))
320 #else
321 # define __mingw_attribute_artificial
322 #endif
323
324 #define __MINGW_SELECTANY __attribute__((__selectany__))
325
326 #pragma push_macro("__has_builtin")
327 #ifndef __has_builtin
328 # define __has_builtin(x) 0
329 #endif
330
331 #if defined(__MINGW32__) && _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 \
332 && __MINGW_GNUC_PREREQ(4, 1)
333 # if _FORTIFY_SOURCE > 3
334 # warning Using _FORTIFY_SOURCE=3 (levels > 3 are not supported)
335 # endif
336 # if _FORTIFY_SOURCE > 2
337 # if __has_builtin(__builtin_dynamic_object_size)
338 # define __MINGW_FORTIFY_LEVEL 3
339 # else
340 # warning Using _FORTIFY_SOURCE=2 (level 3 requires __builtin_dynamic_object_size support)
341 # define __MINGW_FORTIFY_LEVEL 2
342 # endif
343 # elif _FORTIFY_SOURCE > 1
344 # define __MINGW_FORTIFY_LEVEL 2
345 # else
346 # define __MINGW_FORTIFY_LEVEL 1
347 # endif
348 #else
349 # define __MINGW_FORTIFY_LEVEL 0
350 #endif
351
352 #if __MINGW_FORTIFY_LEVEL > 0
353 /* Calling an function with __attribute__((__warning__("...")))
354 from a system include __inline__ function does not print
355 a warning unless caller has __attribute__((__artificial__)). */
356 # define __mingw_bos_declare \
357 void __cdecl __chk_fail(void) __attribute__((__noreturn__)); \
358 void __cdecl __mingw_chk_fail_warn(void) __MINGW_ASM_CALL(__chk_fail) \
359 __attribute__((__noreturn__)) \
360 __attribute__((__warning__("Buffer overflow detected")))
361 # if __MINGW_FORTIFY_LEVEL > 2
362 # define __mingw_bos(p, maxtype) \
363 __builtin_dynamic_object_size((p), (maxtype) > 0)
364 # define __mingw_bos_known(p) \
365 (__builtin_object_size(p, 0) != (size_t)-1 \
366 || !__builtin_constant_p(__mingw_bos(p, 0)))
367 # else
368 # define __mingw_bos(p, maxtype) \
369 __builtin_object_size((p), ((maxtype) > 0) && (__MINGW_FORTIFY_LEVEL > 1))
370 # define __mingw_bos_known(p) \
371 (__mingw_bos(p, 0) != (size_t)-1)
372 # endif
373 # define __mingw_bos_cond_chk(c) \
374 (__builtin_expect((c), 1) ? (void)0 : __chk_fail())
375 # define __mingw_bos_ptr_chk(p, n, maxtype) \
376 __mingw_bos_cond_chk(!__mingw_bos_known(p) || __mingw_bos(p, maxtype) >= (size_t)(n))
377 # define __mingw_bos_ptr_chk_warn(p, n, maxtype) \
378 ((__mingw_bos_known(p) \
379 && __builtin_constant_p(__mingw_bos(p, maxtype) < (size_t)(n)) \
380 && __mingw_bos(p, maxtype) < (size_t)(n)) \
381 ? __mingw_chk_fail_warn() : __mingw_bos_ptr_chk(p, n, maxtype))
382 # define __mingw_bos_ovr __mingw_ovr \
383 __attribute__((__always_inline__)) \
384 __mingw_attribute_artificial
385 # define __mingw_bos_extern_ovr extern __inline__ __cdecl \
386 __attribute__((__always_inline__, __gnu_inline__)) \
387 __mingw_attribute_artificial
388 #else
389 # define __mingw_bos_ovr __mingw_ovr
390 #endif /* __MINGW_FORTIFY_LEVEL > 0 */
391
392 /* If _FORTIFY_SOURCE is enabled, some inline functions may use
393 __builtin_va_arg_pack(). GCC may report an error if the address
394 of such a function is used. Set _FORTIFY_VA_ARG=0 in this case.
395 Clang doesn't, as of version 15, yet implement __builtin_va_arg_pack(). */
396 #if __MINGW_FORTIFY_LEVEL > 0 \
397 && ((__MINGW_GNUC_PREREQ(4, 3) && !defined(__clang__)) \
398 || __has_builtin(__builtin_va_arg_pack)) \
399 && (!defined(_FORTIFY_VA_ARG) || _FORTIFY_VA_ARG > 0)
400 # define __MINGW_FORTIFY_VA_ARG 1
401 #else
402 # define __MINGW_FORTIFY_VA_ARG 0
403 #endif
404
405 #pragma pop_macro("__has_builtin")
406
407 /* Enable workaround for ABI incompatibility on affected platforms */
408 #ifndef WIDL_EXPLICIT_AGGREGATE_RETURNS
409 #if defined(__GNUC__) && defined(__cplusplus)
410 #define WIDL_EXPLICIT_AGGREGATE_RETURNS
411 #endif
412 #endif
413
414 #endif /* _INC_CRTDEFS_MACRO */