summaryrefslogtreecommitdiffstats
path: root/gl/m4/gnulib-common.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/gnulib-common.m4')
-rw-r--r--gl/m4/gnulib-common.m4117
1 files changed, 70 insertions, 47 deletions
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 034dae69..26eef771 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,6 +1,6 @@
1# gnulib-common.m4 1# gnulib-common.m4
2# serial 113 2# serial 115
3dnl Copyright (C) 2007-2025 Free Software Foundation, Inc. 3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -168,7 +168,7 @@ AC_DEFUN([gl_COMMON_BODY], [
168 ====================================================================== 168 ======================================================================
169 This gives a syntax error 169 This gives a syntax error
170 - in C mode with gcc 170 - in C mode with gcc
171 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796>, and 171 <https://gcc.gnu.org/PR108796>, and
172 - in C++ mode with clang++ version < 16, and 172 - in C++ mode with clang++ version < 16, and
173 - in C++ mode, inside extern "C" {}, still in newer clang++ versions 173 - in C++ mode, inside extern "C" {}, still in newer clang++ versions
174 <https://github.com/llvm/llvm-project/issues/101990>. 174 <https://github.com/llvm/llvm-project/issues/101990>.
@@ -414,22 +414,25 @@ AC_DEFUN([gl_COMMON_BODY], [
414#endif 414#endif
415 415
416/* _GL_ATTRIBUTE_CONST declares: 416/* _GL_ATTRIBUTE_CONST declares:
417 It is OK for a compiler to move calls to the function and to omit 417 It is OK for a compiler to move a call, or omit a duplicate call
418 calls to the function if another call has the same arguments or the 418 and reuse a cached return value, even if the state changes between calls.
419 result is not used. 419 It is also OK to omit a call if the result is not used.
420 This attribute is safe for a function that neither depends on 420 This attribute is safe if the function does not change observable state,
421 nor affects state, and always returns exactly once - 421 returns a value determined solely by its arguments' values
422 without examining state, and always returns exactly once -
422 e.g., does not raise an exception, call longjmp, or loop forever. 423 e.g., does not raise an exception, call longjmp, or loop forever.
423 (This attribute is stricter than _GL_ATTRIBUTE_PURE because the 424 (This attribute is stricter than _GL_ATTRIBUTE_PURE because the
424 function cannot observe state. It is stricter than 425 function cannot observe state. Unlike _GL_ATTRIBUTE_UNSEQUENCED
425 _GL_ATTRIBUTE_UNSEQUENCED because the function must return exactly 426 the function must return exactly once and cannot access state
426 once and cannot depend on state addressed by its arguments.) */ 427 addressed by its pointer arguments or that happens to have the same
428 value for all calls to the function, but the function is allowed to
429 return a pointer to storage that can be modified later. */
427/* Applies to: functions. */ 430/* Applies to: functions. */
428#ifndef _GL_ATTRIBUTE_CONST 431#ifndef _GL_ATTRIBUTE_CONST
429# if _GL_HAS_ATTRIBUTE (const) 432# if _GL_HAS_ATTRIBUTE (const)
430# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) 433# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
431# else 434# else
432# define _GL_ATTRIBUTE_CONST _GL_ATTRIBUTE_UNSEQUENCED 435# define _GL_ATTRIBUTE_CONST
433# endif 436# endif
434#endif 437#endif
435 438
@@ -451,7 +454,7 @@ AC_DEFUN([gl_COMMON_BODY], [
451 yet. */ 454 yet. */
452#ifndef _GL_ATTRIBUTE_DEALLOC_FREE 455#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
453# if defined __cplusplus && defined __GNUC__ && !defined __clang__ 456# if defined __cplusplus && defined __GNUC__ && !defined __clang__
454/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */ 457/* Work around GCC bug <https://gcc.gnu.org/PR108231> */
455# define _GL_ATTRIBUTE_DEALLOC_FREE \ 458# define _GL_ATTRIBUTE_DEALLOC_FREE \
456 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) 459 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
457# else 460# else
@@ -590,7 +593,9 @@ AC_DEFUN([gl_COMMON_BODY], [
590 593
591/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if 594/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
592 the entity is not used. The compiler should not warn if the entity is not 595 the entity is not used. The compiler should not warn if the entity is not
593 used. */ 596 used. However, 'int _GL_UNNAMED (i)' is preferable to
597 '_GL_ATTRIBUTE_MAYBE_UNUSED int i' when parameter I is unused
598 regardless of preprocessor macro settings. */
594/* Applies to: 599/* Applies to:
595 - function, variable, 600 - function, variable,
596 - struct, union, struct/union member, 601 - struct, union, struct/union member,
@@ -744,39 +749,40 @@ AC_DEFUN([gl_COMMON_BODY], [
744#endif 749#endif
745 750
746/* _GL_ATTRIBUTE_PURE declares: 751/* _GL_ATTRIBUTE_PURE declares:
747 It is OK for a compiler to move calls to the function and to omit 752 It is OK for a compiler to move a call, or omit a duplicate call
748 calls to the function if another call has the same arguments or the 753 and reuse a cached return value, if observable state is the same.
749 result is not used, and if observable state is the same. 754 It is also OK to omit a call if the return value is not used.
750 This attribute is safe for a function that does not affect observable state 755 This attribute is safe if the function does not change observable state,
751 and always returns exactly once. 756 returns a value determined solely by its arguments's values
757 together with observable state, and always returns exactly once.
752 (This attribute is looser than _GL_ATTRIBUTE_CONST because the function 758 (This attribute is looser than _GL_ATTRIBUTE_CONST because the function
753 can depend on observable state. It is stricter than 759 can depend on observable state.
754 _GL_ATTRIBUTE_REPRODUCIBLE because the function must return exactly 760 Unlike _GL_ATTRIBUTE_REPRODUCIBLE the function must return exactly
755 once and cannot affect state addressed by its arguments.) */ 761 once and cannot change state addressed by its arguments, but the
762 function can return a pointer to storage whose contents change later.) */
756/* Applies to: functions. */ 763/* Applies to: functions. */
757#ifndef _GL_ATTRIBUTE_PURE 764#ifndef _GL_ATTRIBUTE_PURE
758# if _GL_HAS_ATTRIBUTE (pure) 765# if _GL_HAS_ATTRIBUTE (pure)
759# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 766# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
760# else 767# else
761# define _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_REPRODUCIBLE 768# define _GL_ATTRIBUTE_PURE
762# endif 769# endif
763#endif 770#endif
764 771
765/* _GL_ATTRIBUTE_REPRODUCIBLE declares: 772/* _GL_ATTRIBUTE_REPRODUCIBLE declares:
766 It is OK for a compiler to move calls to the function and to omit duplicate 773 It is OK for a compiler to move a call, or omit a duplicate call
767 calls to the function with the same arguments, so long as the state 774 and reuse a cached value returned either directly or indirectly via
768 addressed by its arguments is the same and is updated in time for 775 a pointer, if other observable state is the same;
769 the rest of the program. 776 however, pointer arguments cannot alias.
770 This attribute is safe for a function that is effectless and idempotent; see 777 This attribute is safe for a function that is effectless and idempotent;
771 ISO C 23 § 6.7.12.7 for a definition of these terms. 778 see ISO C 23 § 6.7.13.8 for a definition of these terms.
772 (This attribute is looser than _GL_ATTRIBUTE_UNSEQUENCED because 779 (This attribute is looser than _GL_ATTRIBUTE_UNSEQUENCED because
773 the function need not be stateless and idempotent. It is looser 780 the function need not be stateless or independent.
774 than _GL_ATTRIBUTE_PURE because the function need not return 781 Unlike _GL_ATTRIBUTE_PURE the function need not return exactly once
775 exactly once and can affect state addressed by its arguments.) 782 and can change state addressed by its pointer arguments, but the
783 function cannot return a pointer to storage whose contents change later.)
776 See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and 784 See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
777 <https://stackoverflow.com/questions/76847905/>. 785 <https://stackoverflow.com/questions/76847905/>. */
778 ATTENTION! Efforts are underway to change the meaning of this attribute.
779 See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3424.htm>. */
780/* Applies to: functions, pointer to functions, function types. */ 786/* Applies to: functions, pointer to functions, function types. */
781#ifndef _GL_ATTRIBUTE_REPRODUCIBLE 787#ifndef _GL_ATTRIBUTE_REPRODUCIBLE
782/* This may be revisited when gcc and clang support [[reproducible]] or possibly 788/* This may be revisited when gcc and clang support [[reproducible]] or possibly
@@ -816,20 +822,22 @@ AC_DEFUN([gl_COMMON_BODY], [
816#endif 822#endif
817 823
818/* _GL_ATTRIBUTE_UNSEQUENCED declares: 824/* _GL_ATTRIBUTE_UNSEQUENCED declares:
819 It is OK for a compiler to move calls to the function and to omit duplicate 825 It is OK for a compiler to move a call, or omit a duplicate call
820 calls to the function with the same arguments, so long as the state 826 and reuse a cached value returned either directly or indirectly via
821 addressed by its arguments is the same. 827 a pointer, if the state addressed by its pointer arguments is the same;
828 however, pointer arguments cannot alias.
822 This attribute is safe for a function that is effectless, idempotent, 829 This attribute is safe for a function that is effectless, idempotent,
823 stateless, and independent; see ISO C 23 § 6.7.12.7 for a definition of 830 stateless, and independent; see ISO C 23 § 6.7.13.8 for a definition of
824 these terms. 831 these terms.
825 (This attribute is stricter than _GL_ATTRIBUTE_REPRODUCIBLE because 832 (This attribute is stricter than _GL_ATTRIBUTE_REPRODUCIBLE because
826 the function must be stateless and independent. It is looser than 833 the function must be stateless and independent. Unlike
827 _GL_ATTRIBUTE_CONST because the function need not return exactly 834 _GL_ATTRIBUTE_CONST the function need not return exactly once, and
828 once and can depend on state addressed by its arguments.) 835 can depend on state accessed via its pointer arguments or that
836 happens to have the same value for all calls to the function, but
837 the function cannot return a pointer to storage whose contents
838 change later.)
829 See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and 839 See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
830 <https://stackoverflow.com/questions/76847905/>. 840 <https://stackoverflow.com/questions/76847905/>. */
831 ATTENTION! Efforts are underway to change the meaning of this attribute.
832 See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3424.htm>. */
833/* Applies to: functions, pointer to functions, function types. */ 841/* Applies to: functions, pointer to functions, function types. */
834#ifndef _GL_ATTRIBUTE_UNSEQUENCED 842#ifndef _GL_ATTRIBUTE_UNSEQUENCED
835/* This may be revisited when gcc and clang support [[unsequenced]] or possibly 843/* This may be revisited when gcc and clang support [[unsequenced]] or possibly
@@ -869,6 +877,21 @@ AC_DEFUN([gl_COMMON_BODY], [
869# endif 877# endif
870#endif 878#endif
871 879
880/* _GL_UNNAMED (ID) is the "name" of an unnamed function parameter.
881 Each of the function's unnamed parameters should have a unique "name".
882 The "name" cannot be used. This ports both to C17 and earlier, which
883 lack unnamed parameters, and to C++ and later C, which have them. */
884/* Applies to:
885 - function parameters. */
886#ifndef _GL_UNNAMED
887# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311 \
888 && !defined __cplusplus)
889# define _GL_UNNAMED(id) unnamed_##id _GL_ATTRIBUTE_UNUSED
890# else
891# define _GL_UNNAMED(id)
892# endif
893#endif
894
872/* The following attributes enable detection of multithread-safety problems 895/* The following attributes enable detection of multithread-safety problems
873 and resource leaks at compile-time, by clang ≥ 15, when the warning option 896 and resource leaks at compile-time, by clang ≥ 15, when the warning option
874 -Wthread-safety is enabled. For usage, see 897 -Wthread-safety is enabled. For usage, see
@@ -1406,7 +1429,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
1406 dnl -Wno-type-limits >= 4.3 >= 3.9 1429 dnl -Wno-type-limits >= 4.3 >= 3.9
1407 dnl -Wno-undef >= 3 >= 3.9 1430 dnl -Wno-undef >= 3 >= 3.9
1408 dnl -Wno-unsuffixed-float-constants >= 4.5 1431 dnl -Wno-unsuffixed-float-constants >= 4.5
1409 dnl -Wno-unused-const-variable >= 4.4 >= 3.9 1432 dnl -Wno-unused-const-variable >= 6.1 >= 3.9
1410 dnl -Wno-unused-function >= 3 >= 3.9 1433 dnl -Wno-unused-function >= 3 >= 3.9
1411 dnl -Wno-unused-parameter >= 3 >= 3.9 1434 dnl -Wno-unused-parameter >= 3 >= 3.9
1412 dnl 1435 dnl
@@ -1436,7 +1459,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
1436 -Wno-sign-conversion 1459 -Wno-sign-conversion
1437 -Wno-type-limits 1460 -Wno-type-limits
1438 #endif 1461 #endif
1439 #if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) 1462 #if (__GNUC__ + (__GNUC_MINOR__ >= 1) > 6 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1440 -Wno-unused-const-variable 1463 -Wno-unused-const-variable
1441 #endif 1464 #endif
1442 #if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__) 1465 #if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__)