Collin Funk wrote:
> I've attached patches adding the stdc_rotate_{left,right} macros and
> functions, but have not pushed them yet.I need the #include_next part of your patch 0001, so as to complete the "stdbit-h: Use idioms for handling multiple gnulib-tool invocations" commit a couple of days ago. I'm committing this in your name: 2026-03-12 Collin Funk <[email protected]> stdbit-h: Finish handling multiple gnulib-tool invocations. * lib/stdbit.in.h: Setup #include_next for the system stdbit.h. Don't declare C23 functions if the system has stdbit.h. * m4/stdbit_h.m4 (gl_STDBIT_H): Define HAVE_STDBIT_H. Check for stdc_rotate_left_uc to see if the system header is missing C2y features. * modules/stdbit-h (Depends-on): Add include_next. (Makefile.am): Substitute @HAVE_STDBIT_H@ and some variables needed for #include_next in the generated header.
From e232a308b40ecea7a74c88987845b26fdd08bace Mon Sep 17 00:00:00 2001 From: Collin Funk <[email protected]> Date: Thu, 12 Mar 2026 12:21:44 +0100 Subject: [PATCH 1/2] stdbit-h: Finish handling multiple gnulib-tool invocations. * lib/stdbit.in.h: Setup #include_next for the system stdbit.h. Don't declare C23 functions if the system has stdbit.h. * m4/stdbit_h.m4 (gl_STDBIT_H): Define HAVE_STDBIT_H. Check for stdc_rotate_left_uc to see if the system header is missing C2y features. * modules/stdbit-h (Depends-on): Add include_next. (Makefile.am): Substitute @HAVE_STDBIT_H@ and some variables needed for --- ChangeLog | 11 +++++++++++ lib/stdbit.in.h | 24 +++++++++++++++++++++--- m4/stdbit_h.m4 | 19 ++++++++++++++++--- modules/stdbit-h | 7 +++++++ 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71d77dc037..2ad7640649 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2026-03-12 Collin Funk <[email protected]> + + stdbit-h: Finish handling multiple gnulib-tool invocations. + * lib/stdbit.in.h: Setup #include_next for the system stdbit.h. Don't + declare C23 functions if the system has stdbit.h. + * m4/stdbit_h.m4 (gl_STDBIT_H): Define HAVE_STDBIT_H. Check for + stdc_rotate_left_uc to see if the system header is missing C2y features. + * modules/stdbit-h (Depends-on): Add include_next. + (Makefile.am): Substitute @HAVE_STDBIT_H@ and some variables needed for + #include_next in the generated header. + 2026-03-11 Bruno Haible <[email protected]> vaprintf: Add tests. diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h index 60b7b54981..7ea26926be 100644 --- a/lib/stdbit.in.h +++ b/lib/stdbit.in.h @@ -17,8 +17,20 @@ /* Written by Paul Eggert. */ -#ifndef STDBIT_H -#define STDBIT_H 1 +#ifndef _@GUARD_PREFIX@_STDBIT_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_STDBIT_H@ +# @INCLUDE_NEXT@ @NEXT_STDBIT_H@ +#endif + +#ifndef _@GUARD_PREFIX@_STDBIT_H +#define _@GUARD_PREFIX@_STDBIT_H /* This file uses _GL_INLINE, WORDS_BIGENDIAN. */ #if !_GL_CONFIG_H_INCLUDED @@ -90,6 +102,9 @@ _GL_INLINE_HEADER_BEGIN #endif +/* Some systems are only missing C2y features in stdbit.h. */ +#if !@HAVE_STDBIT_H@ + /* ISO C 23 ?? 7.18.1 General */ #define __STDC_VERSION_STDBIT_H__ 202311L @@ -1068,6 +1083,8 @@ stdc_bit_ceil_ull (unsigned long long int n) #endif +#endif /* @HAVE_STDBIT_H@ */ + #ifdef __cplusplus } @@ -1075,4 +1092,5 @@ stdc_bit_ceil_ull (unsigned long long int n) _GL_INLINE_HEADER_END -#endif /* STDBIT_H */ +#endif /* _@GUARD_PREFIX@_STDBIT_H */ +#endif /* _@GUARD_PREFIX@_STDBIT_H */ diff --git a/m4/stdbit_h.m4 b/m4/stdbit_h.m4 index 997c5b2bfb..3328644e2d 100644 --- a/m4/stdbit_h.m4 +++ b/m4/stdbit_h.m4 @@ -1,5 +1,5 @@ # stdbit_h.m4 -# serial 4 +# serial 5 dnl Copyright 2024-2026 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,9 +12,22 @@ AC_DEFUN_ONCE([gl_STDBIT_H] [ AC_REQUIRE([gl_BIGENDIAN]) - AC_CHECK_HEADERS_ONCE([stdbit.h]) + gl_CHECK_NEXT_HEADERS([stdbit.h]) if test $ac_cv_header_stdbit_h = yes; then - GL_GENERATE_STDBIT_H=false + HAVE_STDBIT_H=1 + else + HAVE_STDBIT_H=0 + fi + AC_SUBST([HAVE_STDBIT_H]) + + if test $ac_cv_header_stdbit_h = yes; then + dnl We may have a stdbit.h without C2y features. + AC_CHECK_DECLS([stdc_rotate_left_uc], , , [[#include <stdbit.h>]]) + if test $ac_cv_have_decl_stdc_rotate_left_uc = no; then + GL_GENERATE_STDBIT_H=true + else + GL_GENERATE_STDBIT_H=false + fi else GL_GENERATE_STDBIT_H=true fi diff --git a/modules/stdbit-h b/modules/stdbit-h index 7b820a864a..7c739fbd48 100644 --- a/modules/stdbit-h +++ b/modules/stdbit-h @@ -8,6 +8,7 @@ m4/stdbit_h.m4 Depends-on: gen-header +include_next extern-inline [$GL_GENERATE_STDBIT_H] bool [$GL_GENERATE_STDBIT_H] @@ -25,6 +26,12 @@ if GL_GENERATE_STDBIT_H stdbit.h: stdbit.in.h $(top_builddir)/config.status @NMD@ $(AM_V_GEN)$(MKDIR_P) '%reldir%' $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's/@''HAVE_STDBIT_H''@/$(HAVE_STDBIT_H)/g' \ + -e 's/@''GUARD_PREFIX''@/$(GUARD_PREFIX)/g' \ + -e 's/@''PRAGMA_SYSTEM_HEADER''@/$(PRAGMA_SYSTEM_HEADER)/g' \ + -e 's/@''PRAGMA_COLUMNS''@/$(PRAGMA_COLUMNS)/g' \ + -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's/@''NEXT_STDBIT_H''@/$(NEXT_STDBIT_H)/g' \ -e 's/@''GNULIB_STDC_LEADING_ZEROS''@/$(GNULIB_STDC_LEADING_ZEROS)/g' \ -e 's/@''GNULIB_STDC_LEADING_ONES''@/$(GNULIB_STDC_LEADING_ONES)/g' \ -e 's/@''GNULIB_STDC_TRAILING_ZEROS''@/$(GNULIB_STDC_TRAILING_ZEROS)/g' \ -- 2.52.0
