mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-27 05:00:15 +00:00
b34b46b880
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.
238 lines
4.9 KiB
Plaintext
238 lines
4.9 KiB
Plaintext
%include <float128-abi.h>
|
|
libc {
|
|
GLIBC_2.0 {
|
|
# functions with required interface outside normal name space
|
|
__xpg_basename;
|
|
|
|
# functions used in inline functions or macros
|
|
__strtod_internal; __strtof_internal; __strtold_internal;
|
|
__strtol_internal; __strtoll_internal;
|
|
__strtoul_internal; __strtoull_internal;
|
|
# functions formerly so used (compatibility symbols)
|
|
__strtoq_internal; __strtouq_internal;
|
|
|
|
# compatibility symbol
|
|
__secure_getenv;
|
|
|
|
# a*
|
|
a64l; abort; abs; atexit; atof; atoi; atol; atoll;
|
|
|
|
# b*
|
|
bsearch;
|
|
|
|
# c*
|
|
canonicalize_file_name; clearenv;
|
|
|
|
# d*
|
|
div; drand48; drand48_r;
|
|
|
|
# e*
|
|
erand48; erand48_r; exit;
|
|
|
|
# g*
|
|
getenv; getsubopt;
|
|
|
|
# i*
|
|
initstate; initstate_r;
|
|
|
|
# l*
|
|
l64a; labs; lcong48; lcong48_r; ldiv; llabs; lldiv; lrand48; lrand48_r;
|
|
|
|
# m*
|
|
mblen; mbrlen; mbrtowc; mbsinit; mbsnrtowcs; mbsrtowcs; mbstowcs;
|
|
mbtowc; mcount; mrand48; mrand48_r;
|
|
|
|
# n*
|
|
nrand48; nrand48_r;
|
|
|
|
# o*
|
|
on_exit;
|
|
|
|
# p*
|
|
putenv;
|
|
|
|
# q*
|
|
qsort;
|
|
|
|
# r*
|
|
rand; rand_r; random; random_r; realpath; rpmatch;
|
|
|
|
# s*
|
|
seed48; seed48_r; setcontext; setenv; setstate; setstate_r; srand; srand48;
|
|
srand48_r; srandom; srandom_r; step; strfmon; strtod; strtof; strtol;
|
|
strtold; strtoll; strtoq; strtoul; strtoull; strtouq; system;
|
|
|
|
# u*
|
|
unsetenv;
|
|
|
|
# w*
|
|
wcstombs; wctomb;
|
|
}
|
|
GLIBC_2.1 {
|
|
# a*
|
|
addseverity;
|
|
|
|
# f*
|
|
fmtmsg;
|
|
|
|
# g*
|
|
getcontext;
|
|
|
|
# m*
|
|
makecontext;
|
|
|
|
# s*
|
|
strtoimax; strtoumax; swapcontext;
|
|
}
|
|
GLIBC_2.1.1 {
|
|
# _*
|
|
_Exit;
|
|
|
|
# i*
|
|
imaxabs; imaxdiv;
|
|
}
|
|
GLIBC_2.1.3 {
|
|
# used by new G++ ABI
|
|
__cxa_atexit; __cxa_finalize;
|
|
}
|
|
GLIBC_2.3 {
|
|
# Silent change in SUS.
|
|
realpath;
|
|
}
|
|
GLIBC_2.8 {
|
|
qsort_r;
|
|
}
|
|
GLIBC_2.10 {
|
|
quick_exit; __cxa_at_quick_exit;
|
|
}
|
|
GLIBC_2.17 {
|
|
secure_getenv;
|
|
}
|
|
GLIBC_2.18 {
|
|
__cxa_thread_atexit_impl;
|
|
}
|
|
GLIBC_2.24 {
|
|
quick_exit;
|
|
}
|
|
GLIBC_2.25 {
|
|
# s*
|
|
strfromd; strfromf; strfroml;
|
|
getrandom; getentropy;
|
|
}
|
|
%ifdef FLOAT128_VERSION
|
|
FLOAT128_VERSION {
|
|
strfromf128;
|
|
strtof128;
|
|
strtof128_l;
|
|
}
|
|
%endif
|
|
GLIBC_2.27 {
|
|
# _Float64x functions, only present for some configurations.
|
|
strfromf64x;
|
|
strtof64x;
|
|
strtof64x_l;
|
|
# _Float32, _Float64 and _Float32x functions, for all configurations.
|
|
strfromf32; strfromf64; strfromf32x;
|
|
strtof32; strtof64; strtof32x;
|
|
strtof32_l; strtof64_l; strtof32x_l;
|
|
}
|
|
GLIBC_2.36 {
|
|
arc4random;
|
|
arc4random_buf;
|
|
arc4random_uniform;
|
|
}
|
|
GLIBC_2.37 {
|
|
}
|
|
GLIBC_2.38 {
|
|
__isoc23_strtol;
|
|
__isoc23_strtoll;
|
|
__isoc23_strtoul;
|
|
__isoc23_strtoull;
|
|
__isoc23_strtoimax;
|
|
__isoc23_strtoumax;
|
|
}
|
|
GLIBC_2.39 {
|
|
stdc_leading_zeros_uc;
|
|
stdc_leading_zeros_us;
|
|
stdc_leading_zeros_ui;
|
|
stdc_leading_zeros_ul;
|
|
stdc_leading_zeros_ull;
|
|
stdc_leading_ones_uc;
|
|
stdc_leading_ones_us;
|
|
stdc_leading_ones_ui;
|
|
stdc_leading_ones_ul;
|
|
stdc_leading_ones_ull;
|
|
stdc_trailing_zeros_uc;
|
|
stdc_trailing_zeros_us;
|
|
stdc_trailing_zeros_ui;
|
|
stdc_trailing_zeros_ul;
|
|
stdc_trailing_zeros_ull;
|
|
stdc_trailing_ones_uc;
|
|
stdc_trailing_ones_us;
|
|
stdc_trailing_ones_ui;
|
|
stdc_trailing_ones_ul;
|
|
stdc_trailing_ones_ull;
|
|
stdc_first_leading_zero_uc;
|
|
stdc_first_leading_zero_us;
|
|
stdc_first_leading_zero_ui;
|
|
stdc_first_leading_zero_ul;
|
|
stdc_first_leading_zero_ull;
|
|
stdc_first_leading_one_uc;
|
|
stdc_first_leading_one_us;
|
|
stdc_first_leading_one_ui;
|
|
stdc_first_leading_one_ul;
|
|
stdc_first_leading_one_ull;
|
|
stdc_first_trailing_zero_uc;
|
|
stdc_first_trailing_zero_us;
|
|
stdc_first_trailing_zero_ui;
|
|
stdc_first_trailing_zero_ul;
|
|
stdc_first_trailing_zero_ull;
|
|
stdc_first_trailing_one_uc;
|
|
stdc_first_trailing_one_us;
|
|
stdc_first_trailing_one_ui;
|
|
stdc_first_trailing_one_ul;
|
|
stdc_first_trailing_one_ull;
|
|
stdc_count_zeros_uc;
|
|
stdc_count_zeros_us;
|
|
stdc_count_zeros_ui;
|
|
stdc_count_zeros_ul;
|
|
stdc_count_zeros_ull;
|
|
stdc_count_ones_uc;
|
|
stdc_count_ones_us;
|
|
stdc_count_ones_ui;
|
|
stdc_count_ones_ul;
|
|
stdc_count_ones_ull;
|
|
stdc_has_single_bit_uc;
|
|
stdc_has_single_bit_us;
|
|
stdc_has_single_bit_ui;
|
|
stdc_has_single_bit_ul;
|
|
stdc_has_single_bit_ull;
|
|
stdc_bit_width_uc;
|
|
stdc_bit_width_us;
|
|
stdc_bit_width_ui;
|
|
stdc_bit_width_ul;
|
|
stdc_bit_width_ull;
|
|
stdc_bit_floor_uc;
|
|
stdc_bit_floor_us;
|
|
stdc_bit_floor_ui;
|
|
stdc_bit_floor_ul;
|
|
stdc_bit_floor_ull;
|
|
stdc_bit_ceil_uc;
|
|
stdc_bit_ceil_us;
|
|
stdc_bit_ceil_ui;
|
|
stdc_bit_ceil_ul;
|
|
stdc_bit_ceil_ull;
|
|
}
|
|
GLIBC_PRIVATE {
|
|
# functions which have an additional interface since they are
|
|
# are cancelable.
|
|
__libc_system;
|
|
# Variable which needs a dynamic symbol table entry.
|
|
__abort_msg;
|
|
# Used from other libraries
|
|
__libc_secure_getenv;
|
|
__call_tls_dtors;
|
|
__strtof_nan; __strtod_nan; __strtold_nan;
|
|
}
|
|
}
|