From f146bac0b09c8b10ff098de47b2b375281b5a4f9 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 16 May 2024 00:45:15 +0200 Subject: [PATCH] stdbit-h, stdc_*: New modules, part of the stdbit module. * lib/stdbit.in.h (_GL_STDC_*_INLINE): New macros. Enclose function definitions in #if @GL_STDC_*@ conditionals. * lib/stdc_leading_zeros.c: New file. * lib/stdc_leading_ones.c: New file. * lib/stdc_trailing_zeros.c: New file. * lib/stdc_trailing_ones.c: New file. * lib/stdc_first_leading_zero.c: New file. * lib/stdc_first_leading_one.c: New file. * lib/stdc_first_trailing_zero.c: New file. * lib/stdc_first_trailing_one.c: New file. * lib/stdc_count_zeros.c: New file. * lib/stdc_count_ones.c: New file, based on lib/stdbit.c. * lib/stdc_has_single_bit.c: New file. * lib/stdc_bit_width.c: New file. * lib/stdc_bit_floor.c: New file. * lib/stdc_bit_ceil.c: New file. * lib/stdbit.c (__gl_stdbit_popcount_support): Remove variable. * m4/stdbit_h.m4 (gl_STDBIT_H): Initialize GL_STDC_* variables. * modules/stdbit-h: New file, based on modules/stdbit. (Depends-on): Add gen-header. (Makefile.am): Substitute GL_STDC_* variables. * modules/stdc_leading_zeros: New file. * modules/stdc_leading_ones: New file. * modules/stdc_trailing_zeros: New file. * modules/stdc_trailing_ones: New file. * modules/stdc_first_leading_zero: New file. * modules/stdc_first_leading_one: New file. * modules/stdc_first_trailing_zero: New file. * modules/stdc_first_trailing_one: New file. * modules/stdc_count_zeros: New file. * modules/stdc_count_ones: New file. * modules/stdc_has_single_bit: New file. * modules/stdc_bit_width: New file. * modules/stdc_bit_floor: New file. * modules/stdc_bit_ceil: New file. * modules/stdbit: Change to a pure composition module. * modules/stdc_leading_zeros-tests: New file, based on modules/stdbit-tests. * modules/stdc_leading_ones-tests: New file, based on modules/stdbit-tests. * modules/stdc_trailing_zeros-tests: New file, based on modules/stdbit-tests. * modules/stdc_trailing_ones-tests: New file, based on modules/stdbit-tests. * modules/stdc_first_leading_zero-tests: New file, based on modules/stdbit-tests. * modules/stdc_first_leading_one-tests: New file, based on modules/stdbit-tests. * modules/stdc_first_trailing_zero-tests: New file, based on modules/stdbit-tests. * modules/stdc_first_trailing_one-tests: New file, based on modules/stdbit-tests. * modules/stdc_count_zeros-tests: New file, based on modules/stdbit-tests. * modules/stdc_count_ones-tests: New file, based on modules/stdbit-tests. * modules/stdc_has_single_bit-tests: New file, based on modules/stdbit-tests. * modules/stdc_bit_width-tests: New file, based on modules/stdbit-tests. * modules/stdc_bit_floor-tests: New file, based on modules/stdbit-tests. * modules/stdc_bit_ceil-tests: New file, based on modules/stdbit-tests. * modules/stdbit-tests: Remove file. * doc/posix-functions/stdc_leading_zeros.texi: Update. * doc/posix-functions/stdc_leading_ones.texi: Likewise. * doc/posix-functions/stdc_trailing_zeros.texi: Likewise. * doc/posix-functions/stdc_trailing_ones.texi: Likewise. * doc/posix-functions/stdc_first_leading_zero.texi: Likewise. * doc/posix-functions/stdc_first_leading_one.texi: Likewise. * doc/posix-functions/stdc_first_trailing_zero.texi: Likewise. * doc/posix-functions/stdc_first_trailing_one.texi: Likewise. * doc/posix-functions/stdc_count_zeros.texi: Likewise. * doc/posix-functions/stdc_count_ones.texi: Likewise. * doc/posix-functions/stdc_has_single_bit.texi: Likewise. * doc/posix-functions/stdc_bit_width.texi: Likewise. * doc/posix-functions/stdc_bit_floor.texi: Likewise. * doc/posix-functions/stdc_bit_ceil.texi: Likewise. --- ChangeLog | 80 ++++ doc/posix-functions/stdc_bit_ceil.texi | 2 +- doc/posix-functions/stdc_bit_floor.texi | 2 +- doc/posix-functions/stdc_bit_width.texi | 2 +- doc/posix-functions/stdc_count_ones.texi | 2 +- doc/posix-functions/stdc_count_zeros.texi | 2 +- .../stdc_first_leading_one.texi | 2 +- .../stdc_first_leading_zero.texi | 2 +- .../stdc_first_trailing_one.texi | 2 +- .../stdc_first_trailing_zero.texi | 2 +- doc/posix-functions/stdc_has_single_bit.texi | 2 +- doc/posix-functions/stdc_leading_ones.texi | 2 +- doc/posix-functions/stdc_leading_zeros.texi | 2 +- doc/posix-functions/stdc_trailing_ones.texi | 2 +- doc/posix-functions/stdc_trailing_zeros.texi | 2 +- lib/stdbit.c | 4 - lib/stdbit.in.h | 348 ++++++++++++------ lib/stdc_bit_ceil.c | 20 + lib/stdc_bit_floor.c | 20 + lib/stdc_bit_width.c | 20 + lib/stdc_count_ones.c | 24 ++ lib/stdc_count_zeros.c | 20 + lib/stdc_first_leading_one.c | 20 + lib/stdc_first_leading_zero.c | 20 + lib/stdc_first_trailing_one.c | 20 + lib/stdc_first_trailing_zero.c | 20 + lib/stdc_has_single_bit.c | 20 + lib/stdc_leading_ones.c | 20 + lib/stdc_leading_zeros.c | 20 + lib/stdc_trailing_ones.c | 20 + lib/stdc_trailing_zeros.c | 20 + m4/stdbit_h.m4 | 20 +- modules/stdbit | 40 +- modules/stdbit-h | 58 +++ modules/stdbit-tests | 86 ----- modules/stdc_bit_ceil | 28 ++ modules/stdc_bit_ceil-tests | 19 + modules/stdc_bit_floor | 28 ++ modules/stdc_bit_floor-tests | 19 + modules/stdc_bit_width | 29 ++ modules/stdc_bit_width-tests | 19 + modules/stdc_count_ones | 27 ++ modules/stdc_count_ones-tests | 19 + modules/stdc_count_zeros | 28 ++ modules/stdc_count_zeros-tests | 19 + modules/stdc_first_leading_one | 29 ++ modules/stdc_first_leading_one-tests | 19 + modules/stdc_first_leading_zero | 29 ++ modules/stdc_first_leading_zero-tests | 19 + modules/stdc_first_trailing_one | 29 ++ modules/stdc_first_trailing_one-tests | 19 + modules/stdc_first_trailing_zero | 29 ++ modules/stdc_first_trailing_zero-tests | 19 + modules/stdc_has_single_bit | 27 ++ modules/stdc_has_single_bit-tests | 19 + modules/stdc_leading_ones | 28 ++ modules/stdc_leading_ones-tests | 19 + modules/stdc_leading_zeros | 27 ++ modules/stdc_leading_zeros-tests | 19 + modules/stdc_trailing_ones | 28 ++ modules/stdc_trailing_ones-tests | 19 + modules/stdc_trailing_zeros | 27 ++ modules/stdc_trailing_zeros-tests | 19 + 63 files changed, 1372 insertions(+), 235 deletions(-) create mode 100644 lib/stdc_bit_ceil.c create mode 100644 lib/stdc_bit_floor.c create mode 100644 lib/stdc_bit_width.c create mode 100644 lib/stdc_count_ones.c create mode 100644 lib/stdc_count_zeros.c create mode 100644 lib/stdc_first_leading_one.c create mode 100644 lib/stdc_first_leading_zero.c create mode 100644 lib/stdc_first_trailing_one.c create mode 100644 lib/stdc_first_trailing_zero.c create mode 100644 lib/stdc_has_single_bit.c create mode 100644 lib/stdc_leading_ones.c create mode 100644 lib/stdc_leading_zeros.c create mode 100644 lib/stdc_trailing_ones.c create mode 100644 lib/stdc_trailing_zeros.c create mode 100644 modules/stdbit-h delete mode 100644 modules/stdbit-tests create mode 100644 modules/stdc_bit_ceil create mode 100644 modules/stdc_bit_ceil-tests create mode 100644 modules/stdc_bit_floor create mode 100644 modules/stdc_bit_floor-tests create mode 100644 modules/stdc_bit_width create mode 100644 modules/stdc_bit_width-tests create mode 100644 modules/stdc_count_ones create mode 100644 modules/stdc_count_ones-tests create mode 100644 modules/stdc_count_zeros create mode 100644 modules/stdc_count_zeros-tests create mode 100644 modules/stdc_first_leading_one create mode 100644 modules/stdc_first_leading_one-tests create mode 100644 modules/stdc_first_leading_zero create mode 100644 modules/stdc_first_leading_zero-tests create mode 100644 modules/stdc_first_trailing_one create mode 100644 modules/stdc_first_trailing_one-tests create mode 100644 modules/stdc_first_trailing_zero create mode 100644 modules/stdc_first_trailing_zero-tests create mode 100644 modules/stdc_has_single_bit create mode 100644 modules/stdc_has_single_bit-tests create mode 100644 modules/stdc_leading_ones create mode 100644 modules/stdc_leading_ones-tests create mode 100644 modules/stdc_leading_zeros create mode 100644 modules/stdc_leading_zeros-tests create mode 100644 modules/stdc_trailing_ones create mode 100644 modules/stdc_trailing_ones-tests create mode 100644 modules/stdc_trailing_zeros create mode 100644 modules/stdc_trailing_zeros-tests diff --git a/ChangeLog b/ChangeLog index 049f27b3b8..377dbe99bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,83 @@ +2024-05-15 Bruno Haible + + stdbit-h, stdc_*: New modules, part of the stdbit module. + * lib/stdbit.in.h (_GL_STDC_*_INLINE): New macros. + Enclose function definitions in #if @GL_STDC_*@ conditionals. + * lib/stdc_leading_zeros.c: New file. + * lib/stdc_leading_ones.c: New file. + * lib/stdc_trailing_zeros.c: New file. + * lib/stdc_trailing_ones.c: New file. + * lib/stdc_first_leading_zero.c: New file. + * lib/stdc_first_leading_one.c: New file. + * lib/stdc_first_trailing_zero.c: New file. + * lib/stdc_first_trailing_one.c: New file. + * lib/stdc_count_zeros.c: New file. + * lib/stdc_count_ones.c: New file, based on lib/stdbit.c. + * lib/stdc_has_single_bit.c: New file. + * lib/stdc_bit_width.c: New file. + * lib/stdc_bit_floor.c: New file. + * lib/stdc_bit_ceil.c: New file. + * lib/stdbit.c (__gl_stdbit_popcount_support): Remove variable. + * m4/stdbit_h.m4 (gl_STDBIT_H): Initialize GL_STDC_* variables. + * modules/stdbit-h: New file, based on modules/stdbit. + (Depends-on): Add gen-header. + (Makefile.am): Substitute GL_STDC_* variables. + * modules/stdc_leading_zeros: New file. + * modules/stdc_leading_ones: New file. + * modules/stdc_trailing_zeros: New file. + * modules/stdc_trailing_ones: New file. + * modules/stdc_first_leading_zero: New file. + * modules/stdc_first_leading_one: New file. + * modules/stdc_first_trailing_zero: New file. + * modules/stdc_first_trailing_one: New file. + * modules/stdc_count_zeros: New file. + * modules/stdc_count_ones: New file. + * modules/stdc_has_single_bit: New file. + * modules/stdc_bit_width: New file. + * modules/stdc_bit_floor: New file. + * modules/stdc_bit_ceil: New file. + * modules/stdbit: Change to a pure composition module. + * modules/stdc_leading_zeros-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_leading_ones-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_trailing_zeros-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_trailing_ones-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_first_leading_zero-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_first_leading_one-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_first_trailing_zero-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_first_trailing_one-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_count_zeros-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_count_ones-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_has_single_bit-tests: New file, based on + modules/stdbit-tests. + * modules/stdc_bit_width-tests: New file, based on modules/stdbit-tests. + * modules/stdc_bit_floor-tests: New file, based on modules/stdbit-tests. + * modules/stdc_bit_ceil-tests: New file, based on modules/stdbit-tests. + * modules/stdbit-tests: Remove file. + * doc/posix-functions/stdc_leading_zeros.texi: Update. + * doc/posix-functions/stdc_leading_ones.texi: Likewise. + * doc/posix-functions/stdc_trailing_zeros.texi: Likewise. + * doc/posix-functions/stdc_trailing_ones.texi: Likewise. + * doc/posix-functions/stdc_first_leading_zero.texi: Likewise. + * doc/posix-functions/stdc_first_leading_one.texi: Likewise. + * doc/posix-functions/stdc_first_trailing_zero.texi: Likewise. + * doc/posix-functions/stdc_first_trailing_one.texi: Likewise. + * doc/posix-functions/stdc_count_zeros.texi: Likewise. + * doc/posix-functions/stdc_count_ones.texi: Likewise. + * doc/posix-functions/stdc_has_single_bit.texi: Likewise. + * doc/posix-functions/stdc_bit_width.texi: Likewise. + * doc/posix-functions/stdc_bit_floor.texi: Likewise. + * doc/posix-functions/stdc_bit_ceil.texi: Likewise. + 2024-05-15 Paul Eggert stdbit: tweak first_leading for GCC diff --git a/doc/posix-functions/stdc_bit_ceil.texi b/doc/posix-functions/stdc_bit_ceil.texi index 5b636e6b02..31549dbd96 100644 --- a/doc/posix-functions/stdc_bit_ceil.texi +++ b/doc/posix-functions/stdc_bit_ceil.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.16. -Gnulib module: stdbit +Gnulib module: stdc_bit_ceil Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_bit_floor.texi b/doc/posix-functions/stdc_bit_floor.texi index 2600aa7b9a..0b811c99eb 100644 --- a/doc/posix-functions/stdc_bit_floor.texi +++ b/doc/posix-functions/stdc_bit_floor.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.15. -Gnulib module: stdbit +Gnulib module: stdc_bit_floor Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_bit_width.texi b/doc/posix-functions/stdc_bit_width.texi index d0bcb359f0..c2cbf083a5 100644 --- a/doc/posix-functions/stdc_bit_width.texi +++ b/doc/posix-functions/stdc_bit_width.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.14. -Gnulib module: stdbit +Gnulib module: stdc_bit_width Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_count_ones.texi b/doc/posix-functions/stdc_count_ones.texi index 17a0e520d8..2f1f292d1b 100644 --- a/doc/posix-functions/stdc_count_ones.texi +++ b/doc/posix-functions/stdc_count_ones.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.12. -Gnulib module: stdbit +Gnulib module: stdc_count_ones Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_count_zeros.texi b/doc/posix-functions/stdc_count_zeros.texi index 18867146e4..0f646292c7 100644 --- a/doc/posix-functions/stdc_count_zeros.texi +++ b/doc/posix-functions/stdc_count_zeros.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.11. -Gnulib module: stdbit +Gnulib module: stdc_count_zeros Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_first_leading_one.texi b/doc/posix-functions/stdc_first_leading_one.texi index f82cb2f940..e4f8f99b22 100644 --- a/doc/posix-functions/stdc_first_leading_one.texi +++ b/doc/posix-functions/stdc_first_leading_one.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.8. -Gnulib module: stdbit +Gnulib module: stdc_first_leading_one Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_first_leading_zero.texi b/doc/posix-functions/stdc_first_leading_zero.texi index 7509fea9ca..a09c44e53b 100644 --- a/doc/posix-functions/stdc_first_leading_zero.texi +++ b/doc/posix-functions/stdc_first_leading_zero.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.7. -Gnulib module: stdbit +Gnulib module: stdc_first_leading_zero Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_first_trailing_one.texi b/doc/posix-functions/stdc_first_trailing_one.texi index 8e0a4cb0b8..54bd578c2f 100644 --- a/doc/posix-functions/stdc_first_trailing_one.texi +++ b/doc/posix-functions/stdc_first_trailing_one.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.10. -Gnulib module: stdbit +Gnulib module: stdc_first_trailing_one Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_first_trailing_zero.texi b/doc/posix-functions/stdc_first_trailing_zero.texi index ffbd802034..82b270ad6e 100644 --- a/doc/posix-functions/stdc_first_trailing_zero.texi +++ b/doc/posix-functions/stdc_first_trailing_zero.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.9. -Gnulib module: stdbit +Gnulib module: stdc_first_trailing_zero Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_has_single_bit.texi b/doc/posix-functions/stdc_has_single_bit.texi index cbd57c7cb8..5f41766482 100644 --- a/doc/posix-functions/stdc_has_single_bit.texi +++ b/doc/posix-functions/stdc_has_single_bit.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.13. -Gnulib module: stdbit +Gnulib module: stdc_has_single_bit Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_leading_ones.texi b/doc/posix-functions/stdc_leading_ones.texi index f1115a2c8e..49a45d536d 100644 --- a/doc/posix-functions/stdc_leading_ones.texi +++ b/doc/posix-functions/stdc_leading_ones.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.4. -Gnulib module: stdbit +Gnulib module: stdc_leading_ones Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_leading_zeros.texi b/doc/posix-functions/stdc_leading_zeros.texi index 8caed8e07e..256b6533a4 100644 --- a/doc/posix-functions/stdc_leading_zeros.texi +++ b/doc/posix-functions/stdc_leading_zeros.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.3. -Gnulib module: stdbit +Gnulib module: stdc_leading_zeros Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_trailing_ones.texi b/doc/posix-functions/stdc_trailing_ones.texi index 14c36bca3e..a7a3fc111f 100644 --- a/doc/posix-functions/stdc_trailing_ones.texi +++ b/doc/posix-functions/stdc_trailing_ones.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.6. -Gnulib module: stdbit +Gnulib module: stdc_trailing_ones Portability problems fixed by Gnulib: @itemize diff --git a/doc/posix-functions/stdc_trailing_zeros.texi b/doc/posix-functions/stdc_trailing_zeros.texi index 60c4d5906a..fb4ae7d778 100644 --- a/doc/posix-functions/stdc_trailing_zeros.texi +++ b/doc/posix-functions/stdc_trailing_zeros.texi @@ -7,7 +7,7 @@ @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf}) section 7.18.5. -Gnulib module: stdbit +Gnulib module: stdc_trailing_zeros Portability problems fixed by Gnulib: @itemize diff --git a/lib/stdbit.c b/lib/stdbit.c index a9f0ef5074..4801e74d28 100644 --- a/lib/stdbit.c +++ b/lib/stdbit.c @@ -21,7 +21,3 @@ #define _GL_STDBIT_INLINE _GL_EXTERN_INLINE #include - -#if 1500 <= _MSC_VER && (defined _M_IX86 || defined _M_X64) -signed char __gl_stdbit_popcount_support; -#endif diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h index ab328a7793..73b234791d 100644 --- a/lib/stdbit.in.h +++ b/lib/stdbit.in.h @@ -26,9 +26,52 @@ #endif _GL_INLINE_HEADER_BEGIN + #ifndef _GL_STDBIT_INLINE # define _GL_STDBIT_INLINE _GL_INLINE #endif +#ifndef _GL_STDC_LEADING_ZEROS_INLINE +# define _GL_STDC_LEADING_ZEROS_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_LEADING_ONES_INLINE +# define _GL_STDC_LEADING_ONES_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_TRAILING_ZEROS_INLINE +# define _GL_STDC_TRAILING_ZEROS_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_TRAILING_ONES_INLINE +# define _GL_STDC_TRAILING_ONES_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_FIRST_LEADING_ZERO_INLINE +# define _GL_STDC_FIRST_LEADING_ZERO_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_FIRST_LEADING_ONE_INLINE +# define _GL_STDC_FIRST_LEADING_ONE_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_FIRST_TRAILING_ZERO_INLINE +# define _GL_STDC_FIRST_TRAILING_ZERO_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_FIRST_TRAILING_ONE_INLINE +# define _GL_STDC_FIRST_TRAILING_ONE_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_COUNT_ZEROS_INLINE +# define _GL_STDC_COUNT_ZEROS_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_COUNT_ONES_INLINE +# define _GL_STDC_COUNT_ONES_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_HAS_SINGLE_BIT_INLINE +# define _GL_STDC_HAS_SINGLE_BIT_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_BIT_WIDTH_INLINE +# define _GL_STDC_BIT_WIDTH_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_BIT_FLOOR_INLINE +# define _GL_STDC_BIT_FLOOR_INLINE _GL_INLINE +#endif +#ifndef _GL_STDC_BIT_CEIL_INLINE +# define _GL_STDC_BIT_CEIL_INLINE _GL_INLINE +#endif #ifdef __cplusplus extern "C" { @@ -49,8 +92,14 @@ extern "C" { # define _GL_STDBIT_TYPEOF_CAST(a, b) (b) #endif + +/* ISO C 23 § 7.18.1 General */ + #define __STDC_VERSION_STDBIT_H__ 202311L + +/* ISO C 23 § 7.18.2 Endian */ + #define __STDC_ENDIAN_BIG__ 4321 #define __STDC_ENDIAN_LITTLE__ 1234 #ifdef WORDS_BIGENDIAN @@ -59,6 +108,7 @@ extern "C" { # define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_LITTLE__ #endif + #ifdef __cplusplus extern "C" { #endif @@ -223,13 +273,14 @@ __gl_stdbit_ctzll (unsigned long long int n) } #endif +#if @GL_STDC_COUNT_ONES@ /* 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 -_GL_STDBIT_INLINE int +# 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) { if (sizeof n & (sizeof n - 1)) @@ -276,25 +327,25 @@ __gl_stdbit_popcount_wide (unsigned long long int n) } } -# ifdef _MSC_VER -# if 1500 <= _MSC_VER && (defined _M_IX86 || defined _M_X64) -# pragma intrinsic (__cpuid) -# pragma intrinsic (__popcnt) -# ifdef _M_X64 -# pragma intrinsic (__popcnt64) -# else -_GL_STDBIT_INLINE int +# ifdef _MSC_VER +# if 1500 <= _MSC_VER && (defined _M_IX86 || defined _M_X64) +# pragma intrinsic (__cpuid) +# pragma intrinsic (__popcnt) +# ifdef _M_X64 +# 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; -_GL_STDBIT_INLINE bool +_GL_STDC_COUNT_ONES_INLINE bool __gl_stdbit_popcount_supported (void) { if (!__gl_stdbit_popcount_support) @@ -309,188 +360,217 @@ __gl_stdbit_popcount_supported (void) } return 0 < __gl_stdbit_popcount_support; } -_GL_STDBIT_INLINE int +_GL_STDC_COUNT_ONES_INLINE int __gl_stdbit_popcount (unsigned int n) { return (__gl_stdbit_popcount_supported () ? __popcnt (n) : __gl_stdbit_popcount_wide (n)); } -_GL_STDBIT_INLINE int +_GL_STDC_COUNT_ONES_INLINE int __gl_stdbit_popcountl (unsigned long int n) { return (__gl_stdbit_popcount_supported () ? __popcnt (n) : __gl_stdbit_popcount_wide (n)); } -_GL_STDBIT_INLINE int +_GL_STDC_COUNT_ONES_INLINE int __gl_stdbit_popcountll (unsigned long long int n) { return (__gl_stdbit_popcount_supported () ? __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 #endif -_GL_STDBIT_INLINE unsigned int +/* ISO C 23 § 7.18.3 Count Leading Zeros */ + +#if @GL_STDC_LEADING_ZEROS@ + +_GL_STDC_LEADING_ZEROS_INLINE unsigned int stdc_leading_zeros_ui (unsigned int n) { return __gl_stdbit_clz (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_LEADING_ZEROS_INLINE unsigned int stdc_leading_zeros_uc (unsigned char n) { return stdc_leading_zeros_ui (n) - 8 * (sizeof 0u - sizeof n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_LEADING_ZEROS_INLINE unsigned int stdc_leading_zeros_us (unsigned short int n) { return stdc_leading_zeros_ui (n) - 8 * (sizeof 0u - sizeof n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_LEADING_ZEROS_INLINE unsigned int stdc_leading_zeros_ul (unsigned long int n) { return __gl_stdbit_clzl (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_LEADING_ZEROS_INLINE unsigned int stdc_leading_zeros_ull (unsigned long long int n) { return __gl_stdbit_clzll (n); } -#define stdc_leading_zeros(n) \ +# define stdc_leading_zeros(n) \ (sizeof (n) == 1 ? stdc_leading_zeros_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_leading_zeros_us (n) \ : sizeof (n) == sizeof 0u ? stdc_leading_zeros_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_leading_zeros_ul (n) \ : stdc_leading_zeros_ull (n)) +#endif + -_GL_STDBIT_INLINE unsigned int +/* ISO C 23 § 7.18.4 Count Leading Ones */ + +#if @GL_STDC_LEADING_ONES@ + +_GL_STDC_LEADING_ONES_INLINE unsigned int stdc_leading_ones_uc (unsigned char n) { return stdc_leading_zeros_uc (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_LEADING_ONES_INLINE unsigned int stdc_leading_ones_us (unsigned short int n) { return stdc_leading_zeros_us (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_LEADING_ONES_INLINE unsigned int stdc_leading_ones_ui (unsigned int n) { return stdc_leading_zeros_ui (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_LEADING_ONES_INLINE unsigned int stdc_leading_ones_ul (unsigned long int n) { return stdc_leading_zeros_ul (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_LEADING_ONES_INLINE unsigned int stdc_leading_ones_ull (unsigned long long int n) { return stdc_leading_zeros_ull (~n); } -#define stdc_leading_ones(n) \ +# define stdc_leading_ones(n) \ (sizeof (n) == 1 ? stdc_leading_ones_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_leading_ones_us (n) \ : sizeof (n) == sizeof 0u ? stdc_leading_ones_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_leading_ones_ul (n) \ : stdc_leading_ones_ull (n)) +#endif + + +/* ISO C 23 § 7.18.5 Count Trailing Zeros */ -_GL_STDBIT_INLINE unsigned int +#if @GL_STDC_TRAILING_ZEROS@ + +_GL_STDC_TRAILING_ZEROS_INLINE unsigned int stdc_trailing_zeros_ui (unsigned int n) { return __gl_stdbit_ctz (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_TRAILING_ZEROS_INLINE unsigned int stdc_trailing_zeros_uc (unsigned char n) { return stdc_trailing_zeros_ui (n | (1 + (unsigned char) -1)); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_TRAILING_ZEROS_INLINE unsigned int stdc_trailing_zeros_us (unsigned short int n) { return stdc_trailing_zeros_ui (n | (1 + (unsigned short int) -1)); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_TRAILING_ZEROS_INLINE unsigned int stdc_trailing_zeros_ul (unsigned long int n) { return __gl_stdbit_ctzl (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_TRAILING_ZEROS_INLINE unsigned int stdc_trailing_zeros_ull (unsigned long long int n) { return __gl_stdbit_ctzll (n); } -#define stdc_trailing_zeros(n) \ +# define stdc_trailing_zeros(n) \ (sizeof (n) == 1 ? stdc_trailing_zeros_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_trailing_zeros_us (n) \ : sizeof (n) == sizeof 0u ? stdc_trailing_zeros_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_trailing_zeros_ul (n) \ : stdc_trailing_zeros_ull (n)) +#endif + + +/* ISO C 23 § 7.18.6 Count Trailing Ones */ + +#if @GL_STDC_TRAILING_ONES@ -_GL_STDBIT_INLINE unsigned int +_GL_STDC_TRAILING_ONES_INLINE unsigned int stdc_trailing_ones_uc (unsigned char n) { return stdc_trailing_zeros_uc (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_TRAILING_ONES_INLINE unsigned int stdc_trailing_ones_us (unsigned short int n) { return stdc_trailing_zeros_us (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_TRAILING_ONES_INLINE unsigned int stdc_trailing_ones_ui (unsigned int n) { return stdc_trailing_zeros_ui (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_TRAILING_ONES_INLINE unsigned int stdc_trailing_ones_ul (unsigned long int n) { return stdc_trailing_zeros_ul (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_TRAILING_ONES_INLINE unsigned int stdc_trailing_ones_ull (unsigned long long int n) { return stdc_trailing_zeros_ull (~n); } -#define stdc_trailing_ones(n) \ +# define stdc_trailing_ones(n) \ (sizeof (n) == 1 ? stdc_trailing_ones_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_trailing_ones_us (n) \ : sizeof (n) == sizeof 0u ? stdc_trailing_ones_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_trailing_ones_ul (n) \ : stdc_trailing_ones_ull (n)) +#endif + + +/* ISO C 23 § 7.18.7 First Leading Zero */ -_GL_STDBIT_INLINE unsigned int +#if @GL_STDC_FIRST_LEADING_ZERO@ + +_GL_STDC_FIRST_LEADING_ZERO_INLINE unsigned int stdc_first_leading_zero_uc (unsigned char n) { unsigned int count = stdc_leading_ones_uc (n); @@ -498,7 +578,7 @@ stdc_first_leading_zero_uc (unsigned char n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_LEADING_ZERO_INLINE unsigned int stdc_first_leading_zero_us (unsigned short int n) { unsigned int count = stdc_leading_ones_us (n); @@ -506,7 +586,7 @@ stdc_first_leading_zero_us (unsigned short int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_LEADING_ZERO_INLINE unsigned int stdc_first_leading_zero_ui (unsigned int n) { unsigned int count = stdc_leading_ones_ui (n); @@ -514,7 +594,7 @@ stdc_first_leading_zero_ui (unsigned int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_LEADING_ZERO_INLINE unsigned int stdc_first_leading_zero_ul (unsigned long int n) { unsigned int count = stdc_leading_ones_ul (n); @@ -522,7 +602,7 @@ stdc_first_leading_zero_ul (unsigned long int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_LEADING_ZERO_INLINE unsigned int stdc_first_leading_zero_ull (unsigned long long int n) { unsigned int count = stdc_leading_ones_ull (n); @@ -530,15 +610,21 @@ stdc_first_leading_zero_ull (unsigned long long int n) return count % bits + (count < bits); } -#define stdc_first_leading_zero(n) \ +# 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) \ : sizeof (n) == sizeof 0u ? stdc_first_leading_zero_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_first_leading_zero_ul (n) \ : stdc_first_leading_zero_ull (n)) +#endif + -_GL_STDBIT_INLINE unsigned int +/* ISO C 23 § 7.18.8 First Leading One */ + +#if @GL_STDC_FIRST_LEADING_ONE@ + +_GL_STDC_FIRST_LEADING_ONE_INLINE unsigned int stdc_first_leading_one_uc (unsigned char n) { unsigned int count = stdc_leading_zeros_uc (n); @@ -546,7 +632,7 @@ stdc_first_leading_one_uc (unsigned char n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_LEADING_ONE_INLINE unsigned int stdc_first_leading_one_us (unsigned short int n) { unsigned int count = stdc_leading_zeros_us (n); @@ -554,7 +640,7 @@ stdc_first_leading_one_us (unsigned short int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_LEADING_ONE_INLINE unsigned int stdc_first_leading_one_ui (unsigned int n) { unsigned int count = stdc_leading_zeros_ui (n); @@ -562,7 +648,7 @@ stdc_first_leading_one_ui (unsigned int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_LEADING_ONE_INLINE unsigned int stdc_first_leading_one_ul (unsigned long int n) { unsigned int count = stdc_leading_zeros_ul (n); @@ -570,7 +656,7 @@ stdc_first_leading_one_ul (unsigned long int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_LEADING_ONE_INLINE unsigned int stdc_first_leading_one_ull (unsigned long long int n) { unsigned int count = stdc_leading_zeros_ull (n); @@ -578,15 +664,21 @@ stdc_first_leading_one_ull (unsigned long long int n) return count % bits + (count < bits); } -#define stdc_first_leading_one(n) \ +# 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) \ : sizeof (n) == sizeof 0u ? stdc_first_leading_one_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_first_leading_one_ul (n) \ : stdc_first_leading_one_ull (n)) +#endif + + +/* ISO C 23 § 7.18.9 First Trailing Zero */ -_GL_STDBIT_INLINE unsigned int +#if @GL_STDC_FIRST_TRAILING_ZERO@ + +_GL_STDC_FIRST_TRAILING_ZERO_INLINE unsigned int stdc_first_trailing_zero_uc (unsigned char n) { unsigned int count = stdc_trailing_ones_uc (n); @@ -594,7 +686,7 @@ stdc_first_trailing_zero_uc (unsigned char n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_TRAILING_ZERO_INLINE unsigned int stdc_first_trailing_zero_us (unsigned short int n) { unsigned int count = stdc_trailing_ones_us (n); @@ -602,7 +694,7 @@ stdc_first_trailing_zero_us (unsigned short int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_TRAILING_ZERO_INLINE unsigned int stdc_first_trailing_zero_ui (unsigned int n) { unsigned int count = stdc_trailing_ones_ui (n); @@ -610,7 +702,7 @@ stdc_first_trailing_zero_ui (unsigned int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_TRAILING_ZERO_INLINE unsigned int stdc_first_trailing_zero_ul (unsigned long int n) { unsigned int count = stdc_trailing_ones_ul (n); @@ -618,7 +710,7 @@ stdc_first_trailing_zero_ul (unsigned long int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_TRAILING_ZERO_INLINE unsigned int stdc_first_trailing_zero_ull (unsigned long long int n) { unsigned int count = stdc_trailing_ones_ull (n); @@ -626,15 +718,21 @@ stdc_first_trailing_zero_ull (unsigned long long int n) return count % bits + (count < bits); } -#define stdc_first_trailing_zero(n) \ +# 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) \ : sizeof (n) == sizeof 0u ? stdc_first_trailing_zero_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_first_trailing_zero_ul (n) \ : stdc_first_trailing_zero_ull (n)) +#endif + + +/* ISO C 23 § 7.18.10 First Trailing One */ + +#if @GL_STDC_FIRST_TRAILING_ONE@ -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_TRAILING_ONE_INLINE unsigned int stdc_first_trailing_one_uc (unsigned char n) { unsigned int count = stdc_trailing_zeros_uc (n); @@ -642,7 +740,7 @@ stdc_first_trailing_one_uc (unsigned char n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_TRAILING_ONE_INLINE unsigned int stdc_first_trailing_one_us (unsigned short int n) { unsigned int count = stdc_trailing_zeros_us (n); @@ -650,7 +748,7 @@ stdc_first_trailing_one_us (unsigned short int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_TRAILING_ONE_INLINE unsigned int stdc_first_trailing_one_ui (unsigned int n) { unsigned int count = stdc_trailing_zeros_ui (n); @@ -658,7 +756,7 @@ stdc_first_trailing_one_ui (unsigned int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_TRAILING_ONE_INLINE unsigned int stdc_first_trailing_one_ul (unsigned long int n) { unsigned int count = stdc_trailing_zeros_ul (n); @@ -666,7 +764,7 @@ stdc_first_trailing_one_ul (unsigned long int n) return count % bits + (count < bits); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_FIRST_TRAILING_ONE_INLINE unsigned int stdc_first_trailing_one_ull (unsigned long long int n) { unsigned int count = stdc_trailing_zeros_ull (n); @@ -681,119 +779,137 @@ stdc_first_trailing_one_ull (unsigned long long int n) : sizeof (n) == sizeof 0ul ? stdc_first_trailing_one_ul (n) \ : stdc_first_trailing_one_ull (n)) +#endif + + +/* ISO C 23 § 7.18.12 Count Ones */ -_GL_STDBIT_INLINE unsigned int +#if @GL_STDC_COUNT_ONES@ + +_GL_STDC_COUNT_ONES_INLINE unsigned int stdc_count_ones_ui (unsigned int n) { return __gl_stdbit_popcount (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_COUNT_ONES_INLINE unsigned int stdc_count_ones_uc (unsigned char n) { return stdc_count_ones_ui (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_COUNT_ONES_INLINE unsigned int stdc_count_ones_us (unsigned short int n) { return stdc_count_ones_ui (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_COUNT_ONES_INLINE unsigned int stdc_count_ones_ul (unsigned long int n) { return __gl_stdbit_popcountl (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_COUNT_ONES_INLINE unsigned int stdc_count_ones_ull (unsigned long long int n) { return __gl_stdbit_popcountll (n); } -#define stdc_count_ones(n) \ +# define stdc_count_ones(n) \ (sizeof (n) == 1 ? stdc_count_ones_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_count_ones_us (n) \ : sizeof (n) == sizeof 0u ? stdc_count_ones_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_count_ones_ul (n) \ : stdc_count_ones_ull (n)) +#endif + + +/* ISO C 23 § 7.18.11 Count Zeros */ + +#if @GL_STDC_COUNT_ZEROS@ -_GL_STDBIT_INLINE unsigned int +_GL_STDC_COUNT_ZEROS_INLINE unsigned int stdc_count_zeros_uc (unsigned char n) { return stdc_count_ones_uc (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_COUNT_ZEROS_INLINE unsigned int stdc_count_zeros_us (unsigned short int n) { return stdc_count_ones_us (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_COUNT_ZEROS_INLINE unsigned int stdc_count_zeros_ui (unsigned int n) { return stdc_count_ones_ui (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_COUNT_ZEROS_INLINE unsigned int stdc_count_zeros_ul (unsigned long int n) { return stdc_count_ones_ul (~n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_COUNT_ZEROS_INLINE unsigned int stdc_count_zeros_ull (unsigned long long int n) { return stdc_count_ones_ull (~n); } -#define stdc_count_zeros(n) \ +# define stdc_count_zeros(n) \ (sizeof (n) == 1 ? stdc_count_zeros_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_count_zeros_us (n) \ : sizeof (n) == sizeof 0u ? stdc_count_zeros_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_count_zeros_ul (n) \ : stdc_count_zeros_ull (n)) +#endif + + +/* ISO C 23 § 7.18.13 Single-bit Check */ -_GL_STDBIT_INLINE bool +#if @GL_STDC_HAS_SINGLE_BIT@ + +_GL_STDC_HAS_SINGLE_BIT_INLINE bool stdc_has_single_bit_uc (unsigned char n) { unsigned char n_1 = n - 1, nx = n_1 ^ n; return n_1 < nx; } -_GL_STDBIT_INLINE bool +_GL_STDC_HAS_SINGLE_BIT_INLINE bool stdc_has_single_bit_us (unsigned short int n) { unsigned short int n_1 = n - 1, nx = n_1 ^ n; return n_1 < nx; } -_GL_STDBIT_INLINE bool +_GL_STDC_HAS_SINGLE_BIT_INLINE bool stdc_has_single_bit_ui (unsigned int n) { unsigned int n_1 = n - 1, nx = n_1 ^ n; return n_1 < nx; } -_GL_STDBIT_INLINE bool +_GL_STDC_HAS_SINGLE_BIT_INLINE bool stdc_has_single_bit_ul (unsigned long int n) { unsigned long int n_1 = n - 1, nx = n_1 ^ n; return n_1 < nx; } -_GL_STDBIT_INLINE bool +_GL_STDC_HAS_SINGLE_BIT_INLINE bool stdc_has_single_bit_ull (unsigned long long int n) { unsigned long long int n_1 = n - 1, nx = n_1 ^ n; return n_1 < nx; } -#define stdc_has_single_bit(n) \ +# define stdc_has_single_bit(n) \ ((bool) \ (sizeof (n) == 1 ? stdc_has_single_bit_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_has_single_bit_us (n) \ @@ -801,76 +917,88 @@ stdc_has_single_bit_ull (unsigned long long int n) : sizeof (n) == sizeof 0ul ? stdc_has_single_bit_ul (n) \ : stdc_has_single_bit_ull (n))) +#endif + + +/* ISO C 23 § 7.18.14 Bit Width */ + +#if @GL_STDC_BIT_WIDTH@ -_GL_STDBIT_INLINE unsigned int +_GL_STDC_BIT_WIDTH_INLINE unsigned int stdc_bit_width_uc (unsigned char n) { return 8 * sizeof n - stdc_leading_zeros_uc (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_BIT_WIDTH_INLINE unsigned int stdc_bit_width_us (unsigned short int n) { return 8 * sizeof n - stdc_leading_zeros_us (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_BIT_WIDTH_INLINE unsigned int stdc_bit_width_ui (unsigned int n) { return 8 * sizeof n - stdc_leading_zeros_ui (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_BIT_WIDTH_INLINE unsigned int stdc_bit_width_ul (unsigned long int n) { return 8 * sizeof n - stdc_leading_zeros_ul (n); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_BIT_WIDTH_INLINE unsigned int stdc_bit_width_ull (unsigned long long int n) { return 8 * sizeof n - stdc_leading_zeros_ull (n); } -#define stdc_bit_width(n) \ +# define stdc_bit_width(n) \ (sizeof (n) == 1 ? stdc_bit_width_uc (n) \ : sizeof (n) == sizeof (unsigned short int) ? stdc_bit_width_us (n) \ : sizeof (n) == sizeof 0u ? stdc_bit_width_ui (n) \ : sizeof (n) == sizeof 0ul ? stdc_bit_width_ul (n) \ : stdc_bit_width_ull (n)) +#endif + + +/* ISO C 23 § 7.18.15 Bit Floor */ -_GL_STDBIT_INLINE unsigned char +#if @GL_STDC_BIT_FLOOR@ + +_GL_STDC_BIT_FLOOR_INLINE unsigned char stdc_bit_floor_uc (unsigned char n) { return n ? 1u << (stdc_bit_width_uc (n) - 1) : 0; } -_GL_STDBIT_INLINE unsigned short int +_GL_STDC_BIT_FLOOR_INLINE unsigned short int stdc_bit_floor_us (unsigned short int n) { return n ? 1u << (stdc_bit_width_us (n) - 1) : 0; } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_BIT_FLOOR_INLINE unsigned int stdc_bit_floor_ui (unsigned int n) { return n ? 1u << (stdc_bit_width_ui (n) - 1) : 0; } -_GL_STDBIT_INLINE unsigned long int +_GL_STDC_BIT_FLOOR_INLINE unsigned long int stdc_bit_floor_ul (unsigned long int n) { return n ? 1ul << (stdc_bit_width_ul (n) - 1) : 0; } -_GL_STDBIT_INLINE unsigned long long int +_GL_STDC_BIT_FLOOR_INLINE unsigned long long int stdc_bit_floor_ull (unsigned long long int n) { return n ? 1ull << (stdc_bit_width_ull (n) - 1) : 0; } -#define stdc_bit_floor(n) \ +# define stdc_bit_floor(n) \ (_GL_STDBIT_TYPEOF_CAST \ (n, \ (sizeof (n) == 1 ? stdc_bit_floor_uc (n) \ @@ -879,38 +1007,44 @@ stdc_bit_floor_ull (unsigned long long int n) : sizeof (n) == sizeof 0ul ? stdc_bit_floor_ul (n) \ : stdc_bit_floor_ull (n)))) +#endif + + +/* ISO C 23 § 7.18.16 Bit Ceiling */ + +#if @GL_STDC_BIT_CEIL@ -_GL_STDBIT_INLINE unsigned char +_GL_STDC_BIT_CEIL_INLINE unsigned char stdc_bit_ceil_uc (unsigned char n) { return n <= 1 ? 1 : 2u << (stdc_bit_width_uc (n - 1) - 1); } -_GL_STDBIT_INLINE unsigned short int +_GL_STDC_BIT_CEIL_INLINE unsigned short int stdc_bit_ceil_us (unsigned short int n) { return n <= 1 ? 1 : 2u << (stdc_bit_width_us (n - 1) - 1); } -_GL_STDBIT_INLINE unsigned int +_GL_STDC_BIT_CEIL_INLINE unsigned int stdc_bit_ceil_ui (unsigned int n) { return n <= 1 ? 1 : 2u << (stdc_bit_width_ui (n - 1) - 1); } -_GL_STDBIT_INLINE unsigned long int +_GL_STDC_BIT_CEIL_INLINE unsigned long int stdc_bit_ceil_ul (unsigned long int n) { return n <= 1 ? 1 : 2ul << (stdc_bit_width_ul (n - 1) - 1); } -_GL_STDBIT_INLINE unsigned long long int +_GL_STDC_BIT_CEIL_INLINE unsigned long long int stdc_bit_ceil_ull (unsigned long long int n) { return n <= 1 ? 1 : 2ull << (stdc_bit_width_ull (n - 1) - 1); } -#define stdc_bit_ceil(n) \ +# define stdc_bit_ceil(n) \ (_GL_STDBIT_TYPEOF_CAST \ (n, \ (sizeof (n) == 1 ? stdc_bit_ceil_uc (n) \ @@ -919,6 +1053,8 @@ stdc_bit_ceil_ull (unsigned long long int n) : sizeof (n) == sizeof 0ul ? stdc_bit_ceil_ul (n) \ : stdc_bit_ceil_ull (n)))) +#endif + #ifdef __cplusplus } diff --git a/lib/stdc_bit_ceil.c b/lib/stdc_bit_ceil.c new file mode 100644 index 0000000000..4a2ddb24e3 --- /dev/null +++ b/lib/stdc_bit_ceil.c @@ -0,0 +1,20 @@ +/* stdc_bit_ceil_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_BIT_CEIL_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_bit_floor.c b/lib/stdc_bit_floor.c new file mode 100644 index 0000000000..27fc5b925d --- /dev/null +++ b/lib/stdc_bit_floor.c @@ -0,0 +1,20 @@ +/* stdc_bit_floor_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_BIT_FLOOR_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_bit_width.c b/lib/stdc_bit_width.c new file mode 100644 index 0000000000..a0dc8de3b5 --- /dev/null +++ b/lib/stdc_bit_width.c @@ -0,0 +1,20 @@ +/* stdc_bit_width_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_BIT_WIDTH_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_count_ones.c b/lib/stdc_count_ones.c new file mode 100644 index 0000000000..7421178adf --- /dev/null +++ b/lib/stdc_count_ones.c @@ -0,0 +1,24 @@ +/* stdc_count_ones_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_COUNT_ONES_INLINE _GL_EXTERN_INLINE +#include + +#if 1500 <= _MSC_VER && (defined _M_IX86 || defined _M_X64) +signed char __gl_stdbit_popcount_support; +#endif diff --git a/lib/stdc_count_zeros.c b/lib/stdc_count_zeros.c new file mode 100644 index 0000000000..c164d9fe10 --- /dev/null +++ b/lib/stdc_count_zeros.c @@ -0,0 +1,20 @@ +/* stdc_count_zeros_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_COUNT_ZEROS_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_first_leading_one.c b/lib/stdc_first_leading_one.c new file mode 100644 index 0000000000..9a2ab1c518 --- /dev/null +++ b/lib/stdc_first_leading_one.c @@ -0,0 +1,20 @@ +/* stdc_first_leading_one_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_FIRST_LEADING_ONE_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_first_leading_zero.c b/lib/stdc_first_leading_zero.c new file mode 100644 index 0000000000..d9a18d1207 --- /dev/null +++ b/lib/stdc_first_leading_zero.c @@ -0,0 +1,20 @@ +/* stdc_first_leading_zero_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_FIRST_LEADING_ZERO_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_first_trailing_one.c b/lib/stdc_first_trailing_one.c new file mode 100644 index 0000000000..9162349c83 --- /dev/null +++ b/lib/stdc_first_trailing_one.c @@ -0,0 +1,20 @@ +/* stdc_first_trailing_one_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_FIRST_TRAILING_ONE_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_first_trailing_zero.c b/lib/stdc_first_trailing_zero.c new file mode 100644 index 0000000000..a8e12a3254 --- /dev/null +++ b/lib/stdc_first_trailing_zero.c @@ -0,0 +1,20 @@ +/* stdc_first_trailing_zero_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_FIRST_TRAILING_ZERO_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_has_single_bit.c b/lib/stdc_has_single_bit.c new file mode 100644 index 0000000000..68ef33b187 --- /dev/null +++ b/lib/stdc_has_single_bit.c @@ -0,0 +1,20 @@ +/* stdc_has_single_bit_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_HAS_SINGLE_BIT_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_leading_ones.c b/lib/stdc_leading_ones.c new file mode 100644 index 0000000000..1f2e615eb7 --- /dev/null +++ b/lib/stdc_leading_ones.c @@ -0,0 +1,20 @@ +/* stdc_leading_ones_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_LEADING_ONES_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_leading_zeros.c b/lib/stdc_leading_zeros.c new file mode 100644 index 0000000000..45695e51aa --- /dev/null +++ b/lib/stdc_leading_zeros.c @@ -0,0 +1,20 @@ +/* stdc_leading_zeros_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_LEADING_ZEROS_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_trailing_ones.c b/lib/stdc_trailing_ones.c new file mode 100644 index 0000000000..4a39cf0ad2 --- /dev/null +++ b/lib/stdc_trailing_ones.c @@ -0,0 +1,20 @@ +/* stdc_trailing_ones_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_TRAILING_ONES_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdc_trailing_zeros.c b/lib/stdc_trailing_zeros.c new file mode 100644 index 0000000000..f4bc43ac6b --- /dev/null +++ b/lib/stdc_trailing_zeros.c @@ -0,0 +1,20 @@ +/* stdc_trailing_zeros_* functions. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDC_TRAILING_ZEROS_INLINE _GL_EXTERN_INLINE +#include diff --git a/m4/stdbit_h.m4 b/m4/stdbit_h.m4 index 3c07bdc669..6af813f39d 100644 --- a/m4/stdbit_h.m4 +++ b/m4/stdbit_h.m4 @@ -1,5 +1,5 @@ # stdbit_h.m4 -# serial 1 +# serial 2 dnl Copyright 2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,10 +10,28 @@ AC_DEFUN_ONCE([gl_STDBIT_H], [ AC_REQUIRE([gl_BIGENDIAN]) + AC_CHECK_HEADERS_ONCE([stdbit.h]) if test $ac_cv_header_stdbit_h = yes; then GL_GENERATE_STDBIT_H=false else GL_GENERATE_STDBIT_H=true fi + + dnl We don't use gl_MODULE_INDICATOR_INIT_VARIABLE here, because stdbit.in.h + dnl does not use #include_next. + GL_STDC_LEADING_ZEROS=0; AC_SUBST([GL_STDC_LEADING_ZEROS]) + GL_STDC_LEADING_ONES=0; AC_SUBST([GL_STDC_LEADING_ONES]) + GL_STDC_TRAILING_ZEROS=0; AC_SUBST([GL_STDC_TRAILING_ZEROS]) + GL_STDC_TRAILING_ONES=0; AC_SUBST([GL_STDC_TRAILING_ONES]) + GL_STDC_FIRST_LEADING_ZERO=0; AC_SUBST([GL_STDC_FIRST_LEADING_ZERO]) + GL_STDC_FIRST_LEADING_ONE=0; AC_SUBST([GL_STDC_FIRST_LEADING_ONE]) + GL_STDC_FIRST_TRAILING_ZERO=0; AC_SUBST([GL_STDC_FIRST_TRAILING_ZERO]) + GL_STDC_FIRST_TRAILING_ONE=0; AC_SUBST([GL_STDC_FIRST_TRAILING_ONE]) + GL_STDC_COUNT_ZEROS=0; AC_SUBST([GL_STDC_COUNT_ZEROS]) + GL_STDC_COUNT_ONES=0; AC_SUBST([GL_STDC_COUNT_ONES]) + GL_STDC_HAS_SINGLE_BIT=0; AC_SUBST([GL_STDC_HAS_SINGLE_BIT]) + GL_STDC_BIT_WIDTH=0; AC_SUBST([GL_STDC_BIT_WIDTH]) + GL_STDC_BIT_FLOOR=0; AC_SUBST([GL_STDC_BIT_FLOOR]) + GL_STDC_BIT_CEIL=0; AC_SUBST([GL_STDC_BIT_CEIL]) ]) diff --git a/modules/stdbit b/modules/stdbit index b428650803..e2ddabac56 100644 --- a/modules/stdbit +++ b/modules/stdbit @@ -1,36 +1,28 @@ Description: -A stdbit.h that is like C23. +A that is like C23. Files: -lib/stdbit.c -lib/stdbit.in.h -m4/stdbit_h.m4 Depends-on: -extern-inline [$GL_GENERATE_STDBIT_H] -stdbool [$GL_GENERATE_STDBIT_H] +stdbit-h +stdc_leading_zeros +stdc_leading_ones +stdc_trailing_zeros +stdc_trailing_ones +stdc_first_leading_zero +stdc_first_leading_one +stdc_first_trailing_zero +stdc_first_trailing_one +stdc_count_zeros +stdc_count_ones +stdc_has_single_bit +stdc_bit_width +stdc_bit_floor +stdc_bit_ceil configure.ac: -gl_STDBIT_H -gl_CONDITIONAL_HEADER([stdbit.h]) -AC_PROG_MKDIR_P Makefile.am: -BUILT_SOURCES += $(STDBIT_H) - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -if GL_GENERATE_STDBIT_H -stdbit.h: stdbit.in.h $(top_builddir)/config.status -@NMD@ $(AM_V_GEN)$(MKDIR_P) '%reldir%' - $(gl_V_at)cp $(srcdir)/stdbit.in.h $@-t - $(AM_V_at)mv $@-t $@ -lib_SOURCES += stdbit.c -else -stdbit.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stdbit.h stdbit.h-t Include: diff --git a/modules/stdbit-h b/modules/stdbit-h new file mode 100644 index 0000000000..ddf1770ef8 --- /dev/null +++ b/modules/stdbit-h @@ -0,0 +1,58 @@ +Description: +A for platforms that lack it. + +Files: +lib/stdbit.in.h +lib/stdbit.c +m4/stdbit_h.m4 + +Depends-on: +gen-header +extern-inline [$GL_GENERATE_STDBIT_H] +stdbool [$GL_GENERATE_STDBIT_H] + +configure.ac: +gl_STDBIT_H +gl_CONDITIONAL_HEADER([stdbit.h]) +AC_PROG_MKDIR_P + +Makefile.am: +BUILT_SOURCES += $(STDBIT_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +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/@''GL_STDC_LEADING_ZEROS''@/$(GL_STDC_LEADING_ZEROS)/g' \ + -e 's/@''GL_STDC_LEADING_ONES''@/$(GL_STDC_LEADING_ONES)/g' \ + -e 's/@''GL_STDC_TRAILING_ZEROS''@/$(GL_STDC_TRAILING_ZEROS)/g' \ + -e 's/@''GL_STDC_TRAILING_ONES''@/$(GL_STDC_TRAILING_ONES)/g' \ + -e 's/@''GL_STDC_FIRST_LEADING_ZERO''@/$(GL_STDC_FIRST_LEADING_ZERO)/g' \ + -e 's/@''GL_STDC_FIRST_LEADING_ONE''@/$(GL_STDC_FIRST_LEADING_ONE)/g' \ + -e 's/@''GL_STDC_FIRST_TRAILING_ZERO''@/$(GL_STDC_FIRST_TRAILING_ZERO)/g' \ + -e 's/@''GL_STDC_FIRST_TRAILING_ONE''@/$(GL_STDC_FIRST_TRAILING_ONE)/g' \ + -e 's/@''GL_STDC_COUNT_ZEROS''@/$(GL_STDC_COUNT_ZEROS)/g' \ + -e 's/@''GL_STDC_COUNT_ONES''@/$(GL_STDC_COUNT_ONES)/g' \ + -e 's/@''GL_STDC_HAS_SINGLE_BIT''@/$(GL_STDC_HAS_SINGLE_BIT)/g' \ + -e 's/@''GL_STDC_BIT_WIDTH''@/$(GL_STDC_BIT_WIDTH)/g' \ + -e 's/@''GL_STDC_BIT_FLOOR''@/$(GL_STDC_BIT_FLOOR)/g' \ + -e 's/@''GL_STDC_BIT_CEIL''@/$(GL_STDC_BIT_CEIL)/g' \ + $(srcdir)/stdbit.in.h > $@-t + $(AM_V_at)mv $@-t $@ +lib_SOURCES += stdbit.c +else +stdbit.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stdbit.h stdbit.h-t + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdbit-tests b/modules/stdbit-tests deleted file mode 100644 index 15386befba..0000000000 --- a/modules/stdbit-tests +++ /dev/null @@ -1,86 +0,0 @@ -Files: -tests/macros.h -tests/from-glibc/support/test-driver.c -tests/from-glibc/tst-stdbit.h -tests/from-glibc/tst-stdc_bit_ceil.c -tests/from-glibc/tst-stdc_bit_floor.c -tests/from-glibc/tst-stdc_bit_width.c -tests/from-glibc/tst-stdc_count_ones.c -tests/from-glibc/tst-stdc_count_zeros.c -tests/from-glibc/tst-stdc_first_leading_one.c -tests/from-glibc/tst-stdc_first_leading_zero.c -tests/from-glibc/tst-stdc_first_trailing_one.c -tests/from-glibc/tst-stdc_first_trailing_zero.c -tests/from-glibc/tst-stdc_has_single_bit.c -tests/from-glibc/tst-stdc_leading_ones.c -tests/from-glibc/tst-stdc_leading_zeros.c -tests/from-glibc/tst-stdc_trailing_ones.c -tests/from-glibc/tst-stdc_trailing_zeros.c - -Depends-on: -assert-h -libc-config -stdint - -configure.ac: - -Makefile.am: -TESTS += \ - test-stdc_bit_ceil test-stdc_bit_floor test-stdc_bit_width \ - test-stdc_count_ones test-stdc_count_zeros test-stdc_first_leading_one \ - test-stdc_first_leading_zero test-stdc_first_trailing_one \ - test-stdc_first_trailing_zero test-stdc_has_single_bit \ - test-stdc_leading_ones test-stdc_leading_zeros test-stdc_trailing_ones \ - test-stdc_trailing_zeros - -check_PROGRAMS += \ - test-stdc_bit_ceil test-stdc_bit_floor test-stdc_bit_width \ - test-stdc_count_ones test-stdc_count_zeros test-stdc_first_leading_one \ - test-stdc_first_leading_zero test-stdc_first_trailing_one \ - test-stdc_first_trailing_zero test-stdc_has_single_bit \ - test-stdc_leading_ones test-stdc_leading_zeros test-stdc_trailing_ones \ - test-stdc_trailing_zeros - -TEST_STDBIT_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT - -test_stdc_bit_ceil_SOURCES = from-glibc/tst-stdc_bit_ceil.c -test_stdc_bit_ceil_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_bit_floor_SOURCES = from-glibc/tst-stdc_bit_floor.c -test_stdc_bit_floor_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_bit_width_SOURCES = from-glibc/tst-stdc_bit_width.c -test_stdc_bit_width_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_count_ones_SOURCES = from-glibc/tst-stdc_count_ones.c -test_stdc_count_ones_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_count_zeros_SOURCES = from-glibc/tst-stdc_count_zeros.c -test_stdc_count_zeros_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_first_leading_one_SOURCES = from-glibc/tst-stdc_first_leading_one.c -test_stdc_first_leading_one_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_first_leading_zero_SOURCES = from-glibc/tst-stdc_first_leading_zero.c -test_stdc_first_leading_zero_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_first_trailing_one_SOURCES = from-glibc/tst-stdc_first_trailing_one.c -test_stdc_first_trailing_one_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_first_trailing_zero_SOURCES = from-glibc/tst-stdc_first_trailing_zero.c -test_stdc_first_trailing_zero_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_has_single_bit_SOURCES = from-glibc/tst-stdc_has_single_bit.c -test_stdc_has_single_bit_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_leading_ones_SOURCES = from-glibc/tst-stdc_leading_ones.c -test_stdc_leading_ones_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_leading_zeros_SOURCES = from-glibc/tst-stdc_leading_zeros.c -test_stdc_leading_zeros_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_trailing_ones_SOURCES = from-glibc/tst-stdc_trailing_ones.c -test_stdc_trailing_ones_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) - -test_stdc_trailing_zeros_SOURCES = from-glibc/tst-stdc_trailing_zeros.c -test_stdc_trailing_zeros_CPPFLAGS = $(TEST_STDBIT_CPPFLAGS) diff --git a/modules/stdc_bit_ceil b/modules/stdc_bit_ceil new file mode 100644 index 0000000000..d08f14d088 --- /dev/null +++ b/modules/stdc_bit_ceil @@ -0,0 +1,28 @@ +Description: +stdc_bit_ceil macro, stdc_bit_ceil_* functions: +Return the smallest power of 2 that is ≥ a given unsigned integer. + +Files: +lib/stdc_bit_ceil.c + +Depends-on: +stdbit-h +stdc_bit_width + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_BIT_CEIL=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_bit_ceil.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_bit_ceil-tests b/modules/stdc_bit_ceil-tests new file mode 100644 index 0000000000..67fd8ebf0d --- /dev/null +++ b/modules/stdc_bit_ceil-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_bit_ceil.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_bit_ceil +check_PROGRAMS += test-stdc_bit_ceil +test_stdc_bit_ceil_SOURCES = from-glibc/tst-stdc_bit_ceil.c +test_stdc_bit_ceil_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_bit_floor b/modules/stdc_bit_floor new file mode 100644 index 0000000000..9d83bf171e --- /dev/null +++ b/modules/stdc_bit_floor @@ -0,0 +1,28 @@ +Description: +stdc_bit_floor macro, stdc_bit_floor_* functions: +Return the largest power of 2 that is ≤ a given unsigned integer. + +Files: +lib/stdc_bit_floor.c + +Depends-on: +stdbit-h +stdc_bit_width + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_BIT_FLOOR=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_bit_floor.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_bit_floor-tests b/modules/stdc_bit_floor-tests new file mode 100644 index 0000000000..5eb9359866 --- /dev/null +++ b/modules/stdc_bit_floor-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_bit_floor.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_bit_floor +check_PROGRAMS += test-stdc_bit_floor +test_stdc_bit_floor_SOURCES = from-glibc/tst-stdc_bit_floor.c +test_stdc_bit_floor_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_bit_width b/modules/stdc_bit_width new file mode 100644 index 0000000000..2c2572588e --- /dev/null +++ b/modules/stdc_bit_width @@ -0,0 +1,29 @@ +Description: +stdc_bit_width macro, stdc_bit_width_* functions: +Return the minimum number of bits required to represent an unsigned integer +value. + +Files: +lib/stdc_bit_width.c + +Depends-on: +stdbit-h +stdc_leading_zeros + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_BIT_WIDTH=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_bit_width.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_bit_width-tests b/modules/stdc_bit_width-tests new file mode 100644 index 0000000000..0c264229da --- /dev/null +++ b/modules/stdc_bit_width-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_bit_width.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_bit_width +check_PROGRAMS += test-stdc_bit_width +test_stdc_bit_width_SOURCES = from-glibc/tst-stdc_bit_width.c +test_stdc_bit_width_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_count_ones b/modules/stdc_count_ones new file mode 100644 index 0000000000..38ee1d5f67 --- /dev/null +++ b/modules/stdc_count_ones @@ -0,0 +1,27 @@ +Description: +stdc_count_ones macro, stdc_count_ones_* functions: +Return the number of 1 bits in an unsigned integer. + +Files: +lib/stdc_count_ones.c + +Depends-on: +stdbit-h + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_COUNT_ONES=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_count_ones.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_count_ones-tests b/modules/stdc_count_ones-tests new file mode 100644 index 0000000000..c7fc0bfbbc --- /dev/null +++ b/modules/stdc_count_ones-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_count_ones.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_count_ones +check_PROGRAMS += test-stdc_count_ones +test_stdc_count_ones_SOURCES = from-glibc/tst-stdc_count_ones.c +test_stdc_count_ones_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_count_zeros b/modules/stdc_count_zeros new file mode 100644 index 0000000000..ff10513b00 --- /dev/null +++ b/modules/stdc_count_zeros @@ -0,0 +1,28 @@ +Description: +stdc_count_zeros macro, stdc_count_zeros_* functions: +Return the number of 0 bits in an unsigned integer. + +Files: +lib/stdc_count_zeros.c + +Depends-on: +stdbit-h +stdc_count_ones + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_COUNT_ZEROS=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_count_zeros.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_count_zeros-tests b/modules/stdc_count_zeros-tests new file mode 100644 index 0000000000..c78f71005e --- /dev/null +++ b/modules/stdc_count_zeros-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_count_zeros.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_count_zeros +check_PROGRAMS += test-stdc_count_zeros +test_stdc_count_zeros_SOURCES = from-glibc/tst-stdc_count_zeros.c +test_stdc_count_zeros_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_first_leading_one b/modules/stdc_first_leading_one new file mode 100644 index 0000000000..e494dc053c --- /dev/null +++ b/modules/stdc_first_leading_one @@ -0,0 +1,29 @@ +Description: +stdc_first_leading_one macro, stdc_first_leading_one_* functions +Return the number of bits, from the most significant 1 bit to the most +significant bit, in an unsigned integer. + +Files: +lib/stdc_first_leading_one.c + +Depends-on: +stdbit-h +stdc_leading_zeros + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_FIRST_LEADING_ONE=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_first_leading_one.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_first_leading_one-tests b/modules/stdc_first_leading_one-tests new file mode 100644 index 0000000000..4ec69f5180 --- /dev/null +++ b/modules/stdc_first_leading_one-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_first_leading_one.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_first_leading_one +check_PROGRAMS += test-stdc_first_leading_one +test_stdc_first_leading_one_SOURCES = from-glibc/tst-stdc_first_leading_one.c +test_stdc_first_leading_one_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_first_leading_zero b/modules/stdc_first_leading_zero new file mode 100644 index 0000000000..f72c692e2e --- /dev/null +++ b/modules/stdc_first_leading_zero @@ -0,0 +1,29 @@ +Description: +stdc_first_leading_zero macro, stdc_first_leading_zero_* functions: +Return the number of bits, from the most significant 0 bit to the most +significant bit, in an unsigned integer. + +Files: +lib/stdc_first_leading_zero.c + +Depends-on: +stdbit-h +stdc_leading_ones + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_FIRST_LEADING_ZERO=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_first_leading_zero.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_first_leading_zero-tests b/modules/stdc_first_leading_zero-tests new file mode 100644 index 0000000000..cf654066a5 --- /dev/null +++ b/modules/stdc_first_leading_zero-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_first_leading_zero.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_first_leading_zero +check_PROGRAMS += test-stdc_first_leading_zero +test_stdc_first_leading_zero_SOURCES = from-glibc/tst-stdc_first_leading_zero.c +test_stdc_first_leading_zero_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_first_trailing_one b/modules/stdc_first_trailing_one new file mode 100644 index 0000000000..41e0b70c62 --- /dev/null +++ b/modules/stdc_first_trailing_one @@ -0,0 +1,29 @@ +Description: +stdc_first_trailing_one macro, stdc_first_trailing_one_* functions: +Return the number of bits, from the least significant 1 bit to the least +significant bit, in an unsigned integer. + +Files: +lib/stdc_first_trailing_one.c + +Depends-on: +stdbit-h +stdc_trailing_zeros + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_FIRST_TRAILING_ONE=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_first_trailing_one.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_first_trailing_one-tests b/modules/stdc_first_trailing_one-tests new file mode 100644 index 0000000000..a021e12c66 --- /dev/null +++ b/modules/stdc_first_trailing_one-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_first_trailing_one.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_first_trailing_one +check_PROGRAMS += test-stdc_first_trailing_one +test_stdc_first_trailing_one_SOURCES = from-glibc/tst-stdc_first_trailing_one.c +test_stdc_first_trailing_one_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_first_trailing_zero b/modules/stdc_first_trailing_zero new file mode 100644 index 0000000000..b194a33791 --- /dev/null +++ b/modules/stdc_first_trailing_zero @@ -0,0 +1,29 @@ +Description: +stdc_first_trailing_zero macro, stdc_first_trailing_zero_* functions: +Return the number of bits, from the least significant 0 bit to the least +significant bit, in an unsigned integer. + +Files: +lib/stdc_first_trailing_zero.c + +Depends-on: +stdbit-h +stdc_trailing_ones + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_FIRST_TRAILING_ZERO=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_first_trailing_zero.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_first_trailing_zero-tests b/modules/stdc_first_trailing_zero-tests new file mode 100644 index 0000000000..e7e541625c --- /dev/null +++ b/modules/stdc_first_trailing_zero-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_first_trailing_zero.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_first_trailing_zero +check_PROGRAMS += test-stdc_first_trailing_zero +test_stdc_first_trailing_zero_SOURCES = from-glibc/tst-stdc_first_trailing_zero.c +test_stdc_first_trailing_zero_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_has_single_bit b/modules/stdc_has_single_bit new file mode 100644 index 0000000000..f7f4459936 --- /dev/null +++ b/modules/stdc_has_single_bit @@ -0,0 +1,27 @@ +Description: +stdc_has_single_bit macro, stdc_has_single_bit_* functions: +Test whether an unsigned integer has exactly one 1 bit. + +Files: +lib/stdc_has_single_bit.c + +Depends-on: +stdbit-h + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_HAS_SINGLE_BIT=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_has_single_bit.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_has_single_bit-tests b/modules/stdc_has_single_bit-tests new file mode 100644 index 0000000000..2540299f00 --- /dev/null +++ b/modules/stdc_has_single_bit-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_has_single_bit.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_has_single_bit +check_PROGRAMS += test-stdc_has_single_bit +test_stdc_has_single_bit_SOURCES = from-glibc/tst-stdc_has_single_bit.c +test_stdc_has_single_bit_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_leading_ones b/modules/stdc_leading_ones new file mode 100644 index 0000000000..92e35181cf --- /dev/null +++ b/modules/stdc_leading_ones @@ -0,0 +1,28 @@ +Description: +stdc_leading_ones macro, stdc_leading_ones_* functions: +Return the number of leading 1 bits in an unsigned integer. + +Files: +lib/stdc_leading_ones.c + +Depends-on: +stdbit-h +stdc_leading_zeros + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_LEADING_ONES=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_leading_ones.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_leading_ones-tests b/modules/stdc_leading_ones-tests new file mode 100644 index 0000000000..b8901367c3 --- /dev/null +++ b/modules/stdc_leading_ones-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_leading_ones.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_leading_ones +check_PROGRAMS += test-stdc_leading_ones +test_stdc_leading_ones_SOURCES = from-glibc/tst-stdc_leading_ones.c +test_stdc_leading_ones_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_leading_zeros b/modules/stdc_leading_zeros new file mode 100644 index 0000000000..9a0bd06bd1 --- /dev/null +++ b/modules/stdc_leading_zeros @@ -0,0 +1,27 @@ +Description: +stdc_leading_zeros macro, stdc_leading_zeros_* functions: +Return the number of leading 0 bits in an unsigned integer. + +Files: +lib/stdc_leading_zeros.c + +Depends-on: +stdbit-h + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_LEADING_ZEROS=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_leading_zeros.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_leading_zeros-tests b/modules/stdc_leading_zeros-tests new file mode 100644 index 0000000000..0d7bfb67a9 --- /dev/null +++ b/modules/stdc_leading_zeros-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_leading_zeros.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_leading_zeros +check_PROGRAMS += test-stdc_leading_zeros +test_stdc_leading_zeros_SOURCES = from-glibc/tst-stdc_leading_zeros.c +test_stdc_leading_zeros_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_trailing_ones b/modules/stdc_trailing_ones new file mode 100644 index 0000000000..7154127062 --- /dev/null +++ b/modules/stdc_trailing_ones @@ -0,0 +1,28 @@ +Description: +stdc_trailing_ones macro, stdc_trailing_ones_* functions: +Return the number of trailing 1 bits in an unsigned integer. + +Files: +lib/stdc_trailing_ones.c + +Depends-on: +stdbit-h +stdc_trailing_zeros + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_TRAILING_ONES=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_trailing_ones.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_trailing_ones-tests b/modules/stdc_trailing_ones-tests new file mode 100644 index 0000000000..24bde0bca7 --- /dev/null +++ b/modules/stdc_trailing_ones-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_trailing_ones.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_trailing_ones +check_PROGRAMS += test-stdc_trailing_ones +test_stdc_trailing_ones_SOURCES = from-glibc/tst-stdc_trailing_ones.c +test_stdc_trailing_ones_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_trailing_zeros b/modules/stdc_trailing_zeros new file mode 100644 index 0000000000..4572dde86e --- /dev/null +++ b/modules/stdc_trailing_zeros @@ -0,0 +1,27 @@ +Description: +stdc_trailing_zeros macro, stdc_trailing_zeros_* functions: +Return the number of trailing 0 bits in an unsigned integer. + +Files: +lib/stdc_trailing_zeros.c + +Depends-on: +stdbit-h + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +GL_STDC_TRAILING_ZEROS=1 + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_trailing_zeros.c +endif + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/stdc_trailing_zeros-tests b/modules/stdc_trailing_zeros-tests new file mode 100644 index 0000000000..5ed01dfd58 --- /dev/null +++ b/modules/stdc_trailing_zeros-tests @@ -0,0 +1,19 @@ +Files: +tests/from-glibc/tst-stdc_trailing_zeros.c +tests/from-glibc/tst-stdbit.h +tests/from-glibc/support/test-driver.c +tests/macros.h + +Depends-on: +libc-config +stdbool +stdint +assert-h + +configure.ac: + +Makefile.am: +TESTS += test-stdc_trailing_zeros +check_PROGRAMS += test-stdc_trailing_zeros +test_stdc_trailing_zeros_SOURCES = from-glibc/tst-stdc_trailing_zeros.c +test_stdc_trailing_zeros_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/from-glibc -DGNULIB_TEST_STDBIT -- 2.34.1