about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/m68k
diff options
context:
space:
mode:
authorJoseph Myers <jsm@polyomino.org.uk>2024-01-03 12:07:14 +0000
committerJoseph Myers <jsm@polyomino.org.uk>2024-01-03 12:07:14 +0000
commitb34b46b8806a115b86da3b2b22555ad5bffa89d1 (patch)
treec386e5b6064843e19c7079ea15d3f0610aa5ce1a /sysdeps/unix/sysv/linux/m68k
parentfe316dad7ccfe44e9d649727b04cd36708477545 (diff)
downloadglibc-b34b46b8806a115b86da3b2b22555ad5bffa89d1.tar.gz
glibc-b34b46b8806a115b86da3b2b22555ad5bffa89d1.tar.xz
glibc-b34b46b8806a115b86da3b2b22555ad5bffa89d1.zip
Implement C23 <stdbit.h>
C23 adds a header <stdbit.h> with various functions and type-generic
macros for bit-manipulation of unsigned integers (plus macro defines
related to endianness).  Implement this header for glibc.

The functions have both inline definitions in the header (referenced
by macros defined in the header) and copies with external linkage in
the library (which are implemented in terms of those macros to avoid
duplication).  They are documented in the glibc manual.  Tests, as
well as verifying results for various inputs (of both the macros and
the out-of-line functions), verify the types of those results (which
showed up a bug in an earlier version with the type-generic macro
stdc_has_single_bit wrongly returning a promoted type), that the
macros can be used at top level in a source file (so don't use ({})),
that they evaluate their arguments exactly once, and that the macros
for the type-specific functions have the expected implicit conversions
to the relevant argument type.

Jakub previously referred to -Wconversion warnings in type-generic
macros, so I've included a test with -Wconversion (but the only
warnings I saw and fixed from that test were actually in inline
functions in the <stdbit.h> header - not anything coming from use of
the type-generic macros themselves).

This implementation of the type-generic macros does not handle
unsigned __int128, or unsigned _BitInt types with a width other than
that of a standard integer type (and C23 doesn't require the header to
handle such types either).  Support for those types, using the new
type-generic built-in functions Jakub's added for GCC 14, can
reasonably be added in a followup (along of course with associated
tests).

This implementation doesn't do anything special to handle C++, or have
any tests of functionality in C++ beyond the existing tests that all
headers can be compiled in C++ code; it's not clear exactly what form
this header should take in C++, but probably not one using macros.

DIS ballot comment AT-107 asks for the word "count" to be added to the
names of the stdc_leading_zeros, stdc_leading_ones,
stdc_trailing_zeros and stdc_trailing_ones functions and macros.  I
don't think it's likely to be accepted (accepting any technical
comments would mean having an FDIS ballot), but if it is accepted at
the WG14 meeting (22-26 January in Strasbourg, starting with DIS
ballot comment handling) then there would still be time to update
glibc for the renaming before the 2.39 release.

The new functions and header are placed in the stdlib/ directory in
glibc, rather than creating a new toplevel stdbit/ or putting them in
string/ alongside ffs.

Tested for x86_64 and x86.
Diffstat (limited to 'sysdeps/unix/sysv/linux/m68k')
-rw-r--r--sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist70
-rw-r--r--sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist70
2 files changed, 140 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 1cbebfb162..d9bd6a9b56 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -560,6 +560,76 @@ GLIBC_2.39 pidfd_spawn F
 GLIBC_2.39 pidfd_spawnp F
 GLIBC_2.39 posix_spawnattr_getcgroup_np F
 GLIBC_2.39 posix_spawnattr_setcgroup_np F
+GLIBC_2.39 stdc_bit_ceil_uc F
+GLIBC_2.39 stdc_bit_ceil_ui F
+GLIBC_2.39 stdc_bit_ceil_ul F
+GLIBC_2.39 stdc_bit_ceil_ull F
+GLIBC_2.39 stdc_bit_ceil_us F
+GLIBC_2.39 stdc_bit_floor_uc F
+GLIBC_2.39 stdc_bit_floor_ui F
+GLIBC_2.39 stdc_bit_floor_ul F
+GLIBC_2.39 stdc_bit_floor_ull F
+GLIBC_2.39 stdc_bit_floor_us F
+GLIBC_2.39 stdc_bit_width_uc F
+GLIBC_2.39 stdc_bit_width_ui F
+GLIBC_2.39 stdc_bit_width_ul F
+GLIBC_2.39 stdc_bit_width_ull F
+GLIBC_2.39 stdc_bit_width_us F
+GLIBC_2.39 stdc_count_ones_uc F
+GLIBC_2.39 stdc_count_ones_ui F
+GLIBC_2.39 stdc_count_ones_ul F
+GLIBC_2.39 stdc_count_ones_ull F
+GLIBC_2.39 stdc_count_ones_us F
+GLIBC_2.39 stdc_count_zeros_uc F
+GLIBC_2.39 stdc_count_zeros_ui F
+GLIBC_2.39 stdc_count_zeros_ul F
+GLIBC_2.39 stdc_count_zeros_ull F
+GLIBC_2.39 stdc_count_zeros_us F
+GLIBC_2.39 stdc_first_leading_one_uc F
+GLIBC_2.39 stdc_first_leading_one_ui F
+GLIBC_2.39 stdc_first_leading_one_ul F
+GLIBC_2.39 stdc_first_leading_one_ull F
+GLIBC_2.39 stdc_first_leading_one_us F
+GLIBC_2.39 stdc_first_leading_zero_uc F
+GLIBC_2.39 stdc_first_leading_zero_ui F
+GLIBC_2.39 stdc_first_leading_zero_ul F
+GLIBC_2.39 stdc_first_leading_zero_ull F
+GLIBC_2.39 stdc_first_leading_zero_us F
+GLIBC_2.39 stdc_first_trailing_one_uc F
+GLIBC_2.39 stdc_first_trailing_one_ui F
+GLIBC_2.39 stdc_first_trailing_one_ul F
+GLIBC_2.39 stdc_first_trailing_one_ull F
+GLIBC_2.39 stdc_first_trailing_one_us F
+GLIBC_2.39 stdc_first_trailing_zero_uc F
+GLIBC_2.39 stdc_first_trailing_zero_ui F
+GLIBC_2.39 stdc_first_trailing_zero_ul F
+GLIBC_2.39 stdc_first_trailing_zero_ull F
+GLIBC_2.39 stdc_first_trailing_zero_us F
+GLIBC_2.39 stdc_has_single_bit_uc F
+GLIBC_2.39 stdc_has_single_bit_ui F
+GLIBC_2.39 stdc_has_single_bit_ul F
+GLIBC_2.39 stdc_has_single_bit_ull F
+GLIBC_2.39 stdc_has_single_bit_us F
+GLIBC_2.39 stdc_leading_ones_uc F
+GLIBC_2.39 stdc_leading_ones_ui F
+GLIBC_2.39 stdc_leading_ones_ul F
+GLIBC_2.39 stdc_leading_ones_ull F
+GLIBC_2.39 stdc_leading_ones_us F
+GLIBC_2.39 stdc_leading_zeros_uc F
+GLIBC_2.39 stdc_leading_zeros_ui F
+GLIBC_2.39 stdc_leading_zeros_ul F
+GLIBC_2.39 stdc_leading_zeros_ull F
+GLIBC_2.39 stdc_leading_zeros_us F
+GLIBC_2.39 stdc_trailing_ones_uc F
+GLIBC_2.39 stdc_trailing_ones_ui F
+GLIBC_2.39 stdc_trailing_ones_ul F
+GLIBC_2.39 stdc_trailing_ones_ull F
+GLIBC_2.39 stdc_trailing_ones_us F
+GLIBC_2.39 stdc_trailing_zeros_uc F
+GLIBC_2.39 stdc_trailing_zeros_ui F
+GLIBC_2.39 stdc_trailing_zeros_ul F
+GLIBC_2.39 stdc_trailing_zeros_ull F
+GLIBC_2.39 stdc_trailing_zeros_us F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0x98
 GLIBC_2.4 _IO_2_1_stdin_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 8dd696a24e..439796d693 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2791,6 +2791,76 @@ GLIBC_2.39 pidfd_spawn F
 GLIBC_2.39 pidfd_spawnp F
 GLIBC_2.39 posix_spawnattr_getcgroup_np F
 GLIBC_2.39 posix_spawnattr_setcgroup_np F
+GLIBC_2.39 stdc_bit_ceil_uc F
+GLIBC_2.39 stdc_bit_ceil_ui F
+GLIBC_2.39 stdc_bit_ceil_ul F
+GLIBC_2.39 stdc_bit_ceil_ull F
+GLIBC_2.39 stdc_bit_ceil_us F
+GLIBC_2.39 stdc_bit_floor_uc F
+GLIBC_2.39 stdc_bit_floor_ui F
+GLIBC_2.39 stdc_bit_floor_ul F
+GLIBC_2.39 stdc_bit_floor_ull F
+GLIBC_2.39 stdc_bit_floor_us F
+GLIBC_2.39 stdc_bit_width_uc F
+GLIBC_2.39 stdc_bit_width_ui F
+GLIBC_2.39 stdc_bit_width_ul F
+GLIBC_2.39 stdc_bit_width_ull F
+GLIBC_2.39 stdc_bit_width_us F
+GLIBC_2.39 stdc_count_ones_uc F
+GLIBC_2.39 stdc_count_ones_ui F
+GLIBC_2.39 stdc_count_ones_ul F
+GLIBC_2.39 stdc_count_ones_ull F
+GLIBC_2.39 stdc_count_ones_us F
+GLIBC_2.39 stdc_count_zeros_uc F
+GLIBC_2.39 stdc_count_zeros_ui F
+GLIBC_2.39 stdc_count_zeros_ul F
+GLIBC_2.39 stdc_count_zeros_ull F
+GLIBC_2.39 stdc_count_zeros_us F
+GLIBC_2.39 stdc_first_leading_one_uc F
+GLIBC_2.39 stdc_first_leading_one_ui F
+GLIBC_2.39 stdc_first_leading_one_ul F
+GLIBC_2.39 stdc_first_leading_one_ull F
+GLIBC_2.39 stdc_first_leading_one_us F
+GLIBC_2.39 stdc_first_leading_zero_uc F
+GLIBC_2.39 stdc_first_leading_zero_ui F
+GLIBC_2.39 stdc_first_leading_zero_ul F
+GLIBC_2.39 stdc_first_leading_zero_ull F
+GLIBC_2.39 stdc_first_leading_zero_us F
+GLIBC_2.39 stdc_first_trailing_one_uc F
+GLIBC_2.39 stdc_first_trailing_one_ui F
+GLIBC_2.39 stdc_first_trailing_one_ul F
+GLIBC_2.39 stdc_first_trailing_one_ull F
+GLIBC_2.39 stdc_first_trailing_one_us F
+GLIBC_2.39 stdc_first_trailing_zero_uc F
+GLIBC_2.39 stdc_first_trailing_zero_ui F
+GLIBC_2.39 stdc_first_trailing_zero_ul F
+GLIBC_2.39 stdc_first_trailing_zero_ull F
+GLIBC_2.39 stdc_first_trailing_zero_us F
+GLIBC_2.39 stdc_has_single_bit_uc F
+GLIBC_2.39 stdc_has_single_bit_ui F
+GLIBC_2.39 stdc_has_single_bit_ul F
+GLIBC_2.39 stdc_has_single_bit_ull F
+GLIBC_2.39 stdc_has_single_bit_us F
+GLIBC_2.39 stdc_leading_ones_uc F
+GLIBC_2.39 stdc_leading_ones_ui F
+GLIBC_2.39 stdc_leading_ones_ul F
+GLIBC_2.39 stdc_leading_ones_ull F
+GLIBC_2.39 stdc_leading_ones_us F
+GLIBC_2.39 stdc_leading_zeros_uc F
+GLIBC_2.39 stdc_leading_zeros_ui F
+GLIBC_2.39 stdc_leading_zeros_ul F
+GLIBC_2.39 stdc_leading_zeros_ull F
+GLIBC_2.39 stdc_leading_zeros_us F
+GLIBC_2.39 stdc_trailing_ones_uc F
+GLIBC_2.39 stdc_trailing_ones_ui F
+GLIBC_2.39 stdc_trailing_ones_ul F
+GLIBC_2.39 stdc_trailing_ones_ull F
+GLIBC_2.39 stdc_trailing_ones_us F
+GLIBC_2.39 stdc_trailing_zeros_uc F
+GLIBC_2.39 stdc_trailing_zeros_ui F
+GLIBC_2.39 stdc_trailing_zeros_ul F
+GLIBC_2.39 stdc_trailing_zeros_ull F
+GLIBC_2.39 stdc_trailing_zeros_us F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F