Hi Paul,
Paul Eggert <[email protected]> writes:
> -#if @GNULIB_STDC_MEMREVERSE8@
> -
> +#if !@HAVE_STDBIT_H@
> /* Get size_t. */
> # include <stddef.h>
> -
> #endif
>
> -#if @GNULIB_STDC_MEMREVERSE8U@ || @GNULIB_STDC_LOAD8_ALIGNED@ ||
> @GNULIB_STDC_LOAD8@ || @GNULIB_STDC_STORE8_ALIGNED@ || @GNULIB_STDC_STORE8@
> -
> -/* Get uint8_t, uint16_t, uint32_t, uint64_t,
> - int_least8_t, int_least16_t, int_least32_t, int_least64_t,
> - uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t,
> - uint_fast16_t, uint_fast32_t, uint_fast64_t. */
> +#if (!@HAVE_STDBIT_H@ \
> + || (!defined __UINT_FAST64_TYPE__ \
> + && (@GNULIB_STDC_MEMREVERSE8U@ \
> + || @GNULIB_STDC_LOAD8@ || @GNULIB_STDC_LOAD8_ALIGNED@ \
> + || @GNULIB_STDC_STORE8@ || @GNULIB_STDC_STORE8_ALIGNED@)))
> +/* Get intN_t, uintN_t, int_leastN_t, uint_leastN_t. */
> # include <stdint.h>
> +#endif
>
> +/* uint_fast{16,32,64}_t equivalents, sans namespace pollution on GNU. */
> +#if @HAVE_STDBIT_H@ && defined __UINT_FAST64_TYPE__
> +# define _GL_STDBIT_UINT_FAST16 __UINT_FAST16_TYPE__
> +# define _GL_STDBIT_UINT_FAST32 __UINT_FAST32_TYPE__
> +# define _GL_STDBIT_UINT_FAST64 __UINT_FAST64_TYPE__
> +#else
> +# define _GL_STDBIT_UINT_FAST16 uint_fast16_t
> +# define _GL_STDBIT_UINT_FAST32 uint_fast32_t
> +# define _GL_STDBIT_UINT_FAST64 uint_fast64_t
> #endif
These changes don't work on FreeBSD 16.0. For example, in the following
testdir:
$ gnulib-tool --create-testdir --dir testdir1 stdc_load8
You will see errors like this:
$ make
[...]
cc -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 -g -O2 -MT
stdc_load8.o -MD -MP -MF .deps/stdc_load8.Tpo -c -o stdc_load8.o stdc_load8.c
In file included from stdc_load8.c:19:
./stdbit.h:1528:23: error: unknown type name 'uint_least8_t'
1528 | _GL_STDC_LOAD8_INLINE uint_least8_t
| ^
./stdbit.h:1534:23: error: unknown type name 'uint_least16_t'
1534 | _GL_STDC_LOAD8_INLINE uint_least16_t
| ^
[...]
Similarly, with this testdir:
$ gnulib-tool --create-testdir --dir testdir1 stdc_memreverse8
You will see errors like this:
$ make
[...]
cc -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 -g -O2 -MT
stdc_memreverse8.o -MD -MP -MF .deps/stdc_memreverse8.Tpo -c -o
stdc_memreverse8.o stdc_memreverse8.c
In file included from stdc_memreverse8.c:19:
./stdbit.h:1309:19: error: unknown type name 'size_t'
1309 | stdc_memreverse8 (size_t n, unsigned char *ptr)
| ^
./stdbit.h:1318:7: error: use of undeclared identifier 'size_t'; did you
mean 'sizeof'?
1318 | size_t i, j;
| ^~~~~~
| sizeof
[...]
This is a FreeBSD bug since C23 § 7.18.1 states that "This header makes
available the size_t type name (7.21) and any uintN_t, intN_t,
uint_leastN_t, or int_leastN_t type names defined by the implementation
(7.22)."
Since FreeBSD 16.0 is not released, I am not sure if it is worth working
around. But I figured it was worth mentioning here.
I reported it on the FreeBSD bug tracker [1].
Collin
[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294131