glibc/sysdeps/unix/sysv/linux/alpha
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
..
alpha
alphaev6/fpu
alphaev67/fpu
bits Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fpu
sys 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
a.out.h
adjtime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
adjtimex.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
aio_cancel.c Linux: Move aio_cancel, aio_cancel64 into libc 2021-06-25 11:48:46 +02:00
arch-syscall.h Update syscall lists for Linux 6.6 2023-11-03 10:01:46 -03:00
brk_call.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
c++-types.data
clone.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
configure configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
configure.ac
dl-auxv.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-support.c
dl-sysdep.c
errlist-compat-data.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fraiseexcpt.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fstatfs64.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fstatfs.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fxstat64.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fxstatat64.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
getclktck.c
getcontext.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
getdents64.c
getdents.c
getegid.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
geteuid.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gethostname.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
getppid.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
getrlimit64.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gettimeofday.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
glob-lstat-compat.c
globfree.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ieee_get_fp_control.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ieee_set_fp_control.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Implies
ioperm.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ipc_priv.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
kernel_sigaction.h
kernel_stat.h alpha: Remove anonymous union in struct stat [BZ #27042] 2020-12-21 09:09:43 -03:00
kernel_sysinfo.h
kernel_termios.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
kernel-features.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ld.abilist Linux: Use ptrdiff_t for __rseq_offset 2022-02-02 22:37:20 +01:00
libanl.abilist resolv: Move libanl into libc (if libpthread is in libc) 2021-07-02 11:45:00 +02:00
libBrokenLocale.abilist
libc_malloc_debug.abilist Move malloc_{g,s}et_state to libc_malloc_debug 2021-07-22 18:38:10 +05:30
libc.abilist Implement C23 <stdbit.h> 2024-01-03 12:07:14 +00:00
libdl.abilist dlfcn: Move dlopen into libc 2021-06-03 08:26:04 +02:00
libm.abilist math: Remove the error handling wrapper from fmod and fmodf 2023-04-03 16:45:27 -03:00
libnsl.abilist
libpthread.abilist nptl: Remove remaining code from libpthread 2021-05-21 22:35:01 +02:00
libresolv.abilist resolv: Move res_query functions into libc 2021-07-19 07:56:57 +02:00
librt-compat.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
librt.abilist Linux: Move timer_settime, __timer_settime64 from librt to libc 2021-06-28 09:51:01 +02:00
libthread_db.abilist
libutil.abilist login: Move libutil into libc 2021-06-30 08:43:37 +02:00
localplt.data elf: Rework exception handling in the dynamic loader [BZ #25486] 2022-11-03 09:39:31 +01:00
lxstat64.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
makecontext.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Makefile nptl: Remove remaining code from libpthread 2021-05-21 22:35:01 +02:00
nldbl-abi.h
oldglob.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
osf_adjtime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
osf_getitimer.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
osf_getrusage.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
osf_gettimeofday.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
osf_setitimer.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
osf_settimeofday.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
osf_utimes.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
osf_wait4.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
pointer_guard.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
rt_sigaction.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
select.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
setcontext.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
setfpucw.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
setrlimit64.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
settimeofday.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
shlib-versions crypt: Remove libcrypt support 2023-10-30 13:03:59 -03:00
sigcontextinfo.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
sizes.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
statfs64.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
statfs.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
swapcontext.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
syscall.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
syscalls.list linux: Consolidate Linux setsockopt implementation 2021-07-06 11:45:35 -03:00
sysconf.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
sysdep.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
timer_t_was_int_compat.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ucontext-offsets.sym
Versions Linux: Move timer_settime, __timer_settime64 from librt to libc 2021-06-28 09:51:01 +02:00
vfork.S Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
wait4.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
wordexp.c
xstat64.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
xstatconv.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
xstatconv.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
xstatver.h Remove mknod wrapper functions, move them to symbols 2020-10-09 17:02:06 -03:00