diff options
Diffstat (limited to 'gl/m4/gnulib-common.m4')
| -rw-r--r-- | gl/m4/gnulib-common.m4 | 426 |
1 files changed, 370 insertions, 56 deletions
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index facc3404..cb730449 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | # gnulib-common.m4 serial 75a | 1 | # gnulib-common.m4 |
| 2 | dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. | 2 | # serial 93 |
| 3 | dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 6 | dnl with or without modifications, as long as this notice is preserved. |
| @@ -15,6 +16,10 @@ AC_DEFUN([gl_COMMON], [ | |||
| 15 | AC_REQUIRE([gl_ZZGNULIB]) | 16 | AC_REQUIRE([gl_ZZGNULIB]) |
| 16 | ]) | 17 | ]) |
| 17 | AC_DEFUN([gl_COMMON_BODY], [ | 18 | AC_DEFUN([gl_COMMON_BODY], [ |
| 19 | AH_VERBATIM([0witness], | ||
| 20 | [/* Witness that <config.h> has been included. */ | ||
| 21 | #define _GL_CONFIG_H_INCLUDED 1 | ||
| 22 | ]) | ||
| 18 | AH_VERBATIM([_GL_GNUC_PREREQ], | 23 | AH_VERBATIM([_GL_GNUC_PREREQ], |
| 19 | [/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ | 24 | [/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ |
| 20 | #if defined __GNUC__ && defined __GNUC_MINOR__ | 25 | #if defined __GNUC__ && defined __GNUC_MINOR__ |
| @@ -72,50 +77,74 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 72 | #endif]) | 77 | #endif]) |
| 73 | AH_VERBATIM([attribute], | 78 | AH_VERBATIM([attribute], |
| 74 | [/* Attributes. */ | 79 | [/* Attributes. */ |
| 75 | #if (defined __has_attribute \ | 80 | /* Define _GL_HAS_ATTRIBUTE only once, because on FreeBSD, with gcc < 5, if |
| 76 | && (!defined __clang_minor__ \ | 81 | <config.h> gets included once again after <sys/cdefs.h>, __has_attribute(x) |
| 77 | || (defined __apple_build_version__ \ | 82 | expands to 0 always, and redefining _GL_HAS_ATTRIBUTE would turn off all |
| 78 | ? 6000000 <= __apple_build_version__ \ | 83 | attributes. */ |
| 79 | : 3 < __clang_major__ + (5 <= __clang_minor__)))) | 84 | #ifndef _GL_HAS_ATTRIBUTE |
| 80 | # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) | 85 | # if (defined __has_attribute \ |
| 81 | #else | 86 | && (!defined __clang_minor__ \ |
| 82 | # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr | 87 | || (defined __apple_build_version__ \ |
| 83 | # define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) | 88 | ? 7000000 <= __apple_build_version__ \ |
| 84 | # define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) | 89 | : 5 <= __clang_major__))) |
| 85 | # define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) | 90 | # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) |
| 86 | # define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3) | ||
| 87 | # define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95) | ||
| 88 | # define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1) | ||
| 89 | # define _GL_ATTR_diagnose_if 0 | ||
| 90 | # define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3) | ||
| 91 | # define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1) | ||
| 92 | # define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) | ||
| 93 | # define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7) | ||
| 94 | # define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6) | ||
| 95 | # define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) | ||
| 96 | # ifdef _ICC | ||
| 97 | # define _GL_ATTR_may_alias 0 | ||
| 98 | # else | 91 | # else |
| 99 | # define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) | 92 | # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr |
| 93 | # define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) | ||
| 94 | # define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) | ||
| 95 | # define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) | ||
| 96 | # define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3) | ||
| 97 | # define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95) | ||
| 98 | # define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1) | ||
| 99 | # define _GL_ATTR_diagnose_if 0 | ||
| 100 | # define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3) | ||
| 101 | # define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1) | ||
| 102 | # define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) | ||
| 103 | # define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7) | ||
| 104 | # define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6) | ||
| 105 | # define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) | ||
| 106 | # ifdef _ICC | ||
| 107 | # define _GL_ATTR_may_alias 0 | ||
| 108 | # else | ||
| 109 | # define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) | ||
| 110 | # endif | ||
| 111 | # define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) | ||
| 112 | # define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) | ||
| 113 | # define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) | ||
| 114 | # define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) | ||
| 115 | # define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) | ||
| 116 | # define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) | ||
| 117 | # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) | ||
| 118 | # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) | ||
| 119 | # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) | ||
| 120 | # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) | ||
| 100 | # endif | 121 | # endif |
| 101 | # define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) | ||
| 102 | # define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) | ||
| 103 | # define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) | ||
| 104 | # define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) | ||
| 105 | # define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) | ||
| 106 | # define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) | ||
| 107 | # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) | ||
| 108 | # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) | ||
| 109 | # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) | ||
| 110 | # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) | ||
| 111 | #endif | 122 | #endif |
| 112 | 123 | ||
| 113 | /* Disable GCC -Wpedantic if using __has_c_attribute and this is not C23+. */ | 124 | /* Use __has_c_attribute if available. However, do not use with |
| 114 | #if (defined __has_c_attribute && _GL_GNUC_PREREQ (4, 6) \ | 125 | pre-C23 GCC, which can issue false positives if -Wpedantic. */ |
| 115 | && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710) | 126 | #if (defined __has_c_attribute \ |
| 116 | # pragma GCC diagnostic ignored "-Wpedantic" | 127 | && ! (_GL_GNUC_PREREQ (4, 6) \ |
| 128 | && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710)) | ||
| 129 | # define _GL_HAVE___HAS_C_ATTRIBUTE 1 | ||
| 130 | #else | ||
| 131 | # define _GL_HAVE___HAS_C_ATTRIBUTE 0 | ||
| 117 | #endif | 132 | #endif |
| 118 | 133 | ||
| 134 | /* Define if, in a function declaration, the attributes in bracket syntax | ||
| 135 | [[...]] must come before the attributes in __attribute__((...)) syntax. | ||
| 136 | If this is defined, it is best to avoid the bracket syntax, so that the | ||
| 137 | various _GL_ATTRIBUTE_* can be cumulated on the same declaration in any | ||
| 138 | order. */ | ||
| 139 | #ifdef __cplusplus | ||
| 140 | # if defined __clang__ | ||
| 141 | # define _GL_BRACKET_BEFORE_ATTRIBUTE 1 | ||
| 142 | # endif | ||
| 143 | #else | ||
| 144 | # if defined __GNUC__ && !defined __clang__ | ||
| 145 | # define _GL_BRACKET_BEFORE_ATTRIBUTE 1 | ||
| 146 | # endif | ||
| 147 | #endif | ||
| 119 | ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead. | 148 | ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead. |
| 120 | [ | 149 | [ |
| 121 | /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function | 150 | /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function |
| @@ -223,9 +252,11 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 223 | - typedef, | 252 | - typedef, |
| 224 | in C++ also: namespace, class, template specialization. */ | 253 | in C++ also: namespace, class, template specialization. */ |
| 225 | #ifndef _GL_ATTRIBUTE_DEPRECATED | 254 | #ifndef _GL_ATTRIBUTE_DEPRECATED |
| 226 | # ifdef __has_c_attribute | 255 | # ifndef _GL_BRACKET_BEFORE_ATTRIBUTE |
| 227 | # if __has_c_attribute (__deprecated__) | 256 | # if _GL_HAVE___HAS_C_ATTRIBUTE |
| 228 | # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] | 257 | # if __has_c_attribute (__deprecated__) |
| 258 | # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] | ||
| 259 | # endif | ||
| 229 | # endif | 260 | # endif |
| 230 | # endif | 261 | # endif |
| 231 | # if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated) | 262 | # if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated) |
| @@ -271,7 +302,7 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 271 | /* Applies to: Empty statement (;), inside a 'switch' statement. */ | 302 | /* Applies to: Empty statement (;), inside a 'switch' statement. */ |
| 272 | /* Always expands to something. */ | 303 | /* Always expands to something. */ |
| 273 | #ifndef _GL_ATTRIBUTE_FALLTHROUGH | 304 | #ifndef _GL_ATTRIBUTE_FALLTHROUGH |
| 274 | # ifdef __has_c_attribute | 305 | # if _GL_HAVE___HAS_C_ATTRIBUTE |
| 275 | # if __has_c_attribute (__fallthrough__) | 306 | # if __has_c_attribute (__fallthrough__) |
| 276 | # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] | 307 | # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] |
| 277 | # endif | 308 | # endif |
| @@ -351,11 +382,19 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 351 | in C++ also: class. */ | 382 | in C++ also: class. */ |
| 352 | /* In C++ and C23, this is spelled [[__maybe_unused__]]. | 383 | /* In C++ and C23, this is spelled [[__maybe_unused__]]. |
| 353 | GCC's syntax is __attribute__ ((__unused__)). | 384 | GCC's syntax is __attribute__ ((__unused__)). |
| 354 | clang supports both syntaxes. */ | 385 | clang supports both syntaxes. Except that with clang ≥ 6, < 10, in C++ mode, |
| 386 | __has_c_attribute (__maybe_unused__) yields true but the use of | ||
| 387 | [[__maybe_unused__]] nevertheless produces a warning. */ | ||
| 355 | #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED | 388 | #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED |
| 356 | # ifdef __has_c_attribute | 389 | # ifndef _GL_BRACKET_BEFORE_ATTRIBUTE |
| 357 | # if __has_c_attribute (__maybe_unused__) | 390 | # if defined __clang__ && defined __cplusplus |
| 358 | # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] | 391 | # if !defined __apple_build_version__ && __clang_major__ >= 10 |
| 392 | # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] | ||
| 393 | # endif | ||
| 394 | # elif _GL_HAVE___HAS_C_ATTRIBUTE | ||
| 395 | # if __has_c_attribute (__maybe_unused__) | ||
| 396 | # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] | ||
| 397 | # endif | ||
| 359 | # endif | 398 | # endif |
| 360 | # endif | 399 | # endif |
| 361 | # ifndef _GL_ATTRIBUTE_MAYBE_UNUSED | 400 | # ifndef _GL_ATTRIBUTE_MAYBE_UNUSED |
| @@ -373,9 +412,20 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 373 | the return value, unless the caller uses something like ignore_value. */ | 412 | the return value, unless the caller uses something like ignore_value. */ |
| 374 | /* Applies to: function, enumeration, class. */ | 413 | /* Applies to: function, enumeration, class. */ |
| 375 | #ifndef _GL_ATTRIBUTE_NODISCARD | 414 | #ifndef _GL_ATTRIBUTE_NODISCARD |
| 376 | # ifdef __has_c_attribute | 415 | # ifndef _GL_BRACKET_BEFORE_ATTRIBUTE |
| 377 | # if __has_c_attribute (__nodiscard__) | 416 | # if defined __clang__ && defined __cplusplus |
| 378 | # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] | 417 | /* With clang up to 15.0.6 (at least), in C++ mode, [[__nodiscard__]] produces |
| 418 | a warning. | ||
| 419 | The 1000 below means a yet unknown threshold. When clang++ version X | ||
| 420 | starts supporting [[__nodiscard__]] without warning about it, you can | ||
| 421 | replace the 1000 with X. */ | ||
| 422 | # if __clang_major__ >= 1000 | ||
| 423 | # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] | ||
| 424 | # endif | ||
| 425 | # elif _GL_HAVE___HAS_C_ATTRIBUTE | ||
| 426 | # if __has_c_attribute (__nodiscard__) | ||
| 427 | # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] | ||
| 428 | # endif | ||
| 379 | # endif | 429 | # endif |
| 380 | # endif | 430 | # endif |
| 381 | # if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result) | 431 | # if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result) |
| @@ -427,11 +477,25 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 427 | /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. | 477 | /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. |
| 428 | */ | 478 | */ |
| 429 | /* Applies to: functions. */ | 479 | /* Applies to: functions. */ |
| 480 | /* After a function's parameter list, this attribute must come first, before | ||
| 481 | other attributes. */ | ||
| 430 | #ifndef _GL_ATTRIBUTE_NOTHROW | 482 | #ifndef _GL_ATTRIBUTE_NOTHROW |
| 431 | # if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus | 483 | # if defined __cplusplus |
| 432 | # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) | 484 | # if _GL_GNUC_PREREQ (2, 8) || __clang_major >= 4 |
| 485 | # if __cplusplus >= 201103L | ||
| 486 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) | ||
| 487 | # else | ||
| 488 | # define _GL_ATTRIBUTE_NOTHROW throw () | ||
| 489 | # endif | ||
| 490 | # else | ||
| 491 | # define _GL_ATTRIBUTE_NOTHROW | ||
| 492 | # endif | ||
| 433 | # else | 493 | # else |
| 434 | # define _GL_ATTRIBUTE_NOTHROW | 494 | # if _GL_HAS_ATTRIBUTE (nothrow) |
| 495 | # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) | ||
| 496 | # else | ||
| 497 | # define _GL_ATTRIBUTE_NOTHROW | ||
| 498 | # endif | ||
| 435 | # endif | 499 | # endif |
| 436 | #endif | 500 | #endif |
| 437 | 501 | ||
| @@ -441,8 +505,10 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 441 | minimizing the memory required. */ | 505 | minimizing the memory required. */ |
| 442 | /* Applies to: struct members, struct, union, | 506 | /* Applies to: struct members, struct, union, |
| 443 | in C++ also: class. */ | 507 | in C++ also: class. */ |
| 508 | /* Oracle Studio 12.6 miscompiles code with __attribute__ ((__packed__)) despite | ||
| 509 | __has_attribute OK. */ | ||
| 444 | #ifndef _GL_ATTRIBUTE_PACKED | 510 | #ifndef _GL_ATTRIBUTE_PACKED |
| 445 | # if _GL_HAS_ATTRIBUTE (packed) | 511 | # if _GL_HAS_ATTRIBUTE (packed) && !defined __SUNPRO_C |
| 446 | # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) | 512 | # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) |
| 447 | # else | 513 | # else |
| 448 | # define _GL_ATTRIBUTE_PACKED | 514 | # define _GL_ATTRIBUTE_PACKED |
| @@ -513,6 +579,18 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 513 | # endif | 579 | # endif |
| 514 | #endif | 580 | #endif |
| 515 | ]) | 581 | ]) |
| 582 | AH_VERBATIM([c_linkage], | ||
| 583 | [/* In C++, there is the concept of "language linkage", that encompasses | ||
| 584 | name mangling and function calling conventions. | ||
| 585 | The following macros start and end a block of "C" linkage. */ | ||
| 586 | #ifdef __cplusplus | ||
| 587 | # define _GL_BEGIN_C_LINKAGE extern "C" { | ||
| 588 | # define _GL_END_C_LINKAGE } | ||
| 589 | #else | ||
| 590 | # define _GL_BEGIN_C_LINKAGE | ||
| 591 | # define _GL_END_C_LINKAGE | ||
| 592 | #endif | ||
| 593 | ]) | ||
| 516 | AH_VERBATIM([async_safe], | 594 | AH_VERBATIM([async_safe], |
| 517 | [/* The _GL_ASYNC_SAFE marker should be attached to functions that are | 595 | [/* The _GL_ASYNC_SAFE marker should be attached to functions that are |
| 518 | signal handlers (for signals other than SIGABRT, SIGPIPE) or can be | 596 | signal handlers (for signals other than SIGABRT, SIGPIPE) or can be |
| @@ -568,7 +646,7 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 568 | dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad), | 646 | dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad), |
| 569 | dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad). | 647 | dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad). |
| 570 | AC_ARG_ENABLE([cross-guesses], | 648 | AC_ARG_ENABLE([cross-guesses], |
| 571 | [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}], | 649 | [AS_HELP_STRING([[--enable-cross-guesses={conservative|risky}]], |
| 572 | [specify policy for cross-compilation guesses])], | 650 | [specify policy for cross-compilation guesses])], |
| 573 | [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then | 651 | [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then |
| 574 | AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses]) | 652 | AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses]) |
| @@ -1005,6 +1083,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], | |||
| 1005 | dnl -Wno-pedantic >= 4.8 >= 3.9 | 1083 | dnl -Wno-pedantic >= 4.8 >= 3.9 |
| 1006 | dnl -Wno-sign-compare >= 3 >= 3.9 | 1084 | dnl -Wno-sign-compare >= 3 >= 3.9 |
| 1007 | dnl -Wno-sign-conversion >= 4.3 >= 3.9 | 1085 | dnl -Wno-sign-conversion >= 4.3 >= 3.9 |
| 1086 | dnl -Wno-tautological-out-of-range-compare - >= 3.9 | ||
| 1008 | dnl -Wno-type-limits >= 4.3 >= 3.9 | 1087 | dnl -Wno-type-limits >= 4.3 >= 3.9 |
| 1009 | dnl -Wno-undef >= 3 >= 3.9 | 1088 | dnl -Wno-undef >= 3 >= 3.9 |
| 1010 | dnl -Wno-unsuffixed-float-constants >= 4.5 | 1089 | dnl -Wno-unsuffixed-float-constants >= 4.5 |
| @@ -1030,6 +1109,9 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], | |||
| 1030 | #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) | 1109 | #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) |
| 1031 | -Wno-pedantic | 1110 | -Wno-pedantic |
| 1032 | #endif | 1111 | #endif |
| 1112 | #if 3 < __clang_major__ + (9 <= __clang_minor__) | ||
| 1113 | -Wno-tautological-constant-out-of-range-compare | ||
| 1114 | #endif | ||
| 1033 | #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) | 1115 | #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) |
| 1034 | -Wno-sign-conversion | 1116 | -Wno-sign-conversion |
| 1035 | -Wno-type-limits | 1117 | -Wno-type-limits |
| @@ -1080,6 +1162,238 @@ AC_DEFUN([gl_CONDITIONAL_HEADER], | |||
| 1080 | m4_popdef([gl_header_name]) | 1162 | m4_popdef([gl_header_name]) |
| 1081 | ]) | 1163 | ]) |
| 1082 | 1164 | ||
| 1165 | dnl Preparations for gl_CHECK_FUNCS_MACOS. | ||
| 1166 | AC_DEFUN([gl_PREPARE_CHECK_FUNCS_MACOS], | ||
| 1167 | [ | ||
| 1168 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
| 1169 | AC_REQUIRE([gl_COMPILER_CLANG]) | ||
| 1170 | AC_CACHE_CHECK([for compiler option needed when checking for future declarations], | ||
| 1171 | [gl_cv_compiler_check_future_option], | ||
| 1172 | [case "$host_os" in | ||
| 1173 | dnl This is only needed on macOS. | ||
| 1174 | darwin*) | ||
| 1175 | if test $gl_cv_compiler_clang = yes; then | ||
| 1176 | dnl Test whether the compiler supports the option | ||
| 1177 | dnl '-Werror=unguarded-availability-new'. | ||
| 1178 | saved_ac_compile="$ac_compile" | ||
| 1179 | ac_compile="$ac_compile -Werror=unguarded-availability-new" | ||
| 1180 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])], | ||
| 1181 | [gl_cv_compiler_check_future_option='-Werror=unguarded-availability-new'], | ||
| 1182 | [gl_cv_compiler_check_future_option=none]) | ||
| 1183 | ac_compile="$saved_ac_compile" | ||
| 1184 | else | ||
| 1185 | gl_cv_compiler_check_future_option=none | ||
| 1186 | fi | ||
| 1187 | ;; | ||
| 1188 | *) gl_cv_compiler_check_future_option=none ;; | ||
| 1189 | esac | ||
| 1190 | ]) | ||
| 1191 | ]) | ||
| 1192 | |||
| 1193 | dnl Pieces of the expansion of | ||
| 1194 | dnl gl_CHECK_FUNCS_ANDROID | ||
| 1195 | dnl gl_CHECK_FUNCS_MACOS | ||
| 1196 | dnl gl_CHECK_FUNCS_ANDROID_MACOS | ||
| 1197 | |||
| 1198 | AC_DEFUN([gl_CHECK_FUNCS_DEFAULT_CASE], | ||
| 1199 | [ | ||
| 1200 | *) | ||
| 1201 | AC_CHECK_FUNC([$1]) | ||
| 1202 | [gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1] | ||
| 1203 | ;; | ||
| 1204 | ]) | ||
| 1205 | |||
| 1206 | AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_ANDROID], | ||
| 1207 | [ | ||
| 1208 | linux*-android*) | ||
| 1209 | AC_CHECK_DECL([$1], , , [$2]) | ||
| 1210 | if test $[ac_cv_have_decl_][$1] = yes; then | ||
| 1211 | AC_CHECK_FUNC([[$1]]) | ||
| 1212 | if test $[ac_cv_func_][$1] = yes; then | ||
| 1213 | [gl_cv_onwards_func_][$1]=yes | ||
| 1214 | else | ||
| 1215 | dnl The function is declared but does not exist. This should not | ||
| 1216 | dnl happen normally. But anyway, we know that a future version | ||
| 1217 | dnl of Android will have the function. | ||
| 1218 | [gl_cv_onwards_func_][$1]='future OS version' | ||
| 1219 | fi | ||
| 1220 | else | ||
| 1221 | [gl_cv_onwards_func_][$1]='future OS version' | ||
| 1222 | fi | ||
| 1223 | ;; | ||
| 1224 | ]) | ||
| 1225 | |||
| 1226 | AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_MACOS], | ||
| 1227 | [ | ||
| 1228 | darwin*) | ||
| 1229 | if test "x$gl_cv_compiler_check_future_option" != "xnone"; then | ||
| 1230 | dnl Use a compile test, not a link test. | ||
| 1231 | saved_ac_compile="$ac_compile" | ||
| 1232 | ac_compile="$ac_compile $gl_cv_compiler_check_future_option" | ||
| 1233 | saved_ac_compile_for_check_decl="$ac_compile_for_check_decl" | ||
| 1234 | ac_compile_for_check_decl="$ac_compile_for_check_decl $gl_cv_compiler_check_future_option" | ||
| 1235 | unset [ac_cv_have_decl_][$1] | ||
| 1236 | AC_CHECK_DECL([$1], , , [$2]) | ||
| 1237 | ac_compile="$saved_ac_compile" | ||
| 1238 | ac_compile_for_check_decl="$saved_ac_compile_for_check_decl" | ||
| 1239 | [ac_cv_func_][$1]="$[ac_cv_have_decl_][$1]" | ||
| 1240 | if test $[ac_cv_func_][$1] = yes; then | ||
| 1241 | [gl_cv_onwards_func_][$1]=yes | ||
| 1242 | else | ||
| 1243 | unset [ac_cv_have_decl_][$1] | ||
| 1244 | AC_CHECK_DECL([$1], , , [$2]) | ||
| 1245 | if test $[ac_cv_have_decl_][$1] = yes; then | ||
| 1246 | [gl_cv_onwards_func_][$1]='future OS version' | ||
| 1247 | else | ||
| 1248 | [gl_cv_onwards_func_][$1]=no | ||
| 1249 | fi | ||
| 1250 | fi | ||
| 1251 | else | ||
| 1252 | AC_CHECK_FUNC([$1]) | ||
| 1253 | [gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1] | ||
| 1254 | fi | ||
| 1255 | ;; | ||
| 1256 | ]) | ||
| 1257 | |||
| 1258 | AC_DEFUN([gl_CHECK_FUNCS_SET_RESULTS], | ||
| 1259 | [ | ||
| 1260 | case "$[gl_cv_onwards_func_][$1]" in | ||
| 1261 | future*) [ac_cv_func_][$1]=no ;; | ||
| 1262 | *) [ac_cv_func_][$1]=$[gl_cv_onwards_func_][$1] ;; | ||
| 1263 | esac | ||
| 1264 | if test $[ac_cv_func_][$1] = yes; then | ||
| 1265 | AC_DEFINE([HAVE_]m4_translit([[$1]], | ||
| 1266 | [abcdefghijklmnopqrstuvwxyz], | ||
| 1267 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ]), | ||
| 1268 | [1], [Define to 1 if you have the `$1' function.]) | ||
| 1269 | fi | ||
| 1270 | ]) | ||
| 1271 | |||
| 1272 | dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]]) | ||
| 1273 | dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem | ||
| 1274 | dnl on Android. | ||
| 1275 | dnl | ||
| 1276 | dnl When code is compiled on Android, it is in the context of a certain | ||
| 1277 | dnl "Android API level", which indicates the minimum version of Android on | ||
| 1278 | dnl which the app can be installed. In other words, you don't compile for a | ||
| 1279 | dnl specific version of Android. You compile for all versions of Android, | ||
| 1280 | dnl onwards from the given API level. | ||
| 1281 | dnl Thus, the question "does the OS have the function func" has three possible | ||
| 1282 | dnl answers: | ||
| 1283 | dnl - yes, in all versions starting from the given API level, | ||
| 1284 | dnl - no, in no version, | ||
| 1285 | dnl - not in the given API level, but in a later version of Android. | ||
| 1286 | dnl | ||
| 1287 | dnl In detail, this works as follows: | ||
| 1288 | dnl If func was added to Android API level, say, 28, then the libc.so has the | ||
| 1289 | dnl symbol func always, whereas the header file <foo.h> declares func | ||
| 1290 | dnl conditionally: | ||
| 1291 | dnl #if __ANDROID_API__ >= 28 | ||
| 1292 | dnl ... func (...) __INTRODUCED_IN(28); | ||
| 1293 | dnl #endif | ||
| 1294 | dnl Thus, when compiling with "clang -target armv7a-unknown-linux-android28", | ||
| 1295 | dnl the function func is declared and exists in libc. | ||
| 1296 | dnl Whereas when compiling with "clang -target armv7a-unknown-linux-android27", | ||
| 1297 | dnl the function func is not declared but exists in libc. | ||
| 1298 | dnl | ||
| 1299 | dnl This macro sets two variables: | ||
| 1300 | dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version" | ||
| 1301 | dnl - ac_cv_func_<func> to yes / no / no | ||
| 1302 | dnl The first variable allows to distinguish all three cases. | ||
| 1303 | dnl The second variable is set, so that an invocation | ||
| 1304 | dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]]) | ||
| 1305 | dnl can be used as a drop-in replacement for | ||
| 1306 | dnl AC_CHECK_FUNCS([func]). | ||
| 1307 | AC_DEFUN([gl_CHECK_FUNCS_ANDROID], | ||
| 1308 | [ | ||
| 1309 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
| 1310 | AC_CACHE_CHECK([for [$1]], | ||
| 1311 | [[gl_cv_onwards_func_][$1]], | ||
| 1312 | [gl_SILENT([ | ||
| 1313 | case "$host_os" in | ||
| 1314 | gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2]) | ||
| 1315 | gl_CHECK_FUNCS_DEFAULT_CASE([$1]) | ||
| 1316 | esac | ||
| 1317 | ]) | ||
| 1318 | ]) | ||
| 1319 | gl_CHECK_FUNCS_SET_RESULTS([$1]) | ||
| 1320 | ]) | ||
| 1321 | |||
| 1322 | dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]]) | ||
| 1323 | dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem | ||
| 1324 | dnl on macOS. | ||
| 1325 | dnl | ||
| 1326 | dnl When code is compiled on macOS, it is in the context of a certain minimum | ||
| 1327 | dnl macOS version, that can be set through the option '-mmacosx-version-min='. | ||
| 1328 | dnl In other words, you don't compile for a specific version of macOS. You | ||
| 1329 | dnl compile for all versions of macOS, onwards from the given version. | ||
| 1330 | dnl Thus, the question "does the OS have the function func" has three possible | ||
| 1331 | dnl answers: | ||
| 1332 | dnl - yes, in all versions starting from the given version, | ||
| 1333 | dnl - no, in no version, | ||
| 1334 | dnl - not in the given version, but in a later version of macOS. | ||
| 1335 | dnl | ||
| 1336 | dnl In detail, this works as follows: | ||
| 1337 | dnl If func was added to, say, macOS version 13, then the libc has the | ||
| 1338 | dnl symbol func always, whereas the header file <foo.h> declares func | ||
| 1339 | dnl conditionally with a special availability attribute: | ||
| 1340 | dnl ... func (...) __attribute__((availability(macos,introduced=13.0))); | ||
| 1341 | dnl Thus, when compiling with "clang mmacosx-version-min=13", there is no | ||
| 1342 | dnl warning about the use of func, and the resulting binary | ||
| 1343 | dnl - runs fine on macOS 13, | ||
| 1344 | dnl - aborts with a dyld "Symbol not found" message on macOS 12. | ||
| 1345 | dnl Whereas, when compiling with "clang mmacosx-version-min=12", there is a | ||
| 1346 | dnl warning: 'func' is only available on macOS 13.0 or newer | ||
| 1347 | dnl [-Wunguarded-availability-new], | ||
| 1348 | dnl and the resulting binary | ||
| 1349 | dnl - runs fine on macOS 13, | ||
| 1350 | dnl - crashes with a SIGSEGV (signal 11) on macOS 12. | ||
| 1351 | dnl | ||
| 1352 | dnl This macro sets two variables: | ||
| 1353 | dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version" | ||
| 1354 | dnl - ac_cv_func_<func> to yes / no / no | ||
| 1355 | dnl The first variable allows to distinguish all three cases. | ||
| 1356 | dnl The second variable is set, so that an invocation | ||
| 1357 | dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]]) | ||
| 1358 | dnl can be used as a drop-in replacement for | ||
| 1359 | dnl AC_CHECK_FUNCS([func]). | ||
| 1360 | AC_DEFUN([gl_CHECK_FUNCS_MACOS], | ||
| 1361 | [ | ||
| 1362 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
| 1363 | AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS]) | ||
| 1364 | AC_CACHE_CHECK([for [$1]], | ||
| 1365 | [[gl_cv_onwards_func_][$1]], | ||
| 1366 | [gl_SILENT([ | ||
| 1367 | case "$host_os" in | ||
| 1368 | gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2]) | ||
| 1369 | gl_CHECK_FUNCS_DEFAULT_CASE([$1]) | ||
| 1370 | esac | ||
| 1371 | ]) | ||
| 1372 | ]) | ||
| 1373 | gl_CHECK_FUNCS_SET_RESULTS([$1]) | ||
| 1374 | ]) | ||
| 1375 | |||
| 1376 | dnl gl_CHECK_FUNCS_ANDROID_MACOS([func], [[#include <foo.h>]]) | ||
| 1377 | dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem | ||
| 1378 | dnl on Android and on macOS. | ||
| 1379 | dnl It is the combination of gl_CHECK_FUNCS_ANDROID and gl_CHECK_FUNCS_MACOS. | ||
| 1380 | AC_DEFUN([gl_CHECK_FUNCS_ANDROID_MACOS], | ||
| 1381 | [ | ||
| 1382 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
| 1383 | AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS]) | ||
| 1384 | AC_CACHE_CHECK([for [$1]], | ||
| 1385 | [[gl_cv_onwards_func_][$1]], | ||
| 1386 | [gl_SILENT([ | ||
| 1387 | case "$host_os" in | ||
| 1388 | gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2]) | ||
| 1389 | gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2]) | ||
| 1390 | gl_CHECK_FUNCS_DEFAULT_CASE([$1]) | ||
| 1391 | esac | ||
| 1392 | ]) | ||
| 1393 | ]) | ||
| 1394 | gl_CHECK_FUNCS_SET_RESULTS([$1]) | ||
| 1395 | ]) | ||
| 1396 | |||
| 1083 | dnl Expands to some code for use in .c programs that, on native Windows, defines | 1397 | dnl Expands to some code for use in .c programs that, on native Windows, defines |
| 1084 | dnl the Microsoft deprecated alias function names to the underscore-prefixed | 1398 | dnl the Microsoft deprecated alias function names to the underscore-prefixed |
| 1085 | dnl actual function names. With this macro, these function names are available | 1399 | dnl actual function names. With this macro, these function names are available |
