|
11 | 11 | #define __MINGW64_STRINGIFY(x) \ |
12 | 12 | __STRINGIFY(x) |
13 | 13 |
|
14 | | -#define __MINGW64_VERSION_MAJOR 10 |
| 14 | +#define __MINGW64_VERSION_MAJOR 12 |
15 | 15 | #define __MINGW64_VERSION_MINOR 0 |
16 | 16 | #define __MINGW64_VERSION_BUGFIX 0 |
17 | 17 |
|
|
294 | 294 | # define __mingw_static_ovr __mingw_ovr |
295 | 295 | #endif /* __cplusplus */ |
296 | 296 |
|
297 | | -#if __MINGW_GNUC_PREREQ(4, 3) && !defined(__clang__) |
| 297 | +#if __MINGW_GNUC_PREREQ(4, 3) || defined(__clang__) |
298 | 298 | # define __mingw_attribute_artificial \ |
299 | 299 | __attribute__((__artificial__)) |
300 | 300 | #else |
|
303 | 303 |
|
304 | 304 | #define __MINGW_SELECTANY __attribute__((__selectany__)) |
305 | 305 |
|
| 306 | +#pragma push_macro("__has_builtin") |
| 307 | +#ifndef __has_builtin |
| 308 | +# define __has_builtin(x) 0 |
| 309 | +#endif |
| 310 | + |
306 | 311 | #if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 && __MINGW_GNUC_PREREQ(4, 1) |
307 | | -# if _FORTIFY_SOURCE > 1 |
| 312 | +# if _FORTIFY_SOURCE > 3 |
| 313 | +# warning Using _FORTIFY_SOURCE=3 (levels > 3 are not supported) |
| 314 | +# endif |
| 315 | +# if _FORTIFY_SOURCE > 2 |
| 316 | +# if __has_builtin(__builtin_dynamic_object_size) |
| 317 | +# define __MINGW_FORTIFY_LEVEL 3 |
| 318 | +# else |
| 319 | +# warning Using _FORTIFY_SOURCE=2 (level 3 requires __builtin_dynamic_object_size support) |
| 320 | +# define __MINGW_FORTIFY_LEVEL 2 |
| 321 | +# endif |
| 322 | +# elif _FORTIFY_SOURCE > 1 |
308 | 323 | # define __MINGW_FORTIFY_LEVEL 2 |
309 | 324 | # else |
310 | 325 | # define __MINGW_FORTIFY_LEVEL 1 |
|
322 | 337 | void __cdecl __mingw_chk_fail_warn(void) __MINGW_ASM_CALL(__chk_fail) \ |
323 | 338 | __attribute__((__noreturn__)) \ |
324 | 339 | __attribute__((__warning__("Buffer overflow detected"))) |
325 | | -# define __mingw_bos(p, maxtype) \ |
326 | | - __builtin_object_size((p), ((maxtype) > 0) && (__MINGW_FORTIFY_LEVEL > 1)) |
327 | | -# define __mingw_bos_known(p) \ |
328 | | - (__mingw_bos(p, 0) != (size_t)-1) |
| 340 | +# if __MINGW_FORTIFY_LEVEL > 2 |
| 341 | +# define __mingw_bos(p, maxtype) \ |
| 342 | + __builtin_dynamic_object_size((p), (maxtype) > 0) |
| 343 | +# define __mingw_bos_known(p) \ |
| 344 | + (__builtin_object_size(p, 0) != (size_t)-1 \ |
| 345 | + || !__builtin_constant_p(__mingw_bos(p, 0))) |
| 346 | +# else |
| 347 | +# define __mingw_bos(p, maxtype) \ |
| 348 | + __builtin_object_size((p), ((maxtype) > 0) && (__MINGW_FORTIFY_LEVEL > 1)) |
| 349 | +# define __mingw_bos_known(p) \ |
| 350 | + (__mingw_bos(p, 0) != (size_t)-1) |
| 351 | +# endif |
329 | 352 | # define __mingw_bos_cond_chk(c) \ |
330 | 353 | (__builtin_expect((c), 1) ? (void)0 : __chk_fail()) |
331 | 354 | # define __mingw_bos_ptr_chk(p, n, maxtype) \ |
332 | 355 | __mingw_bos_cond_chk(!__mingw_bos_known(p) || __mingw_bos(p, maxtype) >= (size_t)(n)) |
333 | 356 | # define __mingw_bos_ptr_chk_warn(p, n, maxtype) \ |
334 | | - (__mingw_bos_known(p) && __builtin_constant_p((n)) && __mingw_bos(p, maxtype) < (size_t)(n) \ |
| 357 | + ((__mingw_bos_known(p) \ |
| 358 | + && __builtin_constant_p(__mingw_bos(p, maxtype) < (size_t)(n)) \ |
| 359 | + && __mingw_bos(p, maxtype) < (size_t)(n)) \ |
335 | 360 | ? __mingw_chk_fail_warn() : __mingw_bos_ptr_chk(p, n, maxtype)) |
336 | 361 | # define __mingw_bos_ovr __mingw_ovr \ |
337 | 362 | __attribute__((__always_inline__)) \ |
|
345 | 370 |
|
346 | 371 | /* If _FORTIFY_SOURCE is enabled, some inline functions may use |
347 | 372 | __builtin_va_arg_pack(). GCC may report an error if the address |
348 | | - of such a function is used. Set _FORTIFY_VA_ARG=0 in this case. */ |
349 | | -#if __MINGW_FORTIFY_LEVEL > 0 && __MINGW_GNUC_PREREQ(4, 3) && !defined(__clang__) \ |
| 373 | + of such a function is used. Set _FORTIFY_VA_ARG=0 in this case. |
| 374 | + Clang doesn't, as of version 15, yet implement __builtin_va_arg_pack(). */ |
| 375 | +#if __MINGW_FORTIFY_LEVEL > 0 \ |
| 376 | + && ((__MINGW_GNUC_PREREQ(4, 3) && !defined(__clang__)) \ |
| 377 | + || __has_builtin(__builtin_va_arg_pack)) \ |
350 | 378 | && (!defined(_FORTIFY_VA_ARG) || _FORTIFY_VA_ARG > 0) |
351 | 379 | # define __MINGW_FORTIFY_VA_ARG 1 |
352 | 380 | #else |
353 | 381 | # define __MINGW_FORTIFY_VA_ARG 0 |
354 | 382 | #endif |
355 | 383 |
|
| 384 | +#pragma pop_macro("__has_builtin") |
| 385 | + |
356 | 386 | /* Enable workaround for ABI incompatibility on affected platforms */ |
357 | 387 | #ifndef WIDL_EXPLICIT_AGGREGATE_RETURNS |
358 | 388 | #if defined(__GNUC__) && defined(__cplusplus) |
|
0 commit comments