> and they both define c32isalnum. The fact that both definitions are identical > is irrelevant; it's an error nonetheless.
The same problem (an inline function definition that may occur in several generated .h files of the same name but with different @GUARD_PREFIX@) occurs also in a couple of other .h files. Fixed through the following patches. 2026-04-28 Bruno Haible <[email protected]> error-h: Support multiple gnulib-tool invocations in the same package. * lib/error.in.h (GNULIB_defined_error, GNULIB_defined_error_at_line): New macros. (verror): Test GNULIB_defined_verror, for consistency with the idiom. (verror_at_line): Test GNULIB_defined_verror_at_line, for consistency with the idiom. 2026-04-28 Bruno Haible <[email protected]> realloc-posix: Support multiple gnulib-tool invocations in a package. * lib/stdlib.in.h (rpl_realloc): Don't define if _GL_INLINE_RPL_REALLOC is already defined. 2026-04-28 Bruno Haible <[email protected]> string-h: Support multiple gnulib-tool invocations in the same package. * lib/string.in.h (GNULIB_defined_memeq, GNULIB_defined_streq, GNULIB_defined_strnul): New macros. 2026-04-28 Bruno Haible <[email protected]> stdbit-h: Support multiple gnulib-tool invocations in the same package. * lib/stdbit.in.h (GNULIB_defined_clz_functions, GNULIB_defined_stdc_leading_zeros_functions, GNULIB_defined_stdc_leading_ones_functions, GNULIB_defined_ctz_functions, GNULIB_defined_stdc_trailing_zeros_functions, GNULIB_defined_stdc_trailing_ones_functions, GNULIB_defined_stdc_first_leading_zero_functions, GNULIB_defined_stdc_first_leading_one_functions, GNULIB_defined_stdc_first_trailing_zero_functions, GNULIB_defined_stdc_first_trailing_one_functions, GNULIB_defined_popcount_functions, GNULIB_defined_stdc_count_ones_functions, GNULIB_defined_stdc_count_zeros_functions, GNULIB_defined_stdc_has_single_bit_functions, GNULIB_defined_stdc_bit_width_functions, GNULIB_defined_stdc_bit_floor_functions, GNULIB_defined_stdc_bit_ceil_functions, GNULIB_defined_stdc_rotate_left_functions, GNULIB_defined_stdc_rotate_right_functions, GNULIB_defined_stdc_memreverse8, GNULIB_defined_stdc_memreverse8u_functions, GNULIB_defined_stdc_load8_functions, GNULIB_defined_stdc_load8_aligned_functions, GNULIB_defined_stdc_store8_functions, GNULIB_defined_stdc_store8_aligned_functions): New macros. 2026-04-28 Bruno Haible <[email protected]> endian: Support multiple gnulib-tool invocations in the same package. * lib/endian.in.h (GNULIB_defined_be16toh, GNULIB_defined_be32toh, GNULIB_defined_be64toh, GNULIB_defined_htobe16, GNULIB_defined_htobe32, GNULIB_defined_htobe64, GNULIB_defined_le16toh, GNULIB_defined_le32toh, GNULIB_defined_le64toh, GNULIB_defined_htole16, GNULIB_defined_htole32, GNULIB_defined_htole64): New macros. 2026-04-28 Bruno Haible <[email protected]> arpa_inet-h: Support multiple gnulib-tool invocations in a package. * lib/arpa_inet.in.h (GNULIB_defined_htons, GNULIB_defined_htonl, GNULIB_defined_ntohs, GNULIB_defined_ntohl): New macros.
>From 4429f402179010e9771404121d8c55a762cfc250 Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Wed, 29 Apr 2026 01:37:37 +0200 Subject: [PATCH 1/6] arpa_inet-h: Support multiple gnulib-tool invocations in a package. * lib/arpa_inet.in.h (GNULIB_defined_htons, GNULIB_defined_htonl, GNULIB_defined_ntohs, GNULIB_defined_ntohl): New macros. --- ChangeLog | 6 ++++++ lib/arpa_inet.in.h | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7cc44b145e..05d8f4e9f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2026-04-28 Bruno Haible <[email protected]> + + arpa_inet-h: Support multiple gnulib-tool invocations in a package. + * lib/arpa_inet.in.h (GNULIB_defined_htons, GNULIB_defined_htonl, + GNULIB_defined_ntohs, GNULIB_defined_ntohl): New macros. + 2026-04-28 Bruno Haible <[email protected]> stdbit-h: Fix syntax error in C++ mode. diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h index a9c93d079b..a3946a48da 100644 --- a/lib/arpa_inet.in.h +++ b/lib/arpa_inet.in.h @@ -73,37 +73,49 @@ _GL_INLINE_HEADER_BEGIN /* Host to network byte order. */ #if !@HAVE_DECL_HTONS@ +# if !GNULIB_defined_htons _GL_ARPA_INET_INLINE uint16_t htons (uint16_t value) { return htobe16 (value); } +# define GNULIB_defined_htons 1 +# endif #endif #if !@HAVE_DECL_HTONL@ +# if !GNULIB_defined_htonl _GL_ARPA_INET_INLINE uint32_t htonl (uint32_t value) { return htobe32 (value); } +# define GNULIB_defined_htonl 1 +# endif #endif /* Network to host byte order. */ #if !@HAVE_DECL_NTOHS@ +# if !GNULIB_defined_ntohs _GL_ARPA_INET_INLINE uint16_t ntohs (uint16_t value) { return htobe16 (value); } +# define GNULIB_defined_ntohs 1 +# endif #endif #if !@HAVE_DECL_NTOHL@ +# if !GNULIB_defined_ntohl _GL_ARPA_INET_INLINE uint32_t ntohl (uint32_t value) { return htobe32 (value); } +# define GNULIB_defined_ntohl 1 +# endif #endif -- 2.52.0
>From f9beefd5d4f745d27605ed9ec6afc153a1dae3bd Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Wed, 29 Apr 2026 01:40:18 +0200 Subject: [PATCH 2/6] endian: Support multiple gnulib-tool invocations in the same package. * lib/endian.in.h (GNULIB_defined_be16toh, GNULIB_defined_be32toh, GNULIB_defined_be64toh, GNULIB_defined_htobe16, GNULIB_defined_htobe32, GNULIB_defined_htobe64, GNULIB_defined_le16toh, GNULIB_defined_le32toh, GNULIB_defined_le64toh, GNULIB_defined_htole16, GNULIB_defined_htole32, GNULIB_defined_htole64): New macros. --- ChangeLog | 9 ++++ lib/endian.in.h | 108 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 81 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05d8f4e9f6..7ec80a5f3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2026-04-28 Bruno Haible <[email protected]> + + endian: Support multiple gnulib-tool invocations in the same package. + * lib/endian.in.h (GNULIB_defined_be16toh, GNULIB_defined_be32toh, + GNULIB_defined_be64toh, GNULIB_defined_htobe16, GNULIB_defined_htobe32, + GNULIB_defined_htobe64, GNULIB_defined_le16toh, GNULIB_defined_le32toh, + GNULIB_defined_le64toh, GNULIB_defined_htole16, GNULIB_defined_htole32, + GNULIB_defined_htole64): New macros. + 2026-04-28 Bruno Haible <[email protected]> arpa_inet-h: Support multiple gnulib-tool invocations in a package. diff --git a/lib/endian.in.h b/lib/endian.in.h index 5eb603a120..6fa0678f93 100644 --- a/lib/endian.in.h +++ b/lib/endian.in.h @@ -120,138 +120,174 @@ _GL_BYTESWAP_INLINE uint_least64_t bswap_64 (uint_least64_t); /* Big endian to host. */ +#if !GNULIB_defined_be16toh _GL_ENDIAN_INLINE uint16_t be16toh (uint16_t x) { -#if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return x; -#else +# else return bswap_16 (x); -#endif +# endif } +# define GNULIB_defined_be16toh 1 +#endif +#if !GNULIB_defined_be32toh _GL_ENDIAN_INLINE uint32_t be32toh (uint32_t x) { -#if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return x; -#else +# else return bswap_32 (x); -#endif +# endif } +# define GNULIB_defined_be32toh 1 +#endif #ifdef UINT64_MAX +# if !GNULIB_defined_be64toh _GL_ENDIAN_INLINE uint64_t be64toh (uint64_t x) { -# if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return x; -# else +# else return bswap_64 (x); -# endif +# endif } +# define GNULIB_defined_be64toh 1 +# endif #endif /* Host to big endian. */ +#if !GNULIB_defined_htobe16 _GL_ENDIAN_INLINE uint16_t htobe16 (uint16_t x) { -#if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return x; -#else +# else return bswap_16 (x); -#endif +# endif } +# define GNULIB_defined_htobe16 1 +#endif +#if !GNULIB_defined_htobe32 _GL_ENDIAN_INLINE uint32_t htobe32 (uint32_t x) { -#if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return x; -#else +# else return bswap_32 (x); -#endif +# endif } +# define GNULIB_defined_htobe32 1 +#endif #ifdef UINT64_MAX +# if !GNULIB_defined_htobe64 _GL_ENDIAN_INLINE uint64_t htobe64 (uint64_t x) { -# if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return x; -# else +# else return bswap_64 (x); -# endif +# endif } +# define GNULIB_defined_htobe64 1 +# endif #endif /* Little endian to host. */ +#if !GNULIB_defined_le16toh _GL_ENDIAN_INLINE uint16_t le16toh (uint16_t x) { -#if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return bswap_16 (x); -#else +# else return x; -#endif +# endif } +# define GNULIB_defined_le16toh 1 +#endif +#if !GNULIB_defined_le32toh _GL_ENDIAN_INLINE uint32_t le32toh (uint32_t x) { -#if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return bswap_32 (x); -#else +# else return x; -#endif +# endif } +# define GNULIB_defined_le32toh 1 +#endif #ifdef UINT64_MAX +# if !GNULIB_defined_le64toh _GL_ENDIAN_INLINE uint64_t le64toh (uint64_t x) { -# if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return bswap_64 (x); -# else +# else return x; -# endif +# endif } +# define GNULIB_defined_le64toh 1 +# endif #endif /* Host to little endian. */ +#if !GNULIB_defined_htole16 _GL_ENDIAN_INLINE uint16_t htole16 (uint16_t x) { -#if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return bswap_16 (x); -#else +# else return x; -#endif +# endif } +# define GNULIB_defined_htole16 1 +#endif +#if !GNULIB_defined_htole32 _GL_ENDIAN_INLINE uint32_t htole32 (uint32_t x) { -#if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return bswap_32 (x); -#else +# else return x; -#endif +# endif } +# define GNULIB_defined_htole32 1 +#endif #ifdef UINT64_MAX +# if !GNULIB_defined_htole64 _GL_ENDIAN_INLINE uint64_t htole64 (uint64_t x) { -# if BYTE_ORDER == BIG_ENDIAN +# if BYTE_ORDER == BIG_ENDIAN return bswap_64 (x); -# else +# else return x; -# endif +# endif } +# define GNULIB_defined_htole64 1 +# endif #endif #ifdef __cplusplus -- 2.52.0
>From 445ecf4860164e5ce36050d66f3b4308a7c73c0c Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Wed, 29 Apr 2026 01:46:06 +0200 Subject: [PATCH 3/6] stdbit-h: Support multiple gnulib-tool invocations in the same package. * lib/stdbit.in.h (GNULIB_defined_clz_functions, GNULIB_defined_stdc_leading_zeros_functions, GNULIB_defined_stdc_leading_ones_functions, GNULIB_defined_ctz_functions, GNULIB_defined_stdc_trailing_zeros_functions, GNULIB_defined_stdc_trailing_ones_functions, GNULIB_defined_stdc_first_leading_zero_functions, GNULIB_defined_stdc_first_leading_one_functions, GNULIB_defined_stdc_first_trailing_zero_functions, GNULIB_defined_stdc_first_trailing_one_functions, GNULIB_defined_popcount_functions, GNULIB_defined_stdc_count_ones_functions, GNULIB_defined_stdc_count_zeros_functions, GNULIB_defined_stdc_has_single_bit_functions, GNULIB_defined_stdc_bit_width_functions, GNULIB_defined_stdc_bit_floor_functions, GNULIB_defined_stdc_bit_ceil_functions, GNULIB_defined_stdc_rotate_left_functions, GNULIB_defined_stdc_rotate_right_functions, GNULIB_defined_stdc_memreverse8, GNULIB_defined_stdc_memreverse8u_functions, GNULIB_defined_stdc_load8_functions, GNULIB_defined_stdc_load8_aligned_functions, GNULIB_defined_stdc_store8_functions, GNULIB_defined_stdc_store8_aligned_functions): New macros. --- ChangeLog | 29 +++++++ lib/stdbit.in.h | 215 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 197 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ec80a5f3c..c0ea7c1dde 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2026-04-28 Bruno Haible <[email protected]> + + stdbit-h: Support multiple gnulib-tool invocations in the same package. + * lib/stdbit.in.h (GNULIB_defined_clz_functions, + GNULIB_defined_stdc_leading_zeros_functions, + GNULIB_defined_stdc_leading_ones_functions, + GNULIB_defined_ctz_functions, + GNULIB_defined_stdc_trailing_zeros_functions, + GNULIB_defined_stdc_trailing_ones_functions, + GNULIB_defined_stdc_first_leading_zero_functions, + GNULIB_defined_stdc_first_leading_one_functions, + GNULIB_defined_stdc_first_trailing_zero_functions, + GNULIB_defined_stdc_first_trailing_one_functions, + GNULIB_defined_popcount_functions, + GNULIB_defined_stdc_count_ones_functions, + GNULIB_defined_stdc_count_zeros_functions, + GNULIB_defined_stdc_has_single_bit_functions, + GNULIB_defined_stdc_bit_width_functions, + GNULIB_defined_stdc_bit_floor_functions, + GNULIB_defined_stdc_bit_ceil_functions, + GNULIB_defined_stdc_rotate_left_functions, + GNULIB_defined_stdc_rotate_right_functions, + GNULIB_defined_stdc_memreverse8, + GNULIB_defined_stdc_memreverse8u_functions, + GNULIB_defined_stdc_load8_functions, + GNULIB_defined_stdc_load8_aligned_functions, + GNULIB_defined_stdc_store8_functions, + GNULIB_defined_stdc_store8_aligned_functions): New macros. + 2026-04-28 Bruno Haible <[email protected]> endian: Support multiple gnulib-tool invocations in the same package. diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h index 33758c31a4..d6fb854a57 100644 --- a/lib/stdbit.in.h +++ b/lib/stdbit.in.h @@ -233,7 +233,8 @@ extern "C" { # endif /* Count leading 0 bits of N, even if N is 0. */ -# ifdef _GL_STDBIT_HAS_BUILTIN_CLZ +# if !GNULIB_defined_clz_functions +# ifdef _GL_STDBIT_HAS_BUILTIN_CLZ _GL_STDC_LEADING_ZEROS_INLINE int _gl_stdbit_clz (unsigned int n) { @@ -249,16 +250,16 @@ _gl_stdbit_clzll (unsigned long long int n) { return n ? __builtin_clzll (n) : 8 * sizeof n; } -# elif defined _MSC_VER +# elif defined _MSC_VER /* Declare the few MSVC intrinsics that we need. We prefer not to include <intrin.h> because it would pollute the namespace. */ extern unsigned char _BitScanReverse (unsigned long *, unsigned long); -# pragma intrinsic (_BitScanReverse) -# ifdef _M_X64 +# pragma intrinsic (_BitScanReverse) +# ifdef _M_X64 extern unsigned char _BitScanReverse64 (unsigned long *, unsigned long long); -# pragma intrinsic (_BitScanReverse64) -# endif +# pragma intrinsic (_BitScanReverse64) +# endif _GL_STDC_LEADING_ZEROS_INLINE int _gl_stdbit_clzl (unsigned long int n) @@ -274,16 +275,16 @@ _gl_stdbit_clz (unsigned int n) _GL_STDC_LEADING_ZEROS_INLINE int _gl_stdbit_clzll (unsigned long long int n) { -# ifdef _M_X64 +# ifdef _M_X64 unsigned long int r; return 8 * sizeof n - (_BitScanReverse64 (&r, n) ? r + 1 : 0); -# else +# else unsigned long int hi = n >> 32; return _gl_stdbit_clzl (hi ? hi : n) + (hi ? 0 : 32); -# endif +# endif } -# else /* !_MSC_VER */ +# else /* !_MSC_VER */ _GL_STDC_LEADING_ZEROS_INLINE int _gl_stdbit_clzll (unsigned long long int n) @@ -309,8 +310,13 @@ _gl_stdbit_clzl (unsigned long int n) { return _gl_stdbit_clzll (n) - 8 * (sizeof 0ull - sizeof 0ul); } +# endif + +# define GNULIB_defined_clz_functions 1 # endif +# if !GNULIB_defined_stdc_leading_zeros_functions + _GL_STDC_LEADING_ZEROS_INLINE unsigned int stdc_leading_zeros_ui (unsigned int n) { @@ -341,6 +347,9 @@ stdc_leading_zeros_ull (unsigned long long int n) return _gl_stdbit_clzll (n); } +# define GNULIB_defined_stdc_leading_zeros_functions 1 +# endif + # define stdc_leading_zeros(n) \ (sizeof (n) == 1 ? stdc_leading_zeros_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_leading_zeros_us (n) \ @@ -355,6 +364,8 @@ stdc_leading_zeros_ull (unsigned long long int n) #if @GNULIB_STDC_LEADING_ONES@ +# if !GNULIB_defined_stdc_leading_ones_functions + _GL_STDC_LEADING_ONES_INLINE unsigned int stdc_leading_ones_uc (unsigned char n) { @@ -385,6 +396,9 @@ stdc_leading_ones_ull (unsigned long long int n) return stdc_leading_zeros_ull (~n); } +# define GNULIB_defined_stdc_leading_ones_functions 1 +# endif + # define stdc_leading_ones(n) \ (sizeof (n) == 1 ? stdc_leading_ones_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_leading_ones_us (n) \ @@ -410,7 +424,8 @@ stdc_leading_ones_ull (unsigned long long int n) # endif /* Count trailing 0 bits of N, even if N is 0. */ -# ifdef _GL_STDBIT_HAS_BUILTIN_CTZ +# if !GNULIB_defined_ctz_functions +# ifdef _GL_STDBIT_HAS_BUILTIN_CTZ _GL_STDC_TRAILING_ZEROS_INLINE int _gl_stdbit_ctz (unsigned int n) { @@ -426,16 +441,16 @@ _gl_stdbit_ctzll (unsigned long long int n) { return n ? __builtin_ctzll (n) : 8 * sizeof n; } -# elif defined _MSC_VER +# elif defined _MSC_VER /* Declare the few MSVC intrinsics that we need. We prefer not to include <intrin.h> because it would pollute the namespace. */ extern unsigned char _BitScanForward (unsigned long *, unsigned long); -# pragma intrinsic (_BitScanForward) -# ifdef _M_X64 +# pragma intrinsic (_BitScanForward) +# ifdef _M_X64 extern unsigned char _BitScanForward64 (unsigned long *, unsigned long long); -# pragma intrinsic (_BitScanForward64) -# endif +# pragma intrinsic (_BitScanForward64) +# endif _GL_STDC_TRAILING_ZEROS_INLINE int _gl_stdbit_ctzl (unsigned long int n) @@ -451,16 +466,16 @@ _gl_stdbit_ctz (unsigned int n) _GL_STDC_TRAILING_ZEROS_INLINE int _gl_stdbit_ctzll (unsigned long long int n) { -# ifdef _M_X64 +# ifdef _M_X64 unsigned long int r; return _BitScanForward64 (&r, n) ? r : 8 * sizeof n; -# else +# else unsigned int lo = n; return _gl_stdbit_ctzl (lo ? lo : n >> 32) + (lo ? 0 : 32); -# endif +# endif } -# else /* !_MSC_VER */ +# else /* !_MSC_VER */ _GL_STDC_TRAILING_ZEROS_INLINE int _gl_stdbit_ctz (unsigned int n) @@ -477,8 +492,13 @@ _gl_stdbit_ctzll (unsigned long long int n) { return 8 * sizeof n - (n ? _gl_stdbit_clzll (n & -n) + 1 : 0); } +# endif + +# define GNULIB_defined_ctz_functions 1 # endif +# if !GNULIB_defined_stdc_trailing_zeros_functions + _GL_STDC_TRAILING_ZEROS_INLINE unsigned int stdc_trailing_zeros_ui (unsigned int n) { @@ -509,6 +529,9 @@ stdc_trailing_zeros_ull (unsigned long long int n) return _gl_stdbit_ctzll (n); } +# define GNULIB_defined_stdc_trailing_zeros_functions 1 +# endif + # define stdc_trailing_zeros(n) \ (sizeof (n) == 1 ? stdc_trailing_zeros_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_trailing_zeros_us (n) \ @@ -523,6 +546,8 @@ stdc_trailing_zeros_ull (unsigned long long int n) #if @GNULIB_STDC_TRAILING_ONES@ +# if !GNULIB_defined_stdc_trailing_ones_functions + _GL_STDC_TRAILING_ONES_INLINE unsigned int stdc_trailing_ones_uc (unsigned char n) { @@ -553,6 +578,9 @@ stdc_trailing_ones_ull (unsigned long long int n) return stdc_trailing_zeros_ull (~n); } +# define GNULIB_defined_stdc_trailing_ones_functions 1 +# endif + # define stdc_trailing_ones(n) \ (sizeof (n) == 1 ? stdc_trailing_ones_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_trailing_ones_us (n) \ @@ -567,6 +595,8 @@ stdc_trailing_ones_ull (unsigned long long int n) #if @GNULIB_STDC_FIRST_LEADING_ZERO@ +# if !GNULIB_defined_stdc_first_leading_zero_functions + _GL_STDC_FIRST_LEADING_ZERO_INLINE unsigned int stdc_first_leading_zero_uc (unsigned char n) { @@ -607,6 +637,9 @@ stdc_first_leading_zero_ull (unsigned long long int n) return count % bits + (count < bits); } +# define GNULIB_defined_stdc_first_leading_zero_functions 1 +# endif + # define stdc_first_leading_zero(n) \ (sizeof (n) == 1 ? stdc_first_leading_zero_uc (n) \ : sizeof (n) == sizeof (unsigned short) ? stdc_first_leading_zero_us (n) \ @@ -621,6 +654,8 @@ stdc_first_leading_zero_ull (unsigned long long int n) #if @GNULIB_STDC_FIRST_LEADING_ONE@ +# if !GNULIB_defined_stdc_first_leading_one_functions + _GL_STDC_FIRST_LEADING_ONE_INLINE unsigned int stdc_first_leading_one_uc (unsigned char n) { @@ -661,6 +696,9 @@ stdc_first_leading_one_ull (unsigned long long int n) return count % bits + (count < bits); } +# define GNULIB_defined_stdc_first_leading_one_functions 1 +# endif + # define stdc_first_leading_one(n) \ (sizeof (n) == 1 ? stdc_first_leading_one_uc (n) \ : sizeof (n) == sizeof (unsigned short) ? stdc_first_leading_one_us (n) \ @@ -675,6 +713,8 @@ stdc_first_leading_one_ull (unsigned long long int n) #if @GNULIB_STDC_FIRST_TRAILING_ZERO@ +# if !GNULIB_defined_stdc_first_trailing_zero_functions + _GL_STDC_FIRST_TRAILING_ZERO_INLINE unsigned int stdc_first_trailing_zero_uc (unsigned char n) { @@ -715,6 +755,9 @@ stdc_first_trailing_zero_ull (unsigned long long int n) return count % bits + (count < bits); } +# define GNULIB_defined_stdc_first_trailing_zero_functions 1 +# endif + # define stdc_first_trailing_zero(n) \ (sizeof (n) == 1 ? stdc_first_trailing_zero_uc (n) \ : sizeof (n) == sizeof (unsigned short) ? stdc_first_trailing_zero_us (n) \ @@ -729,6 +772,8 @@ stdc_first_trailing_zero_ull (unsigned long long int n) #if @GNULIB_STDC_FIRST_TRAILING_ONE@ +# if !GNULIB_defined_stdc_first_trailing_one_functions + _GL_STDC_FIRST_TRAILING_ONE_INLINE unsigned int stdc_first_trailing_one_uc (unsigned char n) { @@ -769,7 +814,10 @@ stdc_first_trailing_one_ull (unsigned long long int n) return count % bits + (count < bits); } -#define stdc_first_trailing_one(n) \ +# define GNULIB_defined_stdc_first_trailing_one_functions 1 +# endif + +# define stdc_first_trailing_one(n) \ (sizeof (n) == 1 ? stdc_first_trailing_one_uc (n) \ : sizeof (n) == sizeof (unsigned short) ? stdc_first_trailing_one_us (n) \ : sizeof (n) == sizeof 0u ? stdc_first_trailing_one_ui (n) \ @@ -794,11 +842,12 @@ stdc_first_trailing_one_ull (unsigned long long int n) # endif /* Count 1 bits in N. */ -# ifdef _GL_STDBIT_HAS_BUILTIN_POPCOUNT -# define _gl_stdbit_popcount __builtin_popcount -# define _gl_stdbit_popcountl __builtin_popcountl -# define _gl_stdbit_popcountll __builtin_popcountll -# else +# if !GNULIB_defined_popcount_functions +# ifdef _GL_STDBIT_HAS_BUILTIN_POPCOUNT +# define _gl_stdbit_popcount __builtin_popcount +# define _gl_stdbit_popcountl __builtin_popcountl +# define _gl_stdbit_popcountll __builtin_popcountll +# else _GL_STDC_COUNT_ONES_INLINE int _gl_stdbit_popcount_wide (unsigned long long int n) { @@ -846,25 +895,25 @@ _gl_stdbit_popcount_wide (unsigned long long int n) } } -# ifdef _MSC_VER -# if 1500 <= _MSC_VER && (defined _M_IX86 || defined _M_X64) +# ifdef _MSC_VER +# if 1500 <= _MSC_VER && (defined _M_IX86 || defined _M_X64) /* Declare the few MSVC intrinsics that we need. We prefer not to include <intrin.h> because it would pollute the namespace. */ extern void __cpuid (int[4], int); -# pragma intrinsic (__cpuid) +# pragma intrinsic (__cpuid) extern unsigned int __popcnt (unsigned int); -# pragma intrinsic (__popcnt) -# ifdef _M_X64 +# pragma intrinsic (__popcnt) +# ifdef _M_X64 extern unsigned long long __popcnt64 (unsigned long long); -# pragma intrinsic (__popcnt64) -# else +# pragma intrinsic (__popcnt64) +# else _GL_STDC_COUNT_ONES_INLINE int __popcnt64 (unsigned long long int n) { return __popcnt (n >> 32) + __popcnt (n); } +# endif # endif -# endif /* 1 if supported, -1 if not, 0 if unknown. */ extern signed char _gl_stdbit_popcount_support; @@ -905,13 +954,17 @@ _gl_stdbit_popcountll (unsigned long long int n) ? __popcnt64 (n) : _gl_stdbit_popcount_wide (n)); } -# else /* !_MSC_VER */ -# define _gl_stdbit_popcount _gl_stdbit_popcount_wide -# define _gl_stdbit_popcountl _gl_stdbit_popcount_wide -# define _gl_stdbit_popcountll _gl_stdbit_popcount_wide +# else /* !_MSC_VER */ +# define _gl_stdbit_popcount _gl_stdbit_popcount_wide +# define _gl_stdbit_popcountl _gl_stdbit_popcount_wide +# define _gl_stdbit_popcountll _gl_stdbit_popcount_wide +# endif # endif +# define GNULIB_defined_popcount_functions 1 # endif +# if !GNULIB_defined_stdc_count_ones_functions + _GL_STDC_COUNT_ONES_INLINE unsigned int stdc_count_ones_ui (unsigned int n) { @@ -942,6 +995,9 @@ stdc_count_ones_ull (unsigned long long int n) return _gl_stdbit_popcountll (n); } +# define GNULIB_defined_stdc_count_ones_functions 1 +# endif + # define stdc_count_ones(n) \ (sizeof (n) == 1 ? stdc_count_ones_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_count_ones_us (n) \ @@ -956,6 +1012,8 @@ stdc_count_ones_ull (unsigned long long int n) #if @GNULIB_STDC_COUNT_ZEROS@ +# if !GNULIB_defined_stdc_count_zeros_functions + _GL_STDC_COUNT_ZEROS_INLINE unsigned int stdc_count_zeros_uc (unsigned char n) { @@ -986,6 +1044,9 @@ stdc_count_zeros_ull (unsigned long long int n) return stdc_count_ones_ull (~n); } +# define GNULIB_defined_stdc_count_zeros_functions 1 +# endif + # define stdc_count_zeros(n) \ (sizeof (n) == 1 ? stdc_count_zeros_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_count_zeros_us (n) \ @@ -1000,6 +1061,8 @@ stdc_count_zeros_ull (unsigned long long int n) #if @GNULIB_STDC_HAS_SINGLE_BIT@ +# if !GNULIB_defined_stdc_has_single_bit_functions + _GL_STDC_HAS_SINGLE_BIT_INLINE bool stdc_has_single_bit_uc (unsigned char n) { @@ -1035,6 +1098,9 @@ stdc_has_single_bit_ull (unsigned long long int n) return n_1 < nx; } +# define GNULIB_defined_stdc_has_single_bit_functions 1 +# endif + # define stdc_has_single_bit(n) \ ((bool) \ (sizeof (n) == 1 ? stdc_has_single_bit_uc (n) \ @@ -1050,6 +1116,8 @@ stdc_has_single_bit_ull (unsigned long long int n) #if @GNULIB_STDC_BIT_WIDTH@ +# if !GNULIB_defined_stdc_bit_width_functions + _GL_STDC_BIT_WIDTH_INLINE unsigned int stdc_bit_width_uc (unsigned char n) { @@ -1080,6 +1148,9 @@ stdc_bit_width_ull (unsigned long long int n) return 8 * sizeof n - stdc_leading_zeros_ull (n); } +# define GNULIB_defined_stdc_bit_width_functions 1 +# endif + # define stdc_bit_width(n) \ (sizeof (n) == 1 ? stdc_bit_width_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_bit_width_us (n) \ @@ -1094,6 +1165,8 @@ stdc_bit_width_ull (unsigned long long int n) #if @GNULIB_STDC_BIT_FLOOR@ +# if !GNULIB_defined_stdc_bit_floor_functions + _GL_STDC_BIT_FLOOR_INLINE unsigned char stdc_bit_floor_uc (unsigned char n) { @@ -1124,6 +1197,9 @@ stdc_bit_floor_ull (unsigned long long int n) return n ? 1ull << (stdc_bit_width_ull (n) - 1) : 0; } +# define GNULIB_defined_stdc_bit_floor_functions 1 +# endif + # define stdc_bit_floor(n) \ (_GL_STDBIT_TYPEOF_CAST \ (n, \ @@ -1140,6 +1216,8 @@ stdc_bit_floor_ull (unsigned long long int n) #if @GNULIB_STDC_BIT_CEIL@ +# if !GNULIB_defined_stdc_bit_ceil_functions + _GL_STDC_BIT_CEIL_INLINE unsigned char stdc_bit_ceil_uc (unsigned char n) { @@ -1170,6 +1248,9 @@ stdc_bit_ceil_ull (unsigned long long int n) return n <= 1 ? 1 : 2ull << (stdc_bit_width_ull (n - 1) - 1); } +# define GNULIB_defined_stdc_bit_ceil_functions 1 +# endif + # define stdc_bit_ceil(n) \ (_GL_STDBIT_TYPEOF_CAST \ (n, \ @@ -1201,6 +1282,8 @@ stdc_bit_ceil_ull (unsigned long long int n) | ((v) >> (-(c) & (sizeof (v) * 8 - 1)))) # endif +# if !GNULIB_defined_stdc_rotate_left_functions + _GL_STDC_ROTATE_LEFT_INLINE unsigned char stdc_rotate_left_uc (unsigned char v, unsigned int c) { @@ -1231,6 +1314,9 @@ stdc_rotate_left_ull (unsigned long long int v, unsigned int c) return _gl_stdc_rotate_left (v, c); } +# define GNULIB_defined_stdc_rotate_left_functions 1 +# endif + # ifndef stdc_rotate_left # define stdc_rotate_left(v, c) \ (_GL_STDBIT_TYPEOF_CAST \ @@ -1262,6 +1348,8 @@ stdc_rotate_left_ull (unsigned long long int v, unsigned int c) | ((v) << (-(c) & (sizeof (v) * 8 - 1)))) # endif +# if !GNULIB_defined_stdc_rotate_right_functions + _GL_STDC_ROTATE_RIGHT_INLINE unsigned char stdc_rotate_right_uc (unsigned char v, unsigned int c) { @@ -1292,6 +1380,9 @@ stdc_rotate_right_ull (unsigned long long int v, unsigned int c) return _gl_stdc_rotate_right (v, c); } +# define GNULIB_defined_stdc_rotate_right_functions 1 +# endif + # ifndef stdc_rotate_right # define stdc_rotate_right(v, c) \ (_GL_STDBIT_TYPEOF_CAST \ @@ -1310,6 +1401,8 @@ stdc_rotate_right_ull (unsigned long long int v, unsigned int c) #if @GNULIB_STDC_MEMREVERSE8@ +# if !GNULIB_defined_stdc_memreverse8 + _GL_STDC_MEMREVERSE8_INLINE void stdc_memreverse8 (size_t n, unsigned char *ptr) { @@ -1331,6 +1424,9 @@ stdc_memreverse8 (size_t n, unsigned char *ptr) } } +# define GNULIB_defined_stdc_memreverse8 1 +# endif + #endif @@ -1343,6 +1439,8 @@ stdc_memreverse8 (size_t n, unsigned char *ptr) generalization that does not contradict ISO C: When uintN_t exists, it is known that uint_leastN_t is the same type as uintN_t. */ +# if !GNULIB_defined_stdc_memreverse8u_functions + _GL_STDC_MEMREVERSE8U_INLINE uint_least8_t stdc_memreverse8u8 (uint_least8_t value) { @@ -1352,35 +1450,35 @@ stdc_memreverse8u8 (uint_least8_t value) _GL_STDC_MEMREVERSE8U_INLINE uint_least16_t stdc_memreverse8u16 (uint_least16_t value) { -# ifdef _GL_STDBIT_HAS_BUILTIN_BSWAP16 +# ifdef _GL_STDBIT_HAS_BUILTIN_BSWAP16 return __builtin_bswap16 (value); -# else +# else _GL_STDBIT_UINT_FAST16 mask = 0xFFU; return ( (value & (mask << (8 * 1))) >> (8 * 1) | (value & (mask << (8 * 0))) << (8 * 1)); -# endif +# endif } _GL_STDC_MEMREVERSE8U_INLINE uint_least32_t stdc_memreverse8u32 (uint_least32_t value) { -# ifdef _GL_STDBIT_HAS_BUILTIN_BSWAP32 +# ifdef _GL_STDBIT_HAS_BUILTIN_BSWAP32 return __builtin_bswap32 (value); -# else +# else _GL_STDBIT_UINT_FAST32 mask = 0xFFU; return ( (value & (mask << (8 * 3))) >> (8 * 3) | (value & (mask << (8 * 2))) >> (8 * 1) | (value & (mask << (8 * 1))) << (8 * 1) | (value & (mask << (8 * 0))) << (8 * 3)); -# endif +# endif } _GL_STDC_MEMREVERSE8U_INLINE uint_least64_t stdc_memreverse8u64 (uint_least64_t value) { -# ifdef _GL_STDBIT_HAS_BUILTIN_BSWAP64 +# ifdef _GL_STDBIT_HAS_BUILTIN_BSWAP64 return __builtin_bswap64 (value); -# else +# else _GL_STDBIT_UINT_FAST64 mask = 0xFFU; return ( (value & (mask << (8 * 7))) >> (8 * 7) | (value & (mask << (8 * 6))) >> (8 * 5) @@ -1390,9 +1488,12 @@ stdc_memreverse8u64 (uint_least64_t value) | (value & (mask << (8 * 2))) << (8 * 3) | (value & (mask << (8 * 1))) << (8 * 5) | (value & (mask << (8 * 0))) << (8 * 7)); -# endif +# endif } +# define GNULIB_defined_stdc_memreverse8u_functions 1 +# endif + #endif @@ -1530,6 +1631,8 @@ stdc_memreverse8u64 (uint_least64_t value) #if @GNULIB_STDC_LOAD8@ +# if !GNULIB_defined_stdc_load8_functions + _GL_STDC_LOAD8_INLINE uint_least8_t stdc_load8_beu8 (const unsigned char ptr[1]) { @@ -1660,10 +1763,15 @@ stdc_load8_les64 (const unsigned char ptr[8]) return stdc_load8_leu64 (ptr); } +# define GNULIB_defined_stdc_load8_functions 1 +# endif + #endif #if @GNULIB_STDC_LOAD8_ALIGNED@ +# if !GNULIB_defined_stdc_load8_aligned_functions + _GL_STDC_LOAD8_ALIGNED_INLINE uint_least8_t stdc_load8_aligned_beu8 (const unsigned char ptr[1]) { @@ -1814,6 +1922,9 @@ stdc_load8_aligned_les64 (const unsigned char ptr[8]) return stdc_load8_aligned_leu64 (ptr); } +# define GNULIB_defined_stdc_load8_aligned_functions 1 +# endif + #endif @@ -1821,6 +1932,8 @@ stdc_load8_aligned_les64 (const unsigned char ptr[8]) #if @GNULIB_STDC_STORE8@ +# if !GNULIB_defined_stdc_store8_functions + _GL_STDC_STORE8_INLINE void stdc_store8_beu8 (uint_least8_t value, unsigned char ptr[1]) { @@ -1939,10 +2052,15 @@ stdc_store8_les64 (int_least64_t value, unsigned char ptr[8]) stdc_store8_leu64 (value, ptr); } +# define GNULIB_defined_stdc_store8_functions 1 +# endif + #endif #if @GNULIB_STDC_STORE8_ALIGNED@ +# if !GNULIB_defined_stdc_store8_aligned_functions + _GL_STDC_STORE8_ALIGNED_INLINE void stdc_store8_aligned_beu8 (uint_least8_t value, unsigned char ptr[1]) { @@ -2081,6 +2199,9 @@ stdc_store8_aligned_les64 (int_least64_t value, unsigned char ptr[8]) stdc_store8_aligned_leu64 (value, ptr); } +# define GNULIB_defined_stdc_store8_aligned_functions 1 +# endif + #endif -- 2.52.0
>From aa162e82592637435beef38d9eafdefcc67729c1 Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Wed, 29 Apr 2026 01:47:39 +0200 Subject: [PATCH 4/6] string-h: Support multiple gnulib-tool invocations in the same package. * lib/string.in.h (GNULIB_defined_memeq, GNULIB_defined_streq, GNULIB_defined_strnul): New macros. --- ChangeLog | 6 ++++++ lib/string.in.h | 55 ++++++++++++++++++++++++++++--------------------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0ea7c1dde..0ef64fe22c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2026-04-28 Bruno Haible <[email protected]> + + string-h: Support multiple gnulib-tool invocations in the same package. + * lib/string.in.h (GNULIB_defined_memeq, GNULIB_defined_streq, + GNULIB_defined_strnul): New macros. + 2026-04-28 Bruno Haible <[email protected]> stdbit-h: Support multiple gnulib-tool invocations in the same package. diff --git a/lib/string.in.h b/lib/string.in.h index f04bbc6514..3fa3e943eb 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -420,16 +420,19 @@ _GL_WARN_ON_USE_CXX (memchr, /* Are S1 and S2, of size N, bytewise equal? */ #if @GNULIB_MEMEQ@ && !@HAVE_DECL_MEMEQ@ -# ifdef __cplusplus +# if !GNULIB_defined_memeq +# ifdef __cplusplus extern "C" { -# endif +# endif _GL_MEMEQ_INLINE bool memeq (void const *__s1, void const *__s2, size_t __n) { return !memcmp (__s1, __s2, __n); } -# ifdef __cplusplus +# ifdef __cplusplus } +# endif +# define GNULIB_defined_memeq 1 # endif #endif @@ -805,16 +808,19 @@ _GL_CXXALIASWARN (strdup); /* Are strings S1 and S2 equal? */ #if @GNULIB_STREQ@ && !@HAVE_DECL_STREQ@ -# ifdef __cplusplus +# if !GNULIB_defined_streq +# ifdef __cplusplus extern "C" { -# endif +# endif _GL_STREQ_INLINE bool streq (char const *__s1, char const *__s2) { return !strcmp (__s1, __s2); } -# ifdef __cplusplus +# ifdef __cplusplus } +# endif +# define GNULIB_defined_streq 1 # endif #endif @@ -1245,9 +1251,10 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " string + strlen (string) or to strchr (string, '\0'). */ -# ifdef __cplusplus +# if !GNULIB_defined_strnul +# ifdef __cplusplus extern "C" { -# endif +# endif _GL_STRNUL_INLINE const char *_gl_strnul (const char *string) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1)); @@ -1261,10 +1268,10 @@ _GL_STRNUL_INLINE const char *_gl_strnul (const char *string) option '-fno-builtin' is in use. */ return string + strlen (string); } -# ifdef __cplusplus +# ifdef __cplusplus } -# endif -# ifdef __cplusplus +# endif +# ifdef __cplusplus _GL_BEGIN_NAMESPACE template <typename T> T strnul (T); template <> inline const char *strnul<const char *> (const char *s) @@ -1272,11 +1279,11 @@ template <> inline const char *strnul<const char *> (const char *s) template <> inline char *strnul< char *> ( char *s) { return const_cast<char *>(_gl_strnul (s)); } _GL_END_NAMESPACE -# else -# if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __cplusplus) \ - || (defined __clang__ && __clang_major__ >= 3) \ - || (defined __SUNPRO_C && __SUNPRO_C >= 0x5150) \ - || (__STDC_VERSION__ >= 201112L && !defined __GNUC__) +# else +# if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __cplusplus) \ + || (defined __clang__ && __clang_major__ >= 3) \ + || (defined __SUNPRO_C && __SUNPRO_C >= 0x5150) \ + || (__STDC_VERSION__ >= 201112L && !defined __GNUC__) /* The compiler supports _Generic from ISO C11. */ /* Since in C (but not in C++!), any function that accepts a '[const] char *' also accepts a '[const] void *' as argument, we make sure that the function- @@ -1284,14 +1291,16 @@ _GL_END_NAMESPACE char *, void * -> void * const char *, const void * -> const void * This mapping is done through the conditional expression. */ -# define strnul(s) \ - _Generic (1 ? (s) : (void *) 99, \ - void * : (char *) _gl_strnul (s), \ - const void * : _gl_strnul (s)) -# else -# define strnul(s) \ - ((char *) _gl_strnul (s)) +# define strnul(s) \ + _Generic (1 ? (s) : (void *) 99, \ + void * : (char *) _gl_strnul (s), \ + const void * : _gl_strnul (s)) +# else +# define strnul(s) \ + ((char *) _gl_strnul (s)) +# endif # endif +# define GNULIB_defined_strnul 1 # endif #endif -- 2.52.0
>From 42b206bea36d4fd12323a2e4dcc45856324294a1 Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Wed, 29 Apr 2026 01:49:40 +0200 Subject: [PATCH 5/6] realloc-posix: Support multiple gnulib-tool invocations in a package. * lib/stdlib.in.h (rpl_realloc): Don't define if _GL_INLINE_RPL_REALLOC is already defined. --- ChangeLog | 6 ++++++ lib/stdlib.in.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0ef64fe22c..ad6f701635 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2026-04-28 Bruno Haible <[email protected]> + + realloc-posix: Support multiple gnulib-tool invocations in a package. + * lib/stdlib.in.h (rpl_realloc): Don't define if _GL_INLINE_RPL_REALLOC + is already defined. + 2026-04-28 Bruno Haible <[email protected]> string-h: Support multiple gnulib-tool invocations in the same package. diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index ed2b1f8ff2..3c2004611f 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -1458,7 +1458,7 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " #if @GNULIB_REALLOC_POSIX@ # if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ -# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2 +# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2 && !_GL_INLINE_RPL_REALLOC # define _GL_INLINE_RPL_REALLOC 1 # ifdef __cplusplus extern "C" { -- 2.52.0
From aa9ab93e4ee8b413d9c1c1cf6525447cdcc9df1d Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Wed, 29 Apr 2026 01:52:17 +0200 Subject: [PATCH 6/6] error-h: Support multiple gnulib-tool invocations in the same package. * lib/error.in.h (GNULIB_defined_error, GNULIB_defined_error_at_line): New macros. (verror): Test GNULIB_defined_verror, for consistency with the idiom. (verror_at_line): Test GNULIB_defined_verror_at_line, for consistency with the idiom. --- ChangeLog | 9 +++++++++ lib/error.in.h | 50 ++++++++++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad6f701635..c38bc06df4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2026-04-28 Bruno Haible <[email protected]> + + error-h: Support multiple gnulib-tool invocations in the same package. + * lib/error.in.h (GNULIB_defined_error, GNULIB_defined_error_at_line): + New macros. + (verror): Test GNULIB_defined_verror, for consistency with the idiom. + (verror_at_line): Test GNULIB_defined_verror_at_line, for consistency + with the idiom. + 2026-04-28 Bruno Haible <[email protected]> realloc-posix: Support multiple gnulib-tool invocations in a package. diff --git a/lib/error.in.h b/lib/error.in.h index 95ed6d8312..97bb96c74b 100644 --- a/lib/error.in.h +++ b/lib/error.in.h @@ -115,11 +115,12 @@ _GL_FUNCDECL_SYS (error, void, _GL_CXXALIAS_SYS (error, void, (int __status, int __errnum, const char *__format, ...)); # ifndef _GL_NO_INLINE_ERROR -# ifdef error +# if !GNULIB_defined_error +# ifdef error /* Only gcc ??? 4.7 has __builtin_va_arg_pack. */ -# if _GL_GNUC_PREREQ (4, 7) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wattributes" +# if _GL_GNUC_PREREQ (4, 7) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wattributes" _GL_ATTRIBUTE_MAYBE_UNUSED static void _GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD @@ -128,14 +129,16 @@ _gl_inline_error (int __status, int __errnum, const char *__format, ...) { return error (__status, __errnum, __format, __builtin_va_arg_pack ()); } -# pragma GCC diagnostic pop -# undef error +# pragma GCC diagnostic pop +# undef error +# define error(status, ...) \ + _gl_error_call (_gl_inline_error, status, __VA_ARGS__) +# endif +# else # define error(status, ...) \ - _gl_error_call (_gl_inline_error, status, __VA_ARGS__) + _gl_error_call (error, status, __VA_ARGS__) # endif -# else -# define error(status, ...) \ - _gl_error_call (error, status, __VA_ARGS__) +# define GNULIB_defined_error 1 # endif # endif #endif @@ -175,11 +178,12 @@ _GL_CXXALIAS_SYS (error_at_line, void, (int __status, int __errnum, const char *__filename, unsigned int __lineno, const char *__format, ...)); # ifndef _GL_NO_INLINE_ERROR -# ifdef error_at_line +# if !GNULIB_defined_error_at_line +# ifdef error_at_line /* Only gcc ??? 4.7 has __builtin_va_arg_pack. */ -# if _GL_GNUC_PREREQ (4, 7) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wattributes" +# if _GL_GNUC_PREREQ (4, 7) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wattributes" _GL_ATTRIBUTE_MAYBE_UNUSED static void _GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD @@ -190,14 +194,16 @@ _gl_inline_error_at_line (int __status, int __errnum, const char *__filename, return error_at_line (__status, __errnum, __filename, __lineno, __format, __builtin_va_arg_pack ()); } -# pragma GCC diagnostic pop -# undef error_at_line +# pragma GCC diagnostic pop +# undef error_at_line +# define error_at_line(status, ...) \ + _gl_error_call (_gl_inline_error_at_line, status, __VA_ARGS__) +# endif +# else # define error_at_line(status, ...) \ - _gl_error_call (_gl_inline_error_at_line, status, __VA_ARGS__) + _gl_error_call (error_at_line, status, __VA_ARGS__) # endif -# else -# define error_at_line(status, ...) \ - _gl_error_call (error_at_line, status, __VA_ARGS__) +# define GNULIB_defined_error_at_line 1 # endif # endif #endif @@ -214,7 +220,7 @@ extern void verror (int __status, int __errnum, const char *__format, _GL_ATTRIBUTE_COLD _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0)); #ifndef _GL_NO_INLINE_ERROR -# ifndef verror +# if !GNULIB_defined_verror # define verror(status, ...) \ _gl_error_call (verror, status, __VA_ARGS__) # define GNULIB_defined_verror 1 @@ -234,7 +240,7 @@ extern void verror_at_line (int __status, int __errnum, const char *__fname, _GL_ATTRIBUTE_COLD _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 0)); #ifdef _GL_NO_INLINE_ERROR -# ifndef verror_at_line +# if !GNULIB_defined_verror_at_line # define verror_at_line(status, ...) \ _gl_error_call (verror_at_line, status, __VA_ARGS__) # define GNULIB_defined_verror_at_line 1 -- 2.52.0
