glibc/sysdeps/mach/hurd/x86_64
Joseph Myers b34b46b880 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.
2024-01-03 12:07:14 +00:00
..
bits Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
htl Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
____longjmp_chk.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
__longjmp.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
c++-types.data hurd: Fix expected c++ types 2023-05-19 01:45:06 +02:00
dl-tls-initialized.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Implies
intr-msg.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ld.abilist hurd: Add expected abilist files for x86_64 2023-05-01 12:10:20 +02:00
libanl.abilist hurd 64bit: Add missing libanl 2023-05-01 13:36:14 +02:00
libBrokenLocale.abilist hurd: Add expected abilist files for x86_64 2023-05-01 12:10:20 +02:00
libc_malloc_debug.abilist hurd: Add expected abilist files for x86_64 2023-05-01 12:10:20 +02:00
libc.abilist Implement C23 <stdbit.h> 2024-01-03 12:07:14 +00:00
libdl.abilist hurd: Add expected abilist files for x86_64 2023-05-01 12:10:20 +02:00
libm.abilist hurd: Add expected abilist files for x86_64 2023-05-01 12:10:20 +02:00
libmvec.abilist hurd: Add expected abilist files for x86_64 2023-05-01 12:10:20 +02:00
libpthread.abilist htl: move pthread_attr_setdetachstate into libc 2023-08-24 01:57:22 +02:00
libresolv.abilist hurd: Add expected abilist files for x86_64 2023-05-01 12:10:20 +02:00
librt.abilist hurd: Add expected abilist files for x86_64 2023-05-01 12:10:20 +02:00
localplt.data Remove __access_noerrno 2023-11-23 19:01:32 +00:00
longjmp-ts.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Makefile hurd: Also XFAIL missing SA_NOCLDWAIT on 64bit 2023-05-01 13:28:53 +02:00
shlib-versions hurd: Fix ld.so name 2023-05-06 21:00:56 +02:00
sigreturn.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
static-start.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tls.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tlsdesc.sym hurd, htl: Add some x86_64-specific code 2023-02-12 16:35:03 +01:00
ucontext_i.sym hurd: Add sys/ucontext.h and sigcontext.h for x86_64 2023-04-10 20:11:43 +02:00
Versions hurd: Add ioperm symbol on x86_64 2023-05-06 19:06:39 +02:00
vm_param.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00