Commit Graph

42256 Commits

Author SHA1 Message Date
Joseph Myers 75ad83f564 Implement C23 pown
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the pown functions, which are like pow but with an
integer exponent.  That exponent has type long long int in C23; it was
intmax_t in TS 18661-4, and as with other interfaces changed after
their initial appearance in the TS, I don't think we need to support
the original version of the interface.  The test inputs are based on
the subset of test inputs for pow that use integer exponents that fit
in long long.

As the first such template implementation that saves and restores the
rounding mode internally (to avoid possible issues with directed
rounding and intermediate overflows or underflows in the wrong
rounding mode), support also needed to be added for using
SET_RESTORE_ROUND* in such template function implementations.  This
required math-type-macros-float128.h to include <fenv_private.h>, so
it can tell whether SET_RESTORE_ROUNDF128 is defined.  In turn, the
include order with <fenv_private.h> included before <math_private.h>
broke loongarch builds, showing up that
sysdeps/loongarch/math_private.h is really a fenv_private.h file
(maybe implemented internally before the consistent split of those
headers in 2018?) and needed to be renamed to fenv_private.h to avoid
errors with duplicate macro definitions if <math_private.h> is
included after <fenv_private.h>.

The underlying implementation uses __ieee754_pow functions (called
more than once in some cases, where the exponent does not fit in the
floating type).  I expect a custom implementation for a given format,
that only handles integer exponents but handles larger exponents
directly, could be faster and more accurate in some cases.

I encourage searching for worst cases for ulps error for these
implementations (necessarily non-exhaustively, given the size of the
input space).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-03-27 10:44:44 +00:00
Florian Weimer be61b9493d support: Use unwinder in links-dso-program-c only with libgcc_s
Do not build links-dso-program-c with exception (unwinding) support
if libgcc_s is not available.  In this case, the unwinder may be
part of libgcc.a or libgcc_eh.a, depending on how GCC was built.
If the unwinder is in libgcc_eh.a only, linking links-dso-program-c
failed before this change.  After this change, the exception
handling landing pad is only generated if libgcc_s available,
avoiding an undefined _Unwind_Resume (or equivalent) symbol
reference in the non-libgcc_s case.

Fixes commit ffd36cc27407003a6f9efcb9c16370e3435c5b1d ("support: Use
unwinder in links-dso-program-c only with libgcc_s") and
commit 5dfbc3c43e ("support: Link
links-dso-program-c with libgcc_s only if available").
2025-03-26 17:46:40 +01:00
Wilco Dijkstra 1233da4943 malloc: Use __always_inline for simple functions
Use __always_inline for small helper functions that are critical for
performance.  This ensures inlining always happens when expected.
Performance of bench-malloc-simple improves by 0.6% on average on
Neoverse V2.

Reviewed-by: DJ Delorie <dj@redhat.com>
2025-03-26 13:17:51 +00:00
Collin Funk 3263675250 linux: Fix integer overflow warnings when including <sys/mount.h> [BZ ]
Using gcc -Wshift-overflow=2 -Wsystem-headers to compile a file
including <sys/mount.h> will cause a warning since 1 << 31 is undefined
behavior on platforms where int is 32-bits.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-03-25 23:55:08 -04:00
Wilco Dijkstra cd33535002 malloc: Use _int_free_chunk for remainders
When splitting a chunk, release the tail part by calling int_free_chunk.
This avoids inserting random blocks into tcache that were never requested
by the user.  Fragmentation will be worse if they are never used again.
Note if the tail is fairly small, we could avoid splitting it at all.
Also remove an oddly placed initialization of tcache in _libc_realloc.

Reviewed-by: DJ Delorie <dj@redhat.com>
2025-03-25 18:53:01 +00:00
Joseph Myers 8bac7f7a43 Use MPFR 4.2.2 and Linux 6.14 in build-many-glibcs.py
Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
2025-03-25 18:29:01 +00:00
Maciej W. Rozycki 4bea073069 stdio-common: Add scanf long double data for IBM 128-bit format
Add Makefile infrastructure and IBM 128-bit 'long double' real input for
targets switching between the IEEE 754 binary128 and IBM 128-bit formats
with '-mabi=ieeelongdouble' and '-mabi=ibmlongdouble'.  Reuse IEEE 754
binary128 input data but with modified output file names so as not to
clash with the names used for IBM 128-bit format tests made with common
rules for the 'long double' data type.

Keep input data disabled and referring to BZ  for entries that are
are currently incorrectly accepted as valid data, such as '0e', '0e+',
'0x', '0x8p', '0x0p-', etc.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-25 09:40:20 +00:00
Maciej W. Rozycki 771cda3c9c stdio-common: Add scanf long double data for IEEE 754 binary64 format
Add Makefile infrastructure and 64-bit `long double' real input data for
targets switching between the IEEE 754 binary64 and IEEE 754 binary128
formats with `-mlong-double-64' and `-mlong-double-128'.  Use modified
output file names for the IEEE 754 binary64 format so as not to clash
with the names used for IEEE 754 binary128 format tests made with common
rules for the 'long double' data type.

Keep input data disabled and referring to BZ  for entries that are
are currently incorrectly accepted as valid data, such as '0e', '0e+',
'0x', '0x8p', '0x0p-', etc.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-25 09:40:20 +00:00
Maciej W. Rozycki 1890e63c86 stdio-common: Add scanf long double data for IEEE 754 binary128 format
Add Makefile infrastructure and `long double' real input data for
targets using the IEEE 754 binary128 format.

Keep input data disabled and referring to BZ  for entries that are
are currently incorrectly accepted as valid data, such as '0e', '0e+',
'0x', '0x8p', '0x0p-', etc.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-25 09:40:20 +00:00
Maciej W. Rozycki 0b31161439 stdio-common: Add scanf double data for IEEE 754 binary64 format
Add Makefile infrastructure and `double' real input data for targets
using the IEEE 754 binary64 format.

Keep input data disabled and referring to BZ  for entries that are
are currently incorrectly accepted as valid data, such as '0e', '0e+',
'0x', '0x8p', '0x0p-', etc.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-25 09:40:20 +00:00
Maciej W. Rozycki 26df22636d stdio-common: Add scanf float data for IEEE 754 binary32 format
Add Makefile infrastructure and `float' real input data for targets
using the IEEE 754 binary32 format.

Keep input data disabled and referring to BZ  for entries that are
are currently incorrectly accepted as valid data, such as '0e', '0e+',
'0x', '0x8p', '0x0p-', etc.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-25 09:40:20 +00:00
Maciej W. Rozycki a2bacea239 stdio-common: Add scanf integer data for LP64 targets
Add Makefile infrastructure and `int' and `long' integer input data,
signed and unsigned, for LP64 targets.

While the size of `int' data is the same between ILP32 and LP64 targets,
resulting scanf output is different between them for out of range input
data and while ISO C and POSIX both say that the behavior is undefined
if the result of the conversion cannot be represented we want to keep
track of our output to prevent inadvertent changes.  Hence the use of
distinct `int' integer input data between ILP32 and LP64 targets.

Keep input data disabled and referring to BZ  for entries that are
are currently incorrectly accepted as valid data, such as '0b' or '0x'.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-25 09:40:20 +00:00
Maciej W. Rozycki d7584e4d36 stdio-common: Add scanf integer data for ILP32 targets
Add Makefile infrastructure and `int' and `long' integer input data,
signed and unsigned, for ILP32 targets.

While the size of `int' data is the same between ILP32 and LP64 targets,
resulting scanf output is different between them for out of range input
data and while ISO C and POSIX both say that the behavior is undefined
if the result of the conversion cannot be represented we want to keep
track of our output to prevent inadvertent changes.  Hence the use of
distinct `int' integer input data between ILP32 and LP64 targets.

Keep input data disabled and referring to BZ  for entries that are
are currently incorrectly accepted as valid data, such as '0b' or '0x'.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-25 09:40:20 +00:00
Maciej W. Rozycki d1a621b735 stdio-common: Add tests for formatted scanf input specifiers
Add a collection of tests for formatted scanf input specifiers covering
the b, d, i, o, u, x, and X integer conversions, the a, A, e, E, f, F,
g, and G floating-point conversions, and the [, c, and s character
conversions.  Also the hh, h, l, and ll length modifiers are covered
with the integer conversions as are the l and L length modifier with the
floating-point conversions.  The tests cover assignment suppressing and
the field width as well, verifying the number of assignments made, the
number of characters consumed and the value assigned.

Add the common test code here as well as test cases for scanf, and then
base Makefile infrastructure plus target-agnostic input data, for the
character conversions and the `char', `short', and `long long' integer
ones, signed and unsigned, with remaining input data and other functions
from the scanf family deferred to subsequent additions.

Keep input data disabled and referring to BZ  for entries that are
currently incorrectly accepted as valid data, such as '0b' or '0x' with
the relevant integer conversions or sequences of an insufficient number
of characters with the c conversion.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-25 09:40:20 +00:00
Zhaoming Luo 0544df4f4a mach: Use the host_get_time64 to replace the deprecated host_get_time for CLOCK_REALTIME when it's available
Check the availability of host_get_time64 and use it to replace
host_get_time for CLOCK_REALTIME when it's available. Fall back to
host_get_time if gnumach does not support host_get_time64 but the
gnumach headers do.

host_get_time is deprecated
See https://git.savannah.gnu.org/cgit/hurd/gnumach.git/commit/?id=569df850cd7badd1e36132ad3b44aa76a4d27c25
However, it's kept for backward compactbility.

* config.h.in: Add HAVE_HOST_GET_TIME64 config entry.
* sysdeps/mach/clock_gettime.c: Use host_get_time64 for CLOCK_REALTIME
  when it's possible, fall to host_get_time otherwise.
* sysdeps/mach/configure: Check the existence of host_get_time64 RPC.
* sysdeps/mach/configure.ac: Check the existence of host_get_time64 RPC.
Message-ID: <20250324052042.19803-1-zhmingluo@163.com>
2025-03-25 01:10:10 +01:00
Samuel Thibault b62692d3c7 aio_suspend64: Fix clock discrepancy [BZ ]
cc5d5852c6 ("y2038: Convert aio_suspend to support 64 bit time")
switched from __clock_gettime (CLOCK_REALTIME, &now); to __clock_gettime64
(CLOCK_MONOTONIC, &ts);, but pthread_cond_timedwait is based on the
absolute realtime clock, so migrate to using pthread_cond_clockwait to
select CLOCK_MONOTONIC. Also fix AIO_MISC_WAIT into passing
CLOCK_MONOTONIC to __futex_abstimed_wait64.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-25 01:05:11 +01:00
Aaron Merey e3a6e85d67 Add _FORTIFY_SOURCE support for inet_pton
Add function __inet_pton_chk which calls __chk_fail when the size of
argument dst is too small.   inet_pton is redirected to __inet_pton_chk
or __inet_pton_warn when _FORTIFY_SOURCE is > 0.

Also add tests to debug/tst-fortify.c, update the abilist with
__inet_pton_chk and mention inet_pton fortification in maint.texi.

Co-authored-by: Frédéric Bérat <fberat@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-24 14:43:03 -04:00
Aaron Merey a71db81ed1 Prepare inet_pton to be fortified
Split inet_pton internals such as __inet_pton_length from the
inet_pton entry point.

This allows the internals to be built with fortification while
leaving the inet_pton entry point unchanged.

Co-authored-by: Frédéric Bérat <fberat@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-24 14:43:03 -04:00
Joseph Myers 2fb0009ff1 Update kernel version to 6.13 in header constant tests
There are no new constants covered by tst-mman-consts.py,
tst-mount-consts.py or tst-sched-consts.py in Linux 6.13 that need any
header changes, so update the kernel version in those tests.
(tst-pidfd-consts.py will need updating separately along with adding
new constants to glibc.)

Tested with build-many-glibcs.py.
2025-03-24 15:51:23 +00:00
Florian Weimer 5dfbc3c43e support: Link links-dso-program-c with libgcc_s only if available
Add a configure check to detect bootstrapping builds that do not
have libgcc_s.

Fixes commit 3e2be87832 ("support: Link
links-dso-program-c against libgcc_s").

Reviewed-by: Sam James <sam@gentoo.org>
2025-03-21 21:40:28 +01:00
Florian Weimer 2f8e8c9cb7 elf: Use +nolink-deps to add make-only dependency for tst-origin
The tst-origin test must link against liborigin-mod.so.  Correct
build order depends on a makefile rule dependency on
$(objpfx)liborigin-mod.so.  Use +nolink-deps to remvoe this
dependency from the linker command line.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-21 21:40:28 +01:00
Florian Weimer c3410db9d0 Makeconfig: Support $(+nolink-deps) in link flags
This allows adding dependencies to rules, but not linking against
them.

This is more or less a reimplementation of .EXTRA_PREREQS feature from
GNU make 4.3.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-21 21:40:28 +01:00
Adhemerval Zanella ed6a68bac7 debug: Improve '%n' fortify detection (BZ 30932)
The 7bb8045ec0 path made the '%n' fortify check ignore EMFILE errors
while trying to open /proc/self/maps, and this added a security
issue where EMFILE can be attacker-controlled thus making it
ineffective for some cases.

The EMFILE failure is reinstated but with a different error
message.  Also, to improve the false positive of the hardening for
the cases where no new files can be opened, the
_dl_readonly_area now uses  _dl_find_object to check if the
memory area is within a writable ELF segment.  The procfs method is
still used as fallback.

Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
2025-03-21 15:46:48 -03:00
Adhemerval Zanella 1894e219dc Remove eloop-threshold.h
On both Linux and Hurd the __eloop_threshold() is always a constant
(40 and 32 respectively), so there is no need to always call
__sysconf (_SC_SYMLOOP_MAX) for Linux case (!SYMLOOP_MAX).  To avoid
a name clash with gnulib, rename the new file min-eloop-threshold.h.

Checked on x86_64-linux-gnu and with a build for x86_64-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
2025-03-21 15:46:48 -03:00
Cupertino Miranda 855561a1fb malloc: missing initialization of tcache in _mid_memalign
_mid_memalign includes tcache code but does not attempt to initialize
tcaches.

Reviewed-by: DJ Delorie <dj@redhat.com>
2025-03-21 17:52:14 +00:00
Florian Weimer 3e2be87832 support: Link links-dso-program-c against libgcc_s
If C++ support is not available, links-dso-program-c is used
instead of the C++ version.  The C version was not linked against
libgcc_s, which meant that thread cancellation and the backtrace
function did not work in containers tests in that situation.

Reviewed-by: Sam James <sam@gentoo.org>
2025-03-21 11:45:00 +01:00
Frédéric Bérat 090dfa40a5 Add _FORTIFY_SOURCE support for inet_ntop
- Create the __inet_ntop_chk routine that verifies that the builtin size
of the destination buffer is at least as big as the size given by the
user.
- Redirect calls from inet_ntop to __inet_ntop_chk or __inet_ntop_warn
- Update the abilist for this new routine
- Update the manual to mention the new fortification

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-21 09:35:42 +01:00
Frédéric Bérat 3cdb99d8bb Add missing guards in include/arpa/inet.h
Add the missing guards in the header, similarly to other headers at the
same level

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-21 09:35:36 +01:00
Frédéric Bérat 84373ef7b7 Prepare inet_ntop to be fortified
Rename inet_ntop to __inet_ntop and create the inet_ntop weak alias
based on it in order to prepare for disabling fortification when
available.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-21 09:35:16 +01:00
Paul Zimmermann c5113a838b add inputs giving large errors for rsqrt 2025-03-19 09:11:44 +01:00
Wilco Dijkstra 575de3d666 malloc: Improve csize2tidx
Remove the alignment rounding up from csize2tidx - this makes no sense
since the input should be a chunk size.  Removing it enables further
optimizations, for example chunksize_nomask can be safely used and
invalid sizes < MINSIZE are not mapped to a valid tidx.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-18 19:19:33 +00:00
Adhemerval Zanella 5291d9f1e2 elf: Fix tst-origin make rules
The tst-origin build can fail with:

  /usr/bin/ld: [...]libc.so: undefined reference to `__tunable_is_initialized@GLIBC_PRIVATE'

Since the custom link invocation links against system glibc instead
of the built one.

The only requirement is to avoid liborigin.so linked with a full path,
which is the default for --enable-hardcoded-path-in-tests.  There
is no need to use a custom rule.

Checked on x86_64-linux-gnu.
2025-03-18 16:10:05 -03:00
Pierre Blanchard cf56eb28fa AArch64: Optimize algorithm in users of SVE expf helper
Polynomial order was unnecessarily high, unlocking multiple
optimizations.
Max error for new SVE expf is 0.88 +0.5ULP.
Max error for new SVE coshf is 2.56 +0.5ULP.
Performance improvement on Neoverse V1: expf (30%), coshf (26%).

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2025-03-18 17:15:18 +00:00
Wilco Dijkstra 9f551e28a7 malloc: Improve arena_for_chunk()
Change heap_max_size() to improve performance of arena_for_chunk().
Instead of a complex calculation, using a simple mask operation to get the
arena base pointer.  HEAP_MAX_SIZE should be larger than the huge page size,
otherwise heaps will use not huge pages.

On AArch64 this removes 6 instructions from arena_for_chunk(), and
bench-malloc-thread improves by 1.1% - 1.8%.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-18 17:14:34 +00:00
Wilco Dijkstra dd003db8d1 benchtests: Increase iterations of bench-malloc-simple
Increase iterations so it runs for ~1 second on modern CPUs.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-18 17:13:28 +00:00
Adhemerval Zanella 997f49fbad elf: Fix tst-origin make rules
Add tests-special before include Rules and compile liborigin.os with
MODULE_NAME set to testsuite instead of libc.
2025-03-17 16:15:07 -03:00
Samuel Thibault bfb2f2f481 htl: Make pthread_setcanceltype / state a cancellation point
as expected by tst-cancel32.
2025-03-15 19:45:55 +00:00
Siddhesh Poyarekar 10af00f7a1 tst-fopen-threaded: Only check EOF for failing read
The fread race checker looks for EOF in every thread, which is incorrect
since threads calling fread successfully could lag behind and read the
EOF condition, resulting in multiple threads thinking that they
encountered an EOF.

Only look for EOF condition if fread fails to read a char.  Also drop
the clearerr() since it could mask the failure of another reader, thus
hiding a test failure.

Finally, also check for error in the stream for completeness.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-14 12:28:05 -04:00
Joseph Myers 409668f6e8 Implement C23 powr
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the powr functions, which are like pow, but with simpler
handling of special cases (based on exp(y*log(x)), so negative x and
0^0 are domain errors, powers of -0 are always +0 or +Inf never -0 or
-Inf, and 1^+-Inf and Inf^0 are also domain errors, while NaN^0 and
1^NaN are NaN).  The test inputs are taken from those for pow, with
appropriate adjustments (including removing all tests that would be
domain errors from those in auto-libm-test-in and adding some more
such tests in libm-test-powr.inc).

The underlying implementation uses __ieee754_pow functions after
dealing with all special cases that need to be handled differently.
It might be a little faster (avoiding a wrapper and redundant checks
for special cases) to have an underlying implementation built
separately for both pow and powr with compile-time conditionals for
special-case handling, but I expect the benefit of that would be
limited given that both functions will end up needing to use the same
logic for computing pow outside of special cases.

My understanding is that powr(negative, qNaN) should raise "invalid":
that the rule on "invalid" for an argument outside the domain of the
function takes precedence over a quiet NaN argument producing a quiet
NaN result with no exceptions raised (for rootn it's explicit that the
0th root of qNaN raises "invalid").  I've raised this on the WG14
reflector to confirm the intent.

Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-03-14 15:58:11 +00:00
Sunil K Pandey c7c4a5906f x86_64: Add atanh with FMA
On SPR, it improves atanh bench performance by:

			Before		After		Improvement
reciprocal-throughput	15.1715		14.8628		2%
latency			57.1941		56.1883		2%

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-13 14:30:47 -07:00
Adhemerval Zanella 9b646f5dc9 elf: Canonicalize $ORIGIN in an explicit ld.so invocation [BZ 25263]
When an executable is invoked directly, we calculate $ORIGIN by calling
readlink on /proc/self/exe, which the Linux kernel resolves to the
target of any symlinks.  However, if an executable is run through ld.so,
we cannot use /proc/self/exe and instead use the path given as an
argument.  This leads to a different calculation of $ORIGIN, which is
most notable in that it causes ldd to behave differently (e.g., by not
finding a library) from directly running the program.

To make the behavior consistent, take advantage of the fact that the
kernel also resolves /proc/self/fd/ symlinks to the target of any
symlinks in the same manner, so once we have opened the main executable
in order to load it, replace the user-provided path with the result of
calling readlink("/proc/self/fd/N").

(On non-Linux platforms this resolution does not happen and so no
behavior change is needed.)

The __fd_to_filename requires _fitoa_word and _itoa_word, which for
32-bits pulls a lot of definitions from _itoa.c (due _ITOA_NEEDED
being defined).  To simplify the build move the required function
to a new file, _fitoa_word.c.

Checked on x86_64-linux-gnu and i686-linux-gnu.

Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com>
Reviewed-by: Geoffrey Thomas <geofft@ldpreload.com>
Tested-by: Geoffrey Thomas <geofft@ldpreload.com>
2025-03-13 16:50:16 -03:00
Sunil K Pandey dded0d20f6 x86_64: Add sinh with FMA
On SPR, it improves sinh bench performance by:

			Before		After		Improvement
reciprocal-throughput	14.2017		11.815		17%
latency			36.4917		35.2114		4%

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-13 10:55:25 -07:00
Adhemerval Zanella 5e1a64736e benchtests: Remove wrong snippet from 360cce0b06 2025-03-13 10:30:43 -03:00
Sunil K Pandey c6352111c7 x86_64: Add tanh with FMA
On Skylake, it improves tanh bench performance by:

	Before 		After 		Improvement
max	110.89		95.826		14%
min	20.966		20.157		4%
mean	30.9601		29.8431		4%

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-13 06:20:32 -07:00
Adhemerval Zanella 360cce0b06 nptl: Check if thread is already terminated in sigcancel_handler (BZ 32782)
The SIGCANCEL signal handler should not issue __syscall_do_cancel,
which calls __do_cancel and __pthread_unwind, if the cancellation
is already in proces (and libgcc unwind is not reentrant).  Any
cancellation signal received after is ignored.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.

Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-13 09:11:13 -03:00
Florian Weimer dbc5a50d12 nptl: PTHREAD_COND_INITIALIZER compatibility with pre-2.41 versions (bug 32786)
The new initializer and struct layout does not initialize the
__g_signals field in the old struct layout before the change in
commit c36fc50781 ("nptl: Remove
g_refs from condition variables").  Bring back fields at the end
of struct __pthread_cond_s, so that they are again zero-initialized.

Reviewed-by: Sam James <sam@gentoo.org>
2025-03-13 07:43:33 +01:00
zhenwei pi a8e9022e0f getaddrinfo.c: support MPTCP (BZ )
There is a lack of MPTCP support from gaih_inet_typeproto array, add
MPTCP entry.

Signed-off-by: zhenwei pi <zhenwei.pi@linux.dev>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-12 14:23:57 -03:00
Adhemerval Zanella 3e8814903c math: Refactor how to use libm-test-ulps
The current approach tracks math maximum supported errors by explicitly
setting them per function and architecture. On newer implementations or
new compiler versions, the file is updated with newer values if it
shows higher results. The idea is to track the maximum known error, to
update the manual with the obtained values.

The constant libm-test-ulps shows little value, where it is usually a
mechanical change done by the maintainer, for past releases it is
usually ignored whether the ulp change resulted from a compiler
regression, and the math tests already have a maximum ulp error that
triggers a regression.

It was shown by a recent update after the new acosf [1] implementation
that is correctly rounded, where the libm-test-ulps was indeed from a
compiler issue.

This patch removes all arch-specific libm-test-ulps, adds system generic
libm-test-ulps where applicable, and changes its semantics. The generic
files now track specific implementation constraints, like if it is
expected to be correctly rounded, or if the system-specific has
different error expectations.

Now multiple libm-test-ulps can be defined, and system-specific
overrides generic implementation.  This is for the case where
arch-specific implementation might show worse precision than generic
implementation, for instance, the cbrtf on i686.

Regressions are only reported if the implementation shows larger errors
than 9 ulps (13 for IBM long double) unless it is overridden by
libm-test-ulps and the maximum error is not printed at the end of tests.
The regen-ulps rule is also removed since it does not make sense to
update the libm-test-ulps automatically.

The manual error table is also removed, Paul Zimmermann and others have
been tracking libm precision with a more comprehensive analysis for some
releases; so link to his work instead.

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=9cc9f8e11e8fb8f54f1e84d9f024917634a78201
2025-03-12 13:40:07 -03:00
Joseph Myers eea6f1e079 Update syscall lists for Linux 6.13
Linux 6.13 adds four new syscalls.  Update syscall-names.list and
regenerate the arch-syscall.h headers with build-many-glibcs.py
update-syscalls.

Tested with build-many-glibcs.py.
2025-03-12 12:51:54 +00:00
Florian Weimer 517846c85d Makefile: Clean up pthread_atfork integration
Do not add the pthread_atfork routine again in nptl/Makefile,
instead rely on sysdeps/pthread/Makefile for the integration
(as this is the directory that contains the source file).

In sysdeps/pthread/Makefile, add to static-only-routines.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-12 12:37:11 +01:00