]> git.feebdaed.xyz Git - 0xmirror/glibc.git/log
0xmirror/glibc.git
2 days agoLoongArch: Use generic __builtin_trap in abort. master
caiyinyu [Fri, 19 Dec 2025 08:23:03 +0000 (16:23 +0800)]
LoongArch: Use generic __builtin_trap in abort.

Reviewed-by: Xi Ruoyao <xry111@xry111.site>
4 days agomalloc: Fix clang build after 1c588a2187
Adhemerval Zanella [Mon, 22 Dec 2025 14:42:18 +0000 (14:42 +0000)]
malloc: Fix clang build after 1c588a2187

clang issues:

malloc.c:1909:8: error: converting the result of '<<' to a boolean always evaluates to true [-Werror,-Wtautological-constant-compare]
 1909 |   if (!DEFAULT_THP_PAGESIZE || mp_.thp_mode != malloc_thp_mode_not_supported)
      |        ^
../sysdeps/unix/sysv/linux/aarch64/malloc-hugepages.h:19:35: note: expanded from macro 'DEFAULT_THP_PAGESIZE'
   19 | #define DEFAULT_THP_PAGESIZE    (1UL << 21)

Checked on aarch64-linux-gnu.

4 days agoelf: Fix elf/tst-decorate-maps on aarch64 after 321e1fc73f
Adhemerval Zanella [Wed, 17 Dec 2025 20:55:18 +0000 (17:55 -0300)]
elf: Fix elf/tst-decorate-maps on aarch64 after 321e1fc73f

The intention of the call "xmalloc(256 * 1024)" in tst-decorate-maps is
to force malloc() to fall back to using mmap() since such an amount
won't be available from the main heap.

Post 321e1fc73f, on aarch64, the heap gets extended by default by at
least 2MB, thus the aforementioned call may get satisfied on the main
heap itself. Thus, increase the amount of memory requested to force the
mmap() path again.

Checked on aarch64-linux-gnu.

4 days agomisc: Enable tst-atomic for clang
Adhemerval Zanella [Fri, 19 Dec 2025 18:52:24 +0000 (15:52 -0300)]
misc: Enable tst-atomic for clang

The atomic.h macros now uses compiler builtins.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 days agomath: Use math_opt_barrier on ldbl-128 powl underflow/overflow handling
Adhemerval Zanella [Fri, 19 Dec 2025 18:52:23 +0000 (15:52 -0300)]
math: Use math_opt_barrier on ldbl-128 powl underflow/overflow handling

This avoids compiler to move the operation before the 'iy' compare.

It fixes math/test-float128-pow regreesions when building with clang [1]:

Failure: pow (-0x1.000002p+0, 0xf.ffffffffffff8p+1020): Exception "Underflow" set
Failure: pow (-0x1.000002p+0, 0xf.ffffffffffffbffffffffffffcp+1020): Exception "Underflow" set
Failure: pow (-0x1.000002p+0, 0xf.fffffffffffffffffffffffffff8p+16380): Exception "Underflow" set
Failure: pow (-0x1.000002p+0, 0xf.fffffffffffffffp+16380): Exception "Underflow" set
Failure: pow (-0x1.000002p+0, 0xf.fffffp+124): Exception "Underflow" set
Failure: pow (-0x1.00000ep+0, 0xf.ffffffffffff8p+1020): Exception "Underflow" set
Failure: pow (-0x1.00000ep+0, 0xf.ffffffffffffbffffffffffffcp+1020): Exception "Underflow" set
Failure: pow (-0x1.00000ep+0, 0xf.fffffffffffffffffffffffffff8p+16380): Exception "Underflow" set
Failure: pow (-0x1.00000ep+0, 0xf.fffffffffffffffp+16380): Exception "Underflow" set
Failure: pow (-0x2p+0, -0xf.ffffffffffff8p+1020): Exception "Overflow" set
Failure: pow (-0x2p+0, -0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: pow (-0x2p+0, -0xf.fffffffffffffffffffffffffff8p+16380): Exception "Overflow" set
Failure: pow (-0x2p+0, -0xf.fffffffffffffffp+16380): Exception "Overflow" set
Failure: pow (-0x2p+0, -0xf.fffffp+124): Exception "Overflow" set
Failure: pow (-0x2p+0, 0xf.ffffffffffff8p+1020): Exception "Underflow" set
Failure: pow (-0x2p+0, 0xf.ffffffffffffbffffffffffffcp+1020): Exception "Underflow" set
Failure: pow (-0x2p+0, 0xf.fffffffffffffffffffffffffff8p+16380): Exception "Underflow" set
Failure: pow (-0x2p+0, 0xf.fffffffffffffffp+16380): Exception "Underflow" set
Failure: pow (-0x2p+0, 0xf.fffffp+124): Exception "Underflow" set
[...]

Checked on x86_64-linux-gnu and aarch64-linux-gnu with gcc-15 and
clang-18.

[1] https://github.com/llvm/llvm-project/issues/173080

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 days agostdio: Fix tst-vfprintf-user-type on clang
Adhemerval Zanella [Fri, 19 Dec 2025 18:52:22 +0000 (15:52 -0300)]
stdio: Fix tst-vfprintf-user-type on clang

The pointer alias comparison will be optimized away by the compiler,
so use an indirection point to prevent it (similar to
malloc/tst-malloc-aux.h).

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 days agox86: Do not use __builtin_isinf_sign for _Float64x/long double
Adhemerval Zanella [Fri, 19 Dec 2025 18:52:21 +0000 (15:52 -0300)]
x86: Do not use __builtin_isinf_sign for _Float64x/long double

Neither gcc [1] nor clang [2] handles pseudo-normal numbers correctly
with the __builtin_isinf_sign, so disable its usage for _Float64x and
long double types.

This only affects x86, so add a new define __FP_BUILTIN_ISINF_SIGN_DENORMAL
to gate long double and related types to the libc function instead.

It fixes the regression on test-ldouble-isinf when built with clang:

Failure: isinf (pseudo_zero): Exception "Invalid operation" set
Failure: isinf (pseudo_inf): Exception "Invalid operation" set
Failure: isinf (pseudo_qnan): Exception "Invalid operation" set
Failure: isinf (pseudo_snan): Exception "Invalid operation" set
Failure: isinf (pseudo_unnormal): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_zero): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_inf): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_qnan): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_snan): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_unnormal): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_zero): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_inf): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_qnan): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_snan): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_unnormal): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_zero): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_inf): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_qnan): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_snan): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_unnormal): Exception "Invalid operation" set

Checked on x86_64-linux-gnu with gcc-15 and clang-18.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123173
[2] https://github.com/llvm/llvm-project/issues/172651

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 days agox86: Do not use __builtin_fpclassify for _Float64x/long double
Adhemerval Zanella [Fri, 19 Dec 2025 18:52:20 +0000 (15:52 -0300)]
x86: Do not use __builtin_fpclassify for _Float64x/long double

Neither gcc [1] nor clang [2] handles pseudo-normal numbers correctly
with the __builtin_fpclassify, so disable its usage for _Float64x and
long double types.

This only affects x86, so add a new header, fp-builtin-denormal.h, that
defines whether the architecture requires disabling the optimization
through a new glibc define (__FP_BUILTIN_FPCLASSIFY_DENORMAL).

It fixes the regression on test-ldouble-fpclassify and
test-float64x-fpclassify when built with clang:

Failure: fpclassify (pseudo_zero): Exception "Invalid operation" set
Failure: fpclassify (pseudo_inf): Exception "Invalid operation" set
Failure: fpclassify (pseudo_qnan): Exception "Invalid operation" set
Failure: fpclassify (pseudo_snan): Exception "Invalid operation" set
Failure: fpclassify (pseudo_unnormal): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_zero): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_inf): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_qnan): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_snan): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_unnormal): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_zero): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_inf): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_qnan): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_snan): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_unnormal): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_zero): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_inf): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_qnan): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_snan): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_unnormal): Exception "Invalid operation" set

Checked on x86_64-linux-gnu with gcc-15 and clang-18.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123161
[2] https://github.com/llvm/llvm-project/issues/172533

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
5 days agoresolv: Add test for NOERROR/NODATA handling [BZ #14308]
Sergey Kolosov [Mon, 15 Dec 2025 12:00:01 +0000 (13:00 +0100)]
resolv: Add test for NOERROR/NODATA handling [BZ #14308]

Add a test which verifies that getaddrinfo does not fail if one of A/AAAA
responses is NOERROR/NODATA reply with recursion unavailable and the other
response provides an address.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 days agoriscv: Add RVV memset for both multiarch and non-multiarch builds
Yao Zihong [Fri, 19 Dec 2025 23:46:42 +0000 (17:46 -0600)]
riscv: Add RVV memset for both multiarch and non-multiarch builds

This patch adds an RVV-optimized implementation of memset for RISC-V and
enables it for both multiarch (IFUNC) and non-multiarch builds.

The implementation integrates Hau Hsu's 2023 RVV work under a unified
ifunc-based framework. A vectorized version (__memset_vector) is added
alongside the generic fallback (__memset_generic). The runtime resolver
selects the RVV variant when RISCV_HWPROBE_KEY_IMA_EXT_0 reports vector
support (RVV).

Currently, the resolver still selects the RVV variant even when the RVV
extension is disabled via prctl(). As a consequence, any process that
has RVV disabled via prctl() will receive SIGILL when calling memset().

Co-authored-by: Jerry Shih <jerry.shih@sifive.com>
Co-authored-by: Jeff Law <jeffreyalaw@gmail.com>
Signed-off-by: Yao Zihong <zihong.plct@isrc.iscas.ac.cn>
Reviewed-by: Peter Bergner <bergner@tenstorrent.com>
8 days agostdlib: Avoid strlen plt with clang
Adhemerval Zanella [Wed, 17 Dec 2025 17:51:53 +0000 (14:51 -0300)]
stdlib: Avoid strlen plt with clang

The clang-21 LoopIdiomRecognizePass replaces some loops in
__xpg_basename with a strlen call.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
8 days agomath: Do not use __builtin_isgreater* and __builtin_isless* on clang
Adhemerval Zanella [Wed, 17 Dec 2025 17:51:47 +0000 (14:51 -0300)]
math: Do not use __builtin_isgreater* and __builtin_isless* on clang

clang does not check for unordered numbers with builtins for 128-bit
float types (both _Float128 on x86_64 or long double on aarch64) [1].

For instance, the code:

  #ifdef __x86_64__
  typedef __float128 FLOAT128_TYPE;
  #elif defined (__aarch64__)
  typedef long double FLOAT128_TYPE;
  #endif

  int foo (FLOAT128_TYPE x, FLOAT128_TYPE y)
  {
    return __builtin_isgreater (x, y);
  }

Will issue a __gttf2 call instead of a __unordtf2 followed by the
comparison.

Using the generic implementation fixes multiple issues with math tests,
such as:

Failure: fmax (0, qNaN): Exception "Invalid operation" set
Failure: fmax (0, -qNaN): Exception "Invalid operation" set
Failure: fmax (-0, qNaN): Exception "Invalid operation" set
Failure: fmax (-0, -qNaN): Exception "Invalid operation" set
Failure: fmax (9, qNaN): Exception "Invalid operation" set
Failure: fmax (9, -qNaN): Exception "Invalid operation" set
Failure: fmax (-9, qNaN): Exception "Invalid operation" set
Failure: fmax (-9, -qNaN): Exception "Invalid operation" set

It has a small performance overhead due to the extra isunordered (which
could be omitted for float and double types). Using _Generic (similar to
how __MATH_TG) on a bivariadic function requires a lot of boilerplate
macros.

[1] https://github.com/llvm/llvm-project/issues/172499
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
8 days agoelf: Support vDSO with more than one PT_LOAD with v_addr starting at 0 (BZ 32583)
Adhemerval Zanella [Tue, 9 Dec 2025 21:35:13 +0000 (18:35 -0300)]
elf: Support vDSO with more than one PT_LOAD with v_addr starting at 0 (BZ 32583)

The setup_vdso assumes that vDSO will contain only one PT_LOAD segment
and that 0 is the sentinel for the start mapping address.  Although
the kernel avoids adding more than one PT_LOAD to avoid compatibility
issues, there is no impending issue that prevents glibc from supporting
vDSO with multiple PT_LOAD (as some wrapper tools do [1]).

To support multiple PT_LOAD segments, replace the sentinel with a bool
to indicate that the VMA start has already been set.

Testing is really tricky, since the bug report does not indicate which
tool was used to trigger the issue, nor a runtime that provides a vDSO
with multiple PT_LOAD.  I had to modify the qemu user with a custom
script to create 2 PT_LOAD sections, remove checks that prevent the
vDSO object from being created, and remove the load bias adjustment
in load_elf_vdso.  I could not come up with an easy test case to
integrate with glibc.

The Linux kernel provides vDSO with only one PT_LOAD due to
compatibility reasons. For instance

* arch/arm64/kernel/vdso/vdso.lds.S

86 /*
87  * We must supply the ELF program headers explicitly to get just one
88  * PT_LOAD segment, and set the flags explicitly to make segments read-only.
89  /
90 PHDRS
91 {
92         text            PT_LOAD         FLAGS(5) FILEHDR PHDRS; / PF_R|PF_X /
93         dynamic         PT_DYNAMIC      FLAGS(4);               / PF_R /
94         note            PT_NOTE         FLAGS(4);               / PF_R */
95 }

* arch/x86/entry/vdso/vdso-layout.lds.S

95 /*
96  * We must supply the ELF program headers explicitly to get just one
97  * PT_LOAD segment, and set the flags explicitly to make segments read-only.
98  /
99 PHDRS
100 {
101         text            PT_LOAD         FLAGS(5) FILEHDR PHDRS; / PF_R|PF_X /
102         dynamic         PT_DYNAMIC      FLAGS(4);               / PF_R /
103         note            PT_NOTE         FLAGS(4);               / PF_R */
104         eh_frame_hdr    PT_GNU_EH_FRAME;
105 }

Checked on aarch64-linux-gnu.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=32583#c2

Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 days agonptl: Make pthread_{clock, timed}join{_np} act on all cancellation (BZ 33717)
Adhemerval Zanella [Thu, 11 Dec 2025 20:47:22 +0000 (17:47 -0300)]
nptl: Make pthread_{clock, timed}join{_np} act on all cancellation (BZ 33717)

The pthread_join/pthread_timedjoin_np/pthread_clockjoin_np will not act
on cancellation if 1. some other thread is already waiting on the 'joinid'
or 2. If the thread has already exited.

On nptl/pthread_join_common.c, the 1. is due to the CAS doing an early
return:

 80   else if (__glibc_unlikely (atomic_compare_exchange_weak_acquire (&pd->joinid,
 81                                                                    &self,
 82                                                                    NULL)))
 83     /* There is already somebody waiting for the thread.  */
 84     return EINVAL;

And 2. is due to the pd->tid equal to 0:

 99       pid_t tid;
100       while ((tid = atomic_load_acquire (&pd->tid)) != 0)
101         {

The easiest solution would be to add an __pthread_testcancel () on
__pthread_clockjoin_ex () if 'cancel' is true.

Checked on aarch64-linux-gnu, arm-linux-gnueabihf, x86_64-linux-gnu,
and i686-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 days agosupport: Add support_thread_state_wait
Adhemerval Zanella [Thu, 11 Dec 2025 20:47:21 +0000 (17:47 -0300)]
support: Add support_thread_state_wait

Same as support_process_state_wait, but wait for the task TID
(obtained with gettid) from the current process.  Since the kernel
might remove the /proc/<pid>/task/<tid>/status at any time if the
thread terminates, the code needs to handle possible
fopen/getline/fclose failures due to an inexistent file.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 days agonptl: Remove INVALID_TD_P
Adhemerval Zanella [Thu, 11 Dec 2025 20:47:20 +0000 (17:47 -0300)]
nptl: Remove INVALID_TD_P

And use the new __pthread_descriptor_valid function that checks
for 'joinstate' to get the thread state instead of 'tid'.  The
joinstate is set by the kernel when the thread exits.

Checked on x86_64-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 days agonptl: Do not use pthread set_tid_address as state synchronization (BZ #19951)
Adhemerval Zanella [Thu, 11 Dec 2025 20:47:19 +0000 (17:47 -0300)]
nptl: Do not use pthread set_tid_address as state synchronization (BZ #19951)

The use-after-free described in BZ#19951 is due to the use of two
different PD fields, 'joinid' and 'cancelhandling', to describe the
thread state and to synchronise the calls of pthread_join,
pthread_detach, pthread_exit, and normal thread exit.

Any state change may require checking both fields atomically to handle
partial state (e.g., pthread_join() with a cancellation handler to
issue a 'joinstate' field rollback).

This patch uses a different PD member with 4 possible states (JOINABLE,
DETACHED, EXITING, and EXITED) instead of the pthread 'tid' field, with
the following logic:

 1. On pthread_create, the initial state is set either to JOINABLE or
    DETACHED depending on the pthread attribute used.

 2. On pthread_detach, a CAS is issued on the state.  If the CAS fails,
    the thread is already detached (DETACHED) or being terminated (EXITING).
    For the former, an EINVAL is returned; for the latter, pthread_detach
    should be responsible for joining the thread (and for deallocating any
    internal resources).

 3. In the exit phase of the wrapper function for the thread start routine
    (reached either if the thread function has returned, pthread_exit has
    been called, or cancellation handled has been acted upon), we issue a
    CAS on state to set it to the EXITING mode.

    If the thread is previously in DETACHED mode, the thread is responsible
    for deallocating any resources; otherwise, the thread must be joined
    (detached threads cannot deallocate themselves immediately).

 4. The clear_tid_field on 'clone' call is changed to set the new 'state'
    field on thread exit (EXITED).  This state is only reached at thread
    termination.

 5. The pthread_join implementation is now simpler: the futex wait is done
    directly on thread state, and there is no need to reset it in case of
    timeout since the state is now set either by pthread_detach() or by the
    kernel on process termination.

The race condition on pthread_detach is avoided with a single atomic
operation on the PD state: once the mode is set to THREAD_STATE_DETACHED, it
is up to the thread itself to deallocate its memory (done during the exit
phase at pthread_create()).

Also, the INVALID_NOT_TERMINATED_TD_P is removed since a negative yid is
not possible, and the macro is not used anywhere.

This change triggers an invalid C11 thread test: it creates a thread that
detaches, and after a timeout, the creating thread checks whether the join
fails.  The issue is that once thrd_join() is called, the thread's lifetime
is not defined.

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
arm-linux-gnueabihf, and powerpc64-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 days agonptl: Set cancellation type and state on pthread_exit (BZ #28267)
Adhemerval Zanella [Thu, 11 Dec 2025 20:47:18 +0000 (17:47 -0300)]
nptl: Set cancellation type and state on pthread_exit (BZ #28267)

It is required by POSIX XSH 2.9.5 Thread Cancellation under the
heading Thread Cancellation Cleanup Handlers.

Checked x86_64-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 days agonptl: Use __futex_abstimed_wait64 on pthread_create (BZ 33715)
Adhemerval Zanella [Thu, 11 Dec 2025 20:47:17 +0000 (17:47 -0300)]
nptl: Use __futex_abstimed_wait64 on pthread_create (BZ 33715)

The pthread_create is annotated as __THROWNL.

Checked on x86_64-linux-gnu.

Suggested-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 days agobuild-many-glibcs.py: Fix s390x-linux-gnu.
Stefan Liebler [Fri, 19 Dec 2025 10:19:53 +0000 (11:19 +0100)]
build-many-glibcs.py: Fix s390x-linux-gnu.

The recent commit 638d437dbf9c68e40986edaa9b0d1c2e72a1ae81
"Deprecate s390-linux-gnu (31bit)"
leads to:
FAIL: compilers-s390x-linux-gnu gcc build
when it tries to build 31bit libgcc.

The build is fixed by explicitely disabling multilib.

8 days agohurd/i386: Remove stale __GNUC_PREREQ (6, 0) test from tls.h
Uros Bizjak [Thu, 18 Dec 2025 08:13:46 +0000 (09:13 +0100)]
hurd/i386: Remove stale __GNUC_PREREQ (6, 0) test from tls.h

GCC 12 is currently the minimum supported compiler version.
Remove no longer needed __GNUC_PREREQ (6, 0) test and corresponding
dead code from tls.h.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 days agonptl: Optimize trylock for high cache contention workloads (BZ #33704)
Sunil K Pandey [Tue, 9 Dec 2025 16:57:44 +0000 (08:57 -0800)]
nptl: Optimize trylock for high cache contention workloads (BZ #33704)

Check lock availability before acquisition to reduce cache line
bouncing.  Significantly improves trylock throughput on multi-core
systems under heavy contention.

Tested on x86_64.

Fixes BZ #33704.

Co-authored-by: Alex M Wells <alex.m.wells@intel.com>
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
9 days agoRegenerate sysdeps/x86_64/configure
Adhemerval Zanella [Thu, 18 Dec 2025 14:09:33 +0000 (11:09 -0300)]
Regenerate sysdeps/x86_64/configure

It fixes the 9b8c2b8294 commit.

9 days agox86_64: Fix mark-plt configure test
Adhemerval Zanella [Wed, 17 Dec 2025 17:51:52 +0000 (14:51 -0300)]
x86_64: Fix mark-plt configure test

The configure check might ignore if compiler driver warns that the
option is no support, so force fatal warnings.

If fixes the elf/tst-plt-rewrite{1,2} regressions when ld.lld is used.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
9 days agomath: Fix potential underflow on ldbl-128 erfl
Adhemerval Zanella [Wed, 17 Dec 2025 17:51:51 +0000 (14:51 -0300)]
math: Fix potential underflow on ldbl-128 erfl

The multiplication operation is required only if the branch is taken,
and the compiler might not optimize it away.

It fixes the following issues when the testcase is built with clang:

FAIL: math/test-ldouble-erf
Failure: erf (-0x4p-16384): Exception "Underflow" set
Failure: erf (0x1p-10000): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded552p-16384): Exception "Underflow" set
Failure: erf (0x4p-16384): Exception "Underflow" set
Failure: erf_downward (-0x4p-16384): Exception "Underflow" set
Failure: erf_downward (0x1p-10000): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded552p-16384): Exception "Underflow" set
Failure: erf_downward (0x4p-16384): Exception "Underflow" set
Failure: erf_towardzero (-0x4p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x1p-10000): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded552p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x4p-16384): Exception "Underflow" set
Failure: erf_upward (-0x4p-16384): Exception "Underflow" set
Failure: erf_upward (0x1p-10000): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded552p-16384): Exception "Underflow" set
Failure: erf_upward (0x4p-16384): Exception "Underflow" set

Checked on x86_64-linux-gnu and aarch64-linux-gnu with gcc-15 and
clang-18.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
9 days agoatomic: Reinstate HAVE_64B_ATOMICS configure check
Wilco Dijkstra [Mon, 15 Dec 2025 13:56:14 +0000 (13:56 +0000)]
atomic: Reinstate HAVE_64B_ATOMICS configure check

Reinstate HAVE_64B_ATOMICS configure check that was reverted by commit
7fec8a5de6826ef9ae440238d698f0fe5a5fb372 due to BZ #33632.  This was
fixed by 3dd2cbfa35e0e6e0345633079bd5a83bb822c2d8 by only allowing
64-bit atomics on sem_t if its type is 8-byte aligned.  Rebase and add
in cleanups in include/atomic.h that were omitted.

Fix an issue with sparcv8-linux-gnu-leon3 forcing -mcpu=v8 for rtld.c which
overrules -mcpu=leon3 and causes __atomic_always_lock_free (4, 0) to
incorrectly return 0 and trigger asserts in atomics.  Remove this as it
seems to be a workaround for an issue in 1997.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
9 days agomalloc: Improve thp_init
Wilco Dijkstra [Fri, 12 Dec 2025 11:58:28 +0000 (11:58 +0000)]
malloc: Improve thp_init

Cleanup thp_init, change it so that the DEFAULT_THP_PAGESIZE
setting can be overridden with glibc.malloc.hugetlb=0 tunable.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
10 days agolinux: Update kernel version to 6.17 in tst-openat2-consts.py
Adhemerval Zanella [Thu, 11 Dec 2025 13:22:55 +0000 (10:22 -0300)]
linux: Update kernel version to 6.17 in tst-openat2-consts.py

No need constant was added between 6.8 and 6.17.

10 days agoUpdates struct tcp_info and TCP_AO_XX corresponding struct from 6.17 to netinet/tcp.h
Jiayuan Chen [Mon, 17 Nov 2025 08:06:48 +0000 (16:06 +0800)]
Updates struct tcp_info and TCP_AO_XX corresponding struct from 6.17 to netinet/tcp.h

This patch updates struct tcp_info to include new fields from Linux 6.17:
- tcpi_pacing_rate, tcpi_max_pacing_rate
- tcpi_bytes_acked, tcpi_bytes_received
- tcpi_delivery_rate, tcpi_busy_time
- tcpi_delivered, tcpi_delivered_ce
- and many other TCP metrics

Additionally, this patch adds:
- TCP_AO_* definitions (Authentication Option)
- struct tcp_diag_md5sig for INET_DIAG_MD5SIG
- Netlink attribute types for SCM_TIMESTAMPING_OPT_STATS

All changes are synchronized from the Linux kernel's tcp.h without
functional modifications, only code style changes.

Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
10 days agomalloc: set default tcache fill count to 16
Dev Jain [Wed, 10 Dec 2025 15:03:22 +0000 (15:03 +0000)]
malloc: set default tcache fill count to 16

Now that the fastbins are gone, set the default per size class length of
tcache to 16. We observe that doing this retains the original performance
of malloc.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomalloc: Remove fastbin comments
Dev Jain [Wed, 10 Dec 2025 15:02:27 +0000 (15:02 +0000)]
malloc: Remove fastbin comments

Now that all the fastbin code is gone, remove the remaining comments
referencing fastbins.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomalloc: Remove fastbin infrastructure
Dev Jain [Wed, 10 Dec 2025 15:01:34 +0000 (15:01 +0000)]
malloc: Remove fastbin infrastructure

Now that all users of the fastbin code are gone, remove the fastbin
infrastructure.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomalloc: Remove do_check_remalloced_chunk
Dev Jain [Wed, 10 Dec 2025 15:00:18 +0000 (15:00 +0000)]
malloc: Remove do_check_remalloced_chunk

do_check_remalloced_chunk checks properties of fastbin chunks. But, it is also
used to check properties of other chunks. Hence, remove this and merge the body
of the function in do_check_malloced_chunk.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomalloc: remove fastbin code from malloc_info
Dev Jain [Wed, 10 Dec 2025 14:59:17 +0000 (14:59 +0000)]
malloc: remove fastbin code from malloc_info

In preparation for removal of fastbins, remove all fastbin code from
malloc_info.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomalloc: remove fastbin code from do_check_malloc_state
Dev Jain [Wed, 10 Dec 2025 14:57:57 +0000 (14:57 +0000)]
malloc: remove fastbin code from do_check_malloc_state

In preparation for removal of fastbins, remove all fastbin code from
do_check_malloc_state.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomalloc: remove mallopt fastbin stats
Dev Jain [Wed, 10 Dec 2025 14:56:37 +0000 (14:56 +0000)]
malloc: remove mallopt fastbin stats

In preparation for removal of fastbins, remove all fastbin code from
mallopt.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomalloc: remove allocation from fastbin, and trim_fastbins
Dev Jain [Wed, 10 Dec 2025 14:55:46 +0000 (14:55 +0000)]
malloc: remove allocation from fastbin, and trim_fastbins

In preparation for removal of fastbins, remove the fastbin allocation
path, and remove the TRIM_FASTBINS code.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomalloc: remove malloc_consolidate
Dev Jain [Wed, 10 Dec 2025 14:54:51 +0000 (14:54 +0000)]
malloc: remove malloc_consolidate

In preparation for removal of fastbins, remove the consolidation
infrastructure of fastbins.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomalloc: remove fastbin tests
Dev Jain [Wed, 10 Dec 2025 14:53:24 +0000 (14:53 +0000)]
malloc: remove fastbin tests

Remove all the fastbin tests in preparation for removing the fastbins.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agoDeprecate s390-linux-gnu (31bit)
Stefan Liebler [Tue, 16 Dec 2025 14:20:29 +0000 (15:20 +0100)]
Deprecate s390-linux-gnu (31bit)

The next linux 6.19 release will remove support for compat syscalls on s390x with those commits:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0d79affa31cbee477a45642efc49957d05466307
0d79affa31cb Merge branch 'compat-removal'
4ac286c4a8d9 s390/syscalls: Switch to generic system call table generation
f4e1f1b1379d s390/syscalls: Remove system call table pointer from thread_struct
3db5cf935471 s390/uapi: Remove 31 bit support from uapi header files
8e0b986c59c6 s390: Remove compat support
169ebcbb9082 tools: Remove s390 compat support
7afb095df3e3 s390/syscalls: Add pt_regs parameter to SYSCALL_DEFINE0() syscall wrapper
b2da5f6400b4 s390/kvm: Use psw32_t instead of psw_compat_t
8c633c78c23a s390/ptrace: Rename psw_t32 to psw32_t

This patch also removes s390-linux-gnu (31bit) from build-many-glibcs.py.
Then the next update of syscall numbers for Linux 6.19 won't change
sysdeps/unix/sysv/linux/s390/s390-32/arch-syscall.h
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
10 days agobenchtests: Add pthread mutex trylock recursive throughput test (BZ #33704)
Sunil K Pandey [Tue, 16 Dec 2025 05:53:51 +0000 (21:53 -0800)]
benchtests: Add pthread mutex trylock recursive throughput test (BZ #33704)

This benchmark measures number of successful updates per second
under high cache contention.

Tested on x86_64.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
10 days agobenchtests: Refactor pthread trylock throughput test (BZ #33704)
Sunil K Pandey [Tue, 16 Dec 2025 12:36:29 +0000 (04:36 -0800)]
benchtests: Refactor pthread trylock throughput test (BZ #33704)

Refactor pthread trylock throughput benchmark test.
No functionality change.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agobenchtests: Add pthread mutex trylock throughput test (BZ #33704)
Sunil K Pandey [Thu, 11 Dec 2025 19:54:05 +0000 (11:54 -0800)]
benchtests: Add pthread mutex trylock throughput test (BZ #33704)

This benchmark measures number of successful updates per second
under high cache contention.

Tested on x86_64.

Co-authored-by: Alex M Wells <alex.m.wells@intel.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agoposix: Fix getconf symbolic constants defined in limits.h (BZ# 29147)
Adhemerval Zanella Netto [Tue, 9 Dec 2025 13:45:24 +0000 (10:45 -0300)]
posix: Fix getconf symbolic constants defined in limits.h (BZ# 29147)

POSIX-1.2018 defines that getconf utility shall print symbolic constant
listed under the heading Maximum value and Minimum Values [1], however
current behaviour is to print the values using pathconf or sysconf,
which represents the specific implementation values instead of the
system agnostics ones.

Another issue is for such the symbolic constants, getconf handles them
as a path_var which requires an additional pathname (which does not
make sense for constants values).

The patch fixes it adding a new internal type, LIMITS_H, which only
prints the constant symbolic without requiring an additional path.
Only the values define in glibc provided limits.h plust the GNU
extensions are handled.

Checked on x86_64-linux-gnu.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/getconf.html)

Tested-by: Yury Khrustalev <yury.khrustalev@arm.com>
Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
2 weeks agoconfigure: use TEST_CC to check for --depaudit
Adhemerval Zanella [Tue, 9 Dec 2025 14:58:33 +0000 (11:58 -0300)]
configure: use TEST_CC to check for --depaudit

The ld.lld does not support this option.
Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoconfigure: use TEST_CC to check for --no-error-execstack
Adhemerval Zanella [Tue, 9 Dec 2025 14:58:32 +0000 (11:58 -0300)]
configure: use TEST_CC to check for --no-error-execstack

The ld.lld does not support the --no-error-execstack option, and it is
required only to suppress the linker warning while building tests. A new
configure macro, LIBC_TEST_LINKER_FEATURE, is added to check for linker
features using TEST_CC instead of CC.

Checked on x86_64-linux-gnu and aarch64-linux-gnu with gcc and
TEST_CC set to clang-18 and clan-21.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agomanual: Fix madvise typo in mseal documentation
Florian Weimer [Thu, 11 Dec 2025 10:57:44 +0000 (11:57 +0100)]
manual: Fix madvise typo in mseal documentation

2 weeks agomalloc: Enable 2MB THP by default on Aarch64
Dev Jain [Wed, 10 Dec 2025 14:50:44 +0000 (14:50 +0000)]
malloc: Enable 2MB THP by default on Aarch64

Add missing files from previous commit.

2 weeks agomalloc: Enable 2MB THP by default on Aarch64
Dev Jain [Wed, 10 Dec 2025 12:15:18 +0000 (12:15 +0000)]
malloc: Enable 2MB THP by default on Aarch64

Linux supports multi-sized Transparent Huge Pages (mTHP). For the purpose
of this patch description, we call the block size mapped by a non-last
level pagetable level, the traditional THP size (2M for 4K basepage,
512M for 64K basepage). Linux now also supports intermediate THP sizes
mapped by the last level pagetable - we call that the mTHP size.

The support for mTHP in Linux has grown to be better and stable over time -
applications can benefit from reduced page faults and reduced kernel
memory management overhead, albeit at the cost of internal fragmentation.
We have observed consistent performance boosts with mTHP with little
variance.

As a result, enable 2M THP by default on Aarch64. This enables THP even if
user hasn't passed glibc.malloc.hugetlb=1. If user has passed it, we avoid
making the system call to check the hugepage size from sysfs, and override
it with the hardcoded 2MB.

There are two additional benefits of this patch, if the transparent
hugepage sysctl is set to madvise or always:

1) The THP size is now hardcoded to 2MB for Aarch64. This avoids a
syscall for fetching the THP size from sysfs.

2) On 64K basepage size systems, the traditional THP size is 512M, which
is unusable and impractical. We can instead benefit from the mTHP size of
2M. Apart from the usual benefit of THPs/mTHPs as described above, Aarch64
systems benefit from reduced TLB pressure on this mTHP size, commonly
known as the "contpte" size. If the application takes a pagefault, and
either the THP sysctl settings is "always", or the virtual memory area
has been madvise(MADV_HUGEPAGE)'d along with sysctl being "madvise", then
Linux will fault in a 2M mTHP, mapping contiguous pages into the pagetable,
and painting the pagetable entries with the cont-bit. This bit is a hint to
the hardware that the concerned pagetable entry maps a page which is part
of a set of contiguous pages - the TLB then only remembers a single entry
for this set of 2M/64K = 32 pages, because the physical address of any
other page in this contiguous set is computable by the TLB cached physical
address via a linear offset. Hence, what was only possible with the
traditional THP size, is now possible with the mTHP size.

We see a 6.25% performance improvement on SPEC.

If the sysctl is set to never, no transparent hugepages will be created by
the kernel. But, this patch still sets thp_pagesize = 2MB. The benefit is
that on MORECORE() invocation, we extend the heap by 2MB instead of 4KB,
potentially reducing the frequency of this syscall's invocation by 512x.
Note that, there is no difference in cost between an sbrk(2M) and sbrk(4K);
the kernel only does a virtual reservation and does not touch user physical
memory.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2 weeks agomalloc: Do not make out-of-bounds madvise call on non-aligned heap
Dev Jain [Wed, 10 Dec 2025 12:09:36 +0000 (12:09 +0000)]
malloc: Do not make out-of-bounds madvise call on non-aligned heap

Currently, if the initial program break is not aligned to the system page
size, then we align the pointer down to the page size. If there is a gap
before the heap VMA, then such an adjustment means that the madvise() range
now contains a gap. The behaviour in the upstream kernel is currently this:
madvise() will return -ENOMEM, even though the operation will still succeed
in the sense that the VM_HUGEPAGE flag will be set on the heap VMA. We
*must not* depend on this behaviour - this is an internal kernel
implementation, and earlier kernels may possibly abort the operation
altogether.

The other case is that there is no gap, and as a result we may end up
setting the VM_HUGEPAGE flag on that other VMA too, which is an
unnecessary side effect.

Let us fix this by aligning the pointer up to the page size. We should
also subtract the pointer difference from the size, because if we don't,
since the pointer is now aligned up, the size may cross the heap VMA, thus
leading to the same problem but at the other end.

There is no need to check this new size against mp_.thp_pagesize to decide
whether to make the madvise() call. The reason we make this check at the
start of madvise_thp() is to check whether the size of the VMA is enough
to map THPs into it. Since that check has passed, all that we need to
ensure now is that q + size does not cross the heap VMA.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2 weeks agolinux: Add openat2 (BZ 31664)
Adhemerval Zanella [Wed, 19 Nov 2025 16:44:34 +0000 (13:44 -0300)]
linux: Add openat2 (BZ 31664)

The openat2 syscall was added on Linux 5.6, as an extension of openat.
Unlike other open-like functions, the kernel only provides the LFS
variant (so files larger than 4GB always succeed, unlike other
functions with an offset larger than off_t).  Also, similar to other
open functions, the new symbol is a cancellable entrypoint.

The test case added only stress tests for some of the syscalls' provided
functionality, and it is based on an existing kernel self-test.

A fortify wrapper is added to verify the argument size if not larger
than the current support open_how struct.

Gnulib added an openat2 module, which uses read-only for the open_how
argument [1].  There is no clear indication whether the kernel will
indeed use the argument as in-out, how it would do so, or for which
kind of functionality [2]. Also, adding a potentially different prototype
than gnulib only would add extra unnecessary friction and extra
wrappers to handle it.

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

[1] https://gitweb.git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=0b97ffdf32bdab909d02449043447237273df75e
[2] https://sourceware.org/pipermail/libc-alpha/2025-September/169740.html

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agomalloc: Extend malloc function hiding to tst-reallocarray (BZ #32366)
Adhemerval Zanella [Fri, 5 Dec 2025 19:11:36 +0000 (16:11 -0300)]
malloc: Extend malloc function hiding to tst-reallocarray (BZ #32366)

clang 20 optimize out reallocarray.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agomalloc: Extend malloc function hiding to tst-pvalloc (BZ #32366)
Adhemerval Zanella [Fri, 5 Dec 2025 19:11:35 +0000 (16:11 -0300)]
malloc: Extend malloc function hiding to tst-pvalloc (BZ #32366)

clang 21 optimize out reallocarray.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoconfigure: Enable experimental support for clang
Adhemerval Zanella [Mon, 1 Dec 2025 20:09:48 +0000 (17:09 -0300)]
configure: Enable experimental support for clang

The clang support is still experimental and not all testcases run
correctly.  Only clang 18 and onwards is supported and only
for x86_64-linux-gnu and aarch64-linux-gnu.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoconfigure: Only use -Wno-discarded-qualifiers iff compiler supports it
Adhemerval Zanella [Mon, 1 Dec 2025 20:09:47 +0000 (17:09 -0300)]
configure: Only use -Wno-discarded-qualifiers iff compiler supports it

The clang analogous option is
-Wno-incompatible-pointer-types-discards-qualifiers, so add a configure
option to check which one compiler supports.

2 weeks agoHandle clang -Wignored-attributes on weak aliases
Adhemerval Zanella [Mon, 1 Dec 2025 20:09:46 +0000 (17:09 -0300)]
Handle clang -Wignored-attributes on weak aliases

Clang issues a warning for double alias redirection, indicating that thei
original symbol is used even if a weak definition attempts to override it.

For instance, in the construction:

  int __internal_impl (...) {}
  weak_alias (__internal_impl, external_impl);
  #if SOMETHING
  weak_alias (external_impl, another_external_impl)
  #endif

Clang warns that another_external_impl always resolves to __internal_impl,
even if external_impl is a weak reference. Using the internal symbol for
both aliases resolves this warning.

This issue also occurs with certain libc_hidden_def usage:

  int __internal_impl (...) {}
  weak_alias (__internal_impl, __internal_alias)
  libc_hidden_weak (__internal_alias)

In this case, using a strong_alias is sufficient to avoid the warning
(since the alias is internal, there is no need to use a weak alias).

However, for the constructions like:

  int __internal_impl (...) {}
  weak_alias (__internal_impl, __internal_alias)
  libc_hidden_def (__internal_alias)
  weak_alias (__internal_impl, external_alias)
  libc_hidden_def (external_alias)

Clang warns that the internal external_alias will always resolve to
__GI___internal_impl, even if a weak definition of __GI_internal_impl is
overridden.  For this case, a new macro named static_weak_alias is used
to create a strong alias for SHARED, or a weak_alias otherwise.

With these changes, there is no need to check and enable the
-Wno-ignored-attributes suppression when using clang.

Checked with a build on affected ABIs, and a full check on aarch64,
armhf, i686, and x86_64.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agobuild-many-glibcs.py: Include URL in download exception
Florian Weimer [Mon, 8 Dec 2025 22:31:02 +0000 (23:31 +0100)]
build-many-glibcs.py: Include URL in download exception

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agox32: Implement prctl in assembly
H.J. Lu [Sun, 7 Dec 2025 03:33:33 +0000 (11:33 +0800)]
x32: Implement prctl in assembly

Since the variadic prctl function takes at most 5 integer arguments which
are passed in the same integer registers on x32 as the function with 5
integer arguments, we can use assembly for prctl.  Since upper 32-bits in
the last 4 arguments of pcrtl must be cleared to match the x32 prctl
syscall interface where the last 4 arguments are unsigned 64 bit longs,
implement prctl in assembly to clear upper 32-bits in the last 4 arguments
and add a test to verify it.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agobuild-many-glibcs.py: Switch Git URLs to https://
Florian Weimer [Mon, 8 Dec 2025 10:37:05 +0000 (11:37 +0100)]
build-many-glibcs.py: Switch Git URLs to https://

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 weeks agolibio: null terminate the buffer upon initial allocation in getdelim
Collin Funk [Wed, 3 Dec 2025 04:02:58 +0000 (20:02 -0800)]
libio: null terminate the buffer upon initial allocation in getdelim

Commit 33eff78c8b28adc4963987880e10d96761f2a167 caused issues in nbdkit
which had code similar to this to get the last line of the file:

    while (getline (&line, &len, fp) != -1)
      ;
    /* Process LINE.  */

After that commit, line[0] would be equal to '\0' instead of containing
the last line of the file like before that commit. A recent POSIX issue
clarified that the behavior before and after that commit are allowed,
since the contents of LINE are unspecified after -1 is returned
[1]. However, some programs rely on the previous behavior.

This patch null terminates the buffer upon getdelim/getline's initial
allocation. This is compatible with previous glibc versions, while also
protecting the caller from reading uninitialized memory if the file is
empty, as long as getline/getdelim does the initial allocation.

[1] https://www.austingroupbugs.net/bug_view_page.php?bug_id=1953

Suggested-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 weeks agoaarch64: Implement AdvSIMD and SVE rsqrt(f) routines
James Chesterman [Fri, 5 Dec 2025 10:37:45 +0000 (10:37 +0000)]
aarch64: Implement AdvSIMD and SVE rsqrt(f) routines

Vector variants of the new C23 rsqrt routines for both AdvSIMD and
SVE, as well as in both single and double precision.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agobenchtests: Add benchtests for rsqrt
James Chesterman [Fri, 5 Dec 2025 10:37:44 +0000 (10:37 +0000)]
benchtests: Add benchtests for rsqrt

Add benchtests for double precision vector rsqrt routine. They are
identical to those found in log2.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agobenchtests: Add benchtests for rsqrtf
James Chesterman [Fri, 5 Dec 2025 10:37:43 +0000 (10:37 +0000)]
benchtests: Add benchtests for rsqrtf

Add benchtests for vector single precision rsqrtf. They are
identical to those found in log2f.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoi386: Fix fmod/fmodf/remainder/remainderf for gcc-12
Adhemerval Zanella [Wed, 3 Dec 2025 14:31:43 +0000 (11:31 -0300)]
i386: Fix fmod/fmodf/remainder/remainderf for gcc-12

The __builtin_fmod{f} and __builtin_remainder{f} were added on gcc 13,
and the minimum supported gcc is 12.  This patch adds a configure test
to check whether the compiler enables inlining for fmod/remainder, and
uses inline assembly if not.

Checked on i686-linux-gnu wih gcc-12.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agonptl: Check alignment of pthread structs
Wilco Dijkstra [Thu, 4 Dec 2025 15:17:25 +0000 (15:17 +0000)]
nptl: Check alignment of pthread structs

Report assertion failure if the alignment of external pthread structs is
lower than the internal version.  This triggers on type mismatches like
in BZ #33632.

Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
3 weeks agoaarch64: Optimise AdvSIMD atanhf
James Chesterman [Fri, 28 Nov 2025 11:18:53 +0000 (11:18 +0000)]
aarch64: Optimise AdvSIMD atanhf

Optimise AdvSIMD atanhf by vectorising the special case.
There are asymptotes at x = -1 and x = 1. So return inf for these.
Values for which |x| > 1, return NaN.

R.Throughput difference on V2 with GCC@15:
58-60% improvement in special cases.
No regression in fast pass.

3 weeks agoaarch64: Optimise AdvSIMD asinhf
James Chesterman [Fri, 28 Nov 2025 11:18:52 +0000 (11:18 +0000)]
aarch64: Optimise AdvSIMD asinhf

Optimise AdvSIMD asinhf by vectorising the special case.
For values greater than 0x1p64, scale the input down first.
This is because the output will overflow with inputs greater than
or equal to this value as there is a squaring operation in the
algorithm.
To scale, do:
2asinh(sqrt[(x-1)/2])
Because:
2asinh(x) = +-acosh(2x^2 + 1)
Apply opposite operations in opposite order for x, and you get:
asinh(x) = 2acosh(sqrt[(x-1)/2]).
Found that using asinh instead of acosh also very closely
approximates asinh(x) for a high input x.

R.Throughput difference on V2 with GCC@15:
25-58% improvement in special cases.
4% regression in fast pass.

3 weeks agoaarch64: Optimise AdvSIMD acoshf
James Chesterman [Fri, 28 Nov 2025 11:18:51 +0000 (11:18 +0000)]
aarch64: Optimise AdvSIMD acoshf

Optimise AdvSIMD acoshf by vectorising the special case.
For values greater than 0x1p64, scale the input down first.
This is because the output will overflow with inputs greater than
or equal to this value as there is a squaring operation in the
algorithm.
To scale, do:
2acosh(sqrt[(x+1)/2])
Because:
acosh(x) = 1/2acosh(2x^2 - 1) for x>=1.
Apply opposite operations in opposite order for x, and you get:
acosh(x) = 2acosh(sqrt[(x+1)/2]).

R.Throughput difference on V2 with GCC@15:
30-49% improvement in special cases.
2% regression in fast pass.

3 weeks agoaarch64: Add tests for glibc.cpu.aarch64_bti behaviour
Yury Khrustalev [Wed, 29 Oct 2025 16:14:06 +0000 (16:14 +0000)]
aarch64: Add tests for glibc.cpu.aarch64_bti behaviour

Check that the new tunable changes behaviour correctly:

 * When BTI is enforced, any unmarked binary that is loaded
   results in an error: either an abort or dlopen error when
   this binary is loaded via dlopen.
 * When BTI is not enforced, it is OK to load an unmarked
   binary.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoaarch64: Support enforcing BTI on dependencies
Yury Khrustalev [Wed, 29 Oct 2025 16:12:14 +0000 (16:12 +0000)]
aarch64: Support enforcing BTI on dependencies

Add glibc.cpu.aarch64_bti tunable with 2 values:

 - permissive (default)
 - enforced

and use this tunable to enforce BTI marking on dependencies
when the enforced option is selected.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Tested-by: Jeremy Linton <jeremy.linton@arm.com>
3 weeks agoaarch64: Add configure checks for BTI support
Yury Khrustalev [Mon, 24 Nov 2025 13:23:35 +0000 (13:23 +0000)]
aarch64: Add configure checks for BTI support

We add configure checks for 3 things:
 - Compiler (both CC and TEST_CC) supports -mbranch-protection=bti.
 - Linker supports -z force-bti.
 - The toolchain supplies object files and target libraries with
   the BTI marking.

All three must be true in order for the tests to be valid, so
we check all flags and set the makefile variable accordingly.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoaarch64: fix makefile formatting
Yury Khrustalev [Thu, 4 Dec 2025 11:53:31 +0000 (11:53 +0000)]
aarch64: fix makefile formatting

3 weeks agoaarch64: Optimise AdvSIMD log10
James Chesterman [Wed, 19 Nov 2025 21:40:43 +0000 (21:40 +0000)]
aarch64: Optimise AdvSIMD log10

Optimise AdvSIMD log10 by vectorising the special case.
For subnormal input values, use the same scaling technique as
described in the single precision equivalent.
Then check for inf, nan and x<=0.

3 weeks agoaarch64: Optimise AdvSIMD log2
James Chesterman [Wed, 19 Nov 2025 21:40:42 +0000 (21:40 +0000)]
aarch64: Optimise AdvSIMD log2

Optimise AdvSIMD log2 by vectorising the special case.
For subnormal input values, use the same scaling technique as
described in the single precision equivalent.
Then check for inf, nan and x<=0.

3 weeks agoaarch64: Optimise AdvSIMD log
James Chesterman [Wed, 19 Nov 2025 21:40:41 +0000 (21:40 +0000)]
aarch64: Optimise AdvSIMD log

Optimise AdvSIMD log by vectorising the special case.
For subnormal input values, use the same scaling technique as
described in the single precision equivalent.
Then check for inf, nan and x<=0.

3 weeks agoaarch64: Optimise AdvSIMD log1p
James Chesterman [Wed, 19 Nov 2025 21:40:40 +0000 (21:40 +0000)]
aarch64: Optimise AdvSIMD log1p

Optimise AdvSIMD log1p by vectorising the special case.
The special cases are for when the input is:
Less than or equal to -1
+/- INFINITY
+/- NaN

3 weeks agoaarch64: Optimise AdvSIMD log10f
James Chesterman [Wed, 19 Nov 2025 14:11:40 +0000 (14:11 +0000)]
aarch64: Optimise AdvSIMD log10f

Optimise AdvSIMD log10f by vectorising the special case.
Use scaling technique on subnormal values, then check for inf and
nan values.
The scaling technique will sqrt the input then multiply the output
by 2 because:
log(sqrt(x)) = 1/2(log(x)), so log(x) = 2log(sqrt(x))

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoaarch64: Optimise AdvSIMD log2f
James Chesterman [Wed, 19 Nov 2025 14:11:39 +0000 (14:11 +0000)]
aarch64: Optimise AdvSIMD log2f

Optimise AdvSIMD log2f by vectorising the special case.
Use scaling technique on subnormal values, then check for inf and
nan values.
The scaling technique used will sqrt the input then multiply the
output by 2 because:
log(sqrt(x)) = 1/2 log(x), so log(x) = 2log(sqrt(x))

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoaarch64: Optimise AdvSIMD logf
James Chesterman [Wed, 19 Nov 2025 14:11:38 +0000 (14:11 +0000)]
aarch64: Optimise AdvSIMD logf

Optimise AdvSIMD logf by vectorising the special case.
Use scaling technique on subnormal values, then check for inf and
nan values.
The scaling technique used will sqrt the input then multiply the
output by 2 because:
log(sqrt(x)) = 1/2 log(x), so log(x) = 2log(sqrt(x))

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoaarch64: Optimise AdvSIMD log1pf
James Chesterman [Wed, 19 Nov 2025 14:11:37 +0000 (14:11 +0000)]
aarch64: Optimise AdvSIMD log1pf

Optimise AdvSIMD log1pf by vectorising the special case and by
reducing the range of values passed to the special case.
Previously, high values such as 0x1.1p127 where treated as special
cases, but now the special cases are for when the input is:
Less than or equal to -1
+/- INFINITY
+/- NaN

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoint128: Check BITS_PER_MP_LIMB == 32 instead of __WORDSIZE == 32
H.J. Lu [Sat, 29 Nov 2025 03:33:56 +0000 (11:33 +0800)]
int128: Check BITS_PER_MP_LIMB == 32 instead of __WORDSIZE == 32

commit 8cd6efca5b3796193ef3ff60d9dbf6e5572b2b73
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Nov 20 15:30:06 2025 -0300

    Add add_ssaaaa and sub_ssaaaa to gmp-arch.h

checks __WORDSIZE == 32 to decide if int128 should be used, which breaks
x32 which has int128 and __WORDSIZE == 32.  Check BITS_PER_MP_LIMB == 32,
instead of __WORDSIZE == 32.  This fixes BZ #33677.

Tested on x32, x86-64 and i686.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agotime: Add TIME_MONOTONIC, TIME_ACTIVE, and TIME_THREAD_ACTIVE
Adhemerval Zanella [Tue, 2 Dec 2025 12:24:18 +0000 (09:24 -0300)]
time: Add TIME_MONOTONIC, TIME_ACTIVE, and TIME_THREAD_ACTIVE

The TIME_MONOTONIC maps to POSIX's CLOCK_MONOTONIC, TIME_ACTIVE to
CLOCK_PROCESS_CPUTIME_ID, and TIME_THREAD_ACTIVE to
CLOCK_THREAD_CPUTIME_ID.

No Linux specific timer are added as extension.

Co-authored-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
3 weeks agoUse Linux 6.18 in build-many-glibcs.py
Joseph Myers [Tue, 2 Dec 2025 16:34:07 +0000 (16:34 +0000)]
Use Linux 6.18 in build-many-glibcs.py

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).

3 weeks agomisc: fix some typos
Yury Khrustalev [Tue, 2 Dec 2025 09:33:00 +0000 (09:33 +0000)]
misc: fix some typos

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 weeks agoUse 64-bit atomic on sem_t with 8-byte alignment [BZ #33632]
H.J. Lu [Sun, 16 Nov 2025 02:28:36 +0000 (10:28 +0800)]
Use 64-bit atomic on sem_t with 8-byte alignment [BZ #33632]

commit 7fec8a5de6826ef9ae440238d698f0fe5a5fb372
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Nov 13 14:26:08 2025 -0300

    Revert __HAVE_64B_ATOMICS configure check

uses 64-bit atomic operations on sem_t if 64-bit atomics are supported.
But sem_t may be aligned to 32-bit on 32-bit architectures.

1. Add a macro, SEM_T_ALIGN, for sem_t alignment.
2. Add a macro, HAVE_UNALIGNED_64B_ATOMICS.  Define it if unaligned 64-bit
atomic operations are supported.
3. Add a macro, USE_64B_ATOMICS_ON_SEM_T.  Define to 1 if 64-bit atomic
operations are supported and SEM_T_ALIGN is at least 8-byte aligned or
HAVE_UNALIGNED_64B_ATOMICS is defined.
4. Assert that size and alignment of sem_t are not lower than those of
the internal struct new_sem.
5. Check USE_64B_ATOMICS_ON_SEM_T, instead of USE_64B_ATOMICS, when using
64-bit atomic operations on sem_t.

This fixes BZ #33632.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 weeks agoscripts: Support custom Git URLs in build-many-glibcs.py
Yury Khrustalev [Wed, 12 Nov 2025 10:57:24 +0000 (10:57 +0000)]
scripts: Support custom Git URLs in build-many-glibcs.py

Use environment variables to provide mirror URLs to checkout
sources from Git. Each component has a corresponding env var
that will be used if it's present: <component>_GIT_MIRROR.

Note that '<component>' should be upper case, e.g. GLIBC.

Co-authored-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 weeks agoscripts: Support custom FTP mirror URL in build-many-glibcs.py
Yury Khrustalev [Wed, 12 Nov 2025 10:55:58 +0000 (10:55 +0000)]
scripts: Support custom FTP mirror URL in build-many-glibcs.py

Allow to use custom mirror URLs to download tarballs from a mirror
of ftp.gnu.org using the FTP_GNU_ORG_MIRROR env variable (default
value is 'https://ftp.gnu.org').

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 weeks agostrops: use strlen instead of strchr for string length
Kacper Piwiński [Mon, 1 Dec 2025 15:42:54 +0000 (16:42 +0100)]
strops: use strlen instead of strchr for string length

For wide string the equivalent funtion __wcslen is used. This change
makes it more symetrical.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 weeks agonptl: tests: Fix test-wrapper use in tst-dl-debug-tid.sh
Yury Khrustalev [Mon, 1 Dec 2025 10:09:14 +0000 (10:09 +0000)]
nptl: tests: Fix test-wrapper use in tst-dl-debug-tid.sh

Test wrapper script was used twice: once to run the test
command and second time within the text command which
seems unnecessary and results in false errors when running
this test.

Fixes 332f8e62afef53492dd8285490bcf7aeef18c80a

Reviewed-by: Frédéric Bérat <fberat@redhat.com>
3 weeks agoFix allocation_index increment in malloc_internal
Osama Abdelkader [Mon, 1 Dec 2025 12:35:36 +0000 (13:35 +0100)]
Fix allocation_index increment in malloc_internal

The allocation_index was being incremented before checking if mmap()
succeeds.  If mmap() fails, allocation_index would still be incremented,
creating a gap in the allocations tracking array and making
allocation_index inconsistent with the actual number of successful
allocations.

This fix moves the allocation_index increment to after the mmap()
success check, ensuring it only increments when an allocation actually
succeeds.  This maintains proper tracking for leak detection and
prevents gaps in the allocations array.

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 weeks agoNEWS: Add new generic fma/fmaf note
Adhemerval Zanella [Thu, 27 Nov 2025 19:54:28 +0000 (16:54 -0300)]
NEWS: Add new generic fma/fmaf note

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
4 weeks agoiconvdata: Fix invalid pointer arithmetic in ANSI_X3.110 module
Florian Weimer [Fri, 28 Nov 2025 10:46:09 +0000 (11:46 +0100)]
iconvdata: Fix invalid pointer arithmetic in ANSI_X3.110 module

The expression inptr + 1 can technically be invalid: if inptr == inend,
inptr may point one element past the end of an array.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agoDefine C23 header version macros
Joseph Myers [Thu, 27 Nov 2025 19:32:49 +0000 (19:32 +0000)]
Define C23 header version macros

C23 defines library macros __STDC_VERSION_<header>_H__ to indicate
that a header has support for new / changed features from C23.  Now
that all the required library features are implemented in glibc,
define these macros.  I'm not sure this is sufficiently much of a
user-visible feature to be worth a mention in NEWS.

Tested for x86_64.

There are various optional C23 features we don't yet have, of which I
might look at the Annex H ones (floating-point encoding conversion
functions and _Float16 functions) next.

* Optional time bases TIME_MONOTONIC, TIME_ACTIVE, TIME_THREAD_ACTIVE.
  See
  <https://sourceware.org/pipermail/libc-alpha/2023-June/149264.html>
  - we need to review / update that patch.  (I think patch 2/2,
  inventing new names for all the nonstandard CLOCK_* supported by the
  Linux kernel, is rather more dubious.)

* Updating conform/ tests for C23.

* Defining the rounding mode macro FE_TONEARESTFROMZERO for RISC-V (as
  far as I know, the only architecture supported by glibc that has
  hardware support for this rounding mode for binary floating point)
  and supporting it throughout glibc and its tests (especially the
  string/numeric conversions in both directions that explicitly handle
  each possible rounding mode, and various tests that do likewise).

* Annex H floating-point encoding conversion functions.  (It's not
  entirely clear which are optional even given support for Annex H;
  there's some wording applied inconsistently about only being
  required when non-arithmetic interchange formats are supported; see
  the comments I raised on the WG14 reflector on 23 Oct 2025.)

* _Float16 functions (and other header and testcase support for this
  type).

* Decimal floating-point support.

* Fully supporting __int128 and unsigned __int128 as integer types
  wider than intmax_t, as permitted by C23.  Would need doing in
  coordination with GCC, see GCC bug 113887 for more discussion of
  what's involved.

4 weeks agomath: New generic fmaf implementation
Adhemerval Zanella [Wed, 26 Nov 2025 17:06:16 +0000 (14:06 -0300)]
math: New generic fmaf implementation

The current implementation relies on setting the rounding mode for
different calculations (FE_TOWARDZERO) to obtain correctly rounded
results.  For most CPUs, this adds significant performance overhead
because it requires executing a typically slow instruction (to
get/set the floating-point status), necessitates flushing the
pipeline, and breaks some compiler assumptions/optimizations.

The original implementation adds tests to handle underflow in corner
cases, whereas this implementation uses a different strategy that
checks both the mantissa and the result to determine whether the
result is not subject to double rounding.

I tested this implementation on various targets (x86_64, i686, arm,
aarch64, powerpc), including some by manually disabling the compiler
instructions.

Performance-wise, it shows large improvements:

reciprocal-throughput       master       patched       improvement
x86_64 [1]                   58.09          7.96             7.33x
i686 [1]                    279.41         16.97            16.46x
aarch64 [2]                  26.09          4.10             6.35x
armhf [2]                    30.25          4.20             7.18x
powerpc [3]                   9.46          1.46             6.45x

latency                     master       patched       improvement
x86_64                       64.50         14.25             4.53x
i686                        304.39         61.04             4.99x
aarch64                      27.71          5.74             4.82x
armhf                        33.46          7.34             4.55x
powerpc                      10.96          2.65             4.13x

Checked on x86_64-linux-gnu and i686-linux-gnu with —disable-multi-arch,
and on arm-linux-gnueabihf.

[1] gcc 15.2.1, Zen3
[2] gcc 15.2.1, Neoverse N1
[3] gcc 15.2.1, POWER10

Signed-off-by: Szabolcs Nagy <nsz@gcc.gnu.org>
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Co-authored-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
4 weeks agoLinux: Ignore PIDFD_GET_INFO in tst-pidfd-consts
Florian Weimer [Thu, 27 Nov 2025 13:20:03 +0000 (14:20 +0100)]
Linux: Ignore PIDFD_GET_INFO in tst-pidfd-consts

The constant is expected to change between kernel releases.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 weeks agomath: Sync atanh from CORE-MATH
Adhemerval Zanella [Wed, 26 Nov 2025 14:22:02 +0000 (11:22 -0300)]
math: Sync atanh from CORE-MATH

The CORE-MATH commit dc9465e7 fixes some issues:

Failure: Test: atanh_towardzero (0x8.3f79103b3c64p-4)
Result:
 is:          5.7018661316561103e-01   0x1.23ef7ff0539c6p-1
 should be:   5.7018661316561092e-01   0x1.23ef7ff0539c5p-1
 difference:  1.1102230246251565e-16   0x1.0000000000000p-53
 ulp       :  1.0000
 max.ulp   :  0.0000
Failure: Test: atanh_towardzero (0x8.3f7d95aabaf7p-4)
Result:
 is:          5.7019248543911060e-01   0x1.23f044fac5997p-1
 should be:   5.7019248543911049e-01   0x1.23f044fac5996p-1
 difference:  1.1102230246251565e-16   0x1.0000000000000p-53
 ulp       :  1.0000
 max.ulp   :  0.0000
Failure: Test: atanh_towardzero (0x8.3f805380d6728p-4)
Result:
 is:          5.7019604623795527e-01   0x1.23f0bc75cd113p-1
 should be:   5.7019604623795516e-01   0x1.23f0bc75cd112p-1
 difference:  1.1102230246251565e-16   0x1.0000000000000p-53
 ulp       :  1.0000
 max.ulp   :  0.0000
Maximal error of `atanh_towardzero'
 is      : 1 ulp
 accepted: 0 ulp

Checked on x86_64-linux-gnu, x86_64-linux-gnu-v3, aarch64-linux-gnu,
and i686-linux-gnu.

4 weeks agoaarch64: make GCS configure checks aarch64-only
Yury Khrustalev [Mon, 24 Nov 2025 11:20:57 +0000 (11:20 +0000)]
aarch64: make GCS configure checks aarch64-only

We only need to enable GCS tests on AArch64 targets, however previously
the configure checks for GCS support in compiler and linker were added
for all targets which was not efficient.

To enable tests for GCS we need 4 things to be true:

 - Compiler supports GCS branch protection.
 - Test compiler supports GCS branch protection.
 - Linker supports GCS marking of binaries.
 - The CRT objects provided by the toolchain have GCS marking.

To check for the latter, we add new macro to aclocal.m4 that allows to
grep output from readelf.

We check all four and then put the result in one make variable to
simplify checks in makefiles.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
4 weeks agomath: New generic fma implementation
Adhemerval Zanella [Thu, 13 Nov 2025 12:58:20 +0000 (09:58 -0300)]
math: New generic fma implementation

The current implementation relies on setting the rounding mode for
different calculations (first to FE_TONEAREST and then to FE_TOWARDZERO)
to obtain correctly rounded results. For most CPUs, this adds a significant
performance overhead since it requires executing a typically slow
instruction (to get/set the floating-point status), it necessitates
flushing the pipeline, and breaks some compiler assumptions/optimizations.

This patch introduces a new implementation originally written by Szabolcs
for musl, which utilizes mostly integer arithmetic.  Floating-point
arithmetic is used to raise the expected exceptions, without the need for
fenv.h operations.

I added some changes compared to the original code:

  * Fixed some signaling NaN issues when the 3-argument is NaN.

  * Use math_uint128.h for the 64-bit multiplication operation.  It allows
    the compiler to use 128-bit types where available, which enables some
    optimizations on certain targets (for instance, MIPS64).

  * Fixed an arm32 issue where the libgcc routine might not respect the
    rounding mode [1].  This can also be used on other targets to optimize
    the conversion from int64_t to double.

  * Use -fexcess-precision=standard on i686.

I tested this implementation on various targets (x86_64, i686, arm, aarch64,
powerpc), including some by manually disabling the compiler instructions.

Performance-wise, it shows large improvements:

reciprocal-throughput       master       patched       improvement
x86_64 [2]                289.4640       22.4396            12.90x
i686 [2]                  636.8660      169.3640             3.76x
aarch64 [3]                46.0020       11.3281             4.06x
armhf [3]                   63.989       26.5056             2.41x
powerpc [4]                23.9332       6.40205             3.74x

latency                     master       patched       improvement
x86_64                    293.7360       38.1478             7.70x
i686                      658.4160      187.9940             3.50x
aarch64                    44.5166       14.7157             3.03x
armhf                      63.7678       28.4116             2.24x
power10                    23.8561       11.4250             2.09x

Checked on x86_64-linux-gnu and i686-linux-gnu with —disable-multi-arch,
and on arm-linux-gnueabihf.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91970
[2] gcc 15.2.1, Zen3
[3] gcc 15.2.1, Neoverse N1
[4] gcc 15.2.1, POWER10

Signed-off-by: Szabolcs Nagy <nsz@gcc.gnu.org>
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
4 weeks agostdlib: Remove longlong.h
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:08 +0000 (15:30 -0300)]
stdlib: Remove longlong.h

The gmp-arch.h now provides all the required definitions.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
4 weeks agoAdd umul_ppmm to gmp-arch.hdoc
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:07 +0000 (15:30 -0300)]
Add umul_ppmm to gmp-arch.hdoc

To enable “longlong.h” removal, the umul_ppmm is moved to a gmp-arch.h.
The generic implementation now uses a static inline, which provides
better type checking than the GNU extension to cast the asm constraint
(and it works better with clang).

Most of the architecture uses the generic implementation, which is
expanded from a macro, except for alpha, arm, hppa, x86, m68k, mips,
powerpc, and sparc.  The 32 bit architectures the compiler generates
good enough code using uint64_t types, where for 64 bit architecture
the patch leverages the math_u128.h definitions that uses 128-bit
integers when available (all 64 bit architectures on gcc 15).

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>