]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
119 min agobuild-many-glibcs.py: Switch Git URLs to https:// master
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>
2 days 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>
2 days 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>
2 days 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>
2 days 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 days 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 days 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 days 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 days 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 days 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.

4 days 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>
4 days 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>
4 days 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>
4 days agoaarch64: fix makefile formatting
Yury Khrustalev [Thu, 4 Dec 2025 11:53:31 +0000 (11:53 +0000)] 
aarch64: fix makefile formatting

4 days 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.

4 days 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.

4 days 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.

4 days 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

4 days 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>
4 days 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>
4 days 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>
4 days 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>
4 days 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>
4 days 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>
5 days 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).

6 days 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>
6 days 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>
6 days 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>
6 days 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>
6 days 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>
6 days 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>
7 days 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>
10 days 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>
10 days 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>
10 days 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.

10 days 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>
10 days 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>
11 days 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.

11 days 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>
11 days 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>
11 days 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>
11 days 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>
11 days agoAdd add_ssaaaa and sub_ssaaaa to gmp-arch.h
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:06 +0000 (15:30 -0300)] 
Add add_ssaaaa and sub_ssaaaa to gmp-arch.h

To enable “longlong.h” removal, add_ssaaaa and sub_ssaaaa are moved to
gmp-arch.h.  The generic implementation now uses a static inline.  This
provides better type checking than the GNU extension, which casts the
asm constraint; and it also works better with clang.

Most architectures use the generic implementation, with except of
arc, arm, hppa, x86, m68k, 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).

The strongly typed implementation required some changes.  I adjusted
_FP_W_TYPE, _FP_WS_TYPE, and _FP_I_TYPE to use the same type as
mp_limb_t on aarch64, powerpc64le, x86_64, and riscv64.  This basically
means using “long” instead of “long long.”

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
12 days agoAdd gmp-arch and udiv_qrnnd
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:05 +0000 (15:30 -0300)] 
Add gmp-arch and udiv_qrnnd

To enable “longlong.h” removal, the udiv_qrnnd is moved to a gmp-arch.h
file.  It allows each architecture to implement its own arch-specific
optimizations.  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, x86, m68k, sh, and sparc.
I kept that alpha, which uses out-of-the-line implementations and x86,
where there is no easy way to use the div{q} instruction from C code.
For the rest, the compiler generates good enough code.

The hppa also provides arch-specific implementations, but they are not
routed in “longlong.h” and thus never used.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
12 days agoAdd new math improvemenst to NEWS
Adhemerval Zanella [Mon, 24 Nov 2025 14:27:24 +0000 (11:27 -0300)] 
Add new math improvemenst to NEWS

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
12 days agoscripts: Fix minor lint warnings in build-many-glibcs.py
Yury Khrustalev [Wed, 12 Nov 2025 10:54:41 +0000 (10:54 +0000)] 
scripts: Fix minor lint warnings in build-many-glibcs.py

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
13 days agomalloc: Add threaded variants of single-threaded malloc tests
Arjun Shankar [Fri, 14 Nov 2025 17:31:46 +0000 (18:31 +0100)] 
malloc: Add threaded variants of single-threaded malloc tests

Single-threaded malloc tests exercise only the SINGLE_THREAD_P paths in
the malloc implementation.  This commit runs variants of these tests in
a multi-threaded environment in order to exercise the alternate code
paths in the same test scenarios, thus potentially improving coverage.

$(test)-threaded-main and $(test)-threaded-worker variants are
introduced for most single-threaded malloc tests (with a small number of
exceptions).  The -main variants run the base test in a main thread
while the test environment has an alternate thread running, whereas the
-worker variants run the test in an alternate thread while the main
thread waits on it.

The tests themselves are unmodified, and the change is accomplished by
using -DTEST_IN_THREAD at compile time, which instructs support/
infrastructure to run the test while an alternate thread waits on it.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
13 days agosupport: Add support for running tests in a multi-threaded environment
Arjun Shankar [Fri, 14 Nov 2025 17:31:45 +0000 (18:31 +0100)] 
support: Add support for running tests in a multi-threaded environment

It can be useful to be able to write a single-threaded test but run it
as part of a multi-threaded program simply to exercise glibc
synchronization code paths, e.g. the malloc implementation.

This commit adds support to enable this kind of testing.  Tests that
define TEST_IN_THREAD, either as TEST_THREAD_MAIN or TEST_THREAD_WORKER,
and then use support infrastructure (by including test-driver.c) will be
accordingly run in either the main thread, or in a second "worker"
thread while the other thread waits.

This can be used in new tests, or to easily make and run copies of
existing tests without modifying the tests themselves.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agohtl: Fix conditions for thread list variables
Samuel Thibault [Sat, 22 Nov 2025 10:55:40 +0000 (11:55 +0100)] 
htl: Fix conditions for thread list variables

_dl_stack_used/user/etc. vs _dl_pthread_num_threads etc. is really an
nptl vs htl question rather than pthread being in libc.

2 weeks agopthread: Simplify condition for hidden proto
Samuel Thibault [Sat, 22 Nov 2025 10:54:12 +0000 (11:54 +0100)] 
pthread: Simplify condition for hidden proto

This is not needed yet for htl (only the Linux mq_notify), but we can as
well just simplify the header.

2 weeks agohtl: move c11 symbols into libc.
gfleury [Fri, 21 Nov 2025 19:13:36 +0000 (21:13 +0200)] 
htl: move c11 symbols into libc.

thrd_{create,detach,exit,join}.
mtx_{init,destroy,lock,trylock,unlock,timeelock}.
cnd_{broadcast,destroy,init,signal,timewait,wait,destroy}
tss_{create,delete,get,set}. call_once.
Message-ID: <20251121191336.1224485-1-gfleury@disroot.org>

2 weeks agohtl: Also use __libc_thread_freeres to clean TLS state
Samuel Thibault [Sat, 22 Nov 2025 02:25:26 +0000 (02:25 +0000)] 
htl: Also use __libc_thread_freeres to clean TLS state

2 weeks agobenchtests: Fix bench-build after cd748a63ab
Adhemerval Zanella [Fri, 21 Nov 2025 16:21:25 +0000 (13:21 -0300)] 
benchtests: Fix bench-build after cd748a63ab

The benchtests does not define _LIBC.

2 weeks agolinux: Handle EINVAL as unsupported on tst-pidfd_getinfo
Adhemerval Zanella [Thu, 20 Nov 2025 19:42:04 +0000 (16:42 -0300)] 
linux: Handle EINVAL as unsupported on tst-pidfd_getinfo

Some kernels returns EINVAL for ioctl (PIDFD_GET_INFO) on pidfd
descriptors.

Checked on aarch64-linux-gnu with Linux 6.12.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agobench-malloc-thread: Add libm for powf
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:15 +0000 (15:30 -0300)] 
bench-malloc-thread: Add libm for powf

The compiler might not constant fold the call, which issues
linker error.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agobenchtests: Remove clang warnings
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:14 +0000 (15:30 -0300)] 
benchtests: Remove clang warnings

clangs warns of the implicit cast of RAND_MAX to float:

  error: implicit conversion from 'int' to 'float' changes value from
  2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]

So make it explicit.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agobenchtests: Add attribute_optimize
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:13 +0000 (15:30 -0300)] 
benchtests: Add attribute_optimize

Similar to tst-printf-bz18872.sh, add the attribute_optimize to avoid
build failures with compilers that do not support "GCC optimize" pragma.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agobenchtests: Use __f128 on ilogbf128-inputs constants
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:12 +0000 (15:30 -0300)] 
benchtests: Use __f128 on ilogbf128-inputs constants

The f128 is not a valid floating constant suffix on clang.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoEnable --enable-fortify-source with clang
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:11 +0000 (15:30 -0300)] 
Enable --enable-fortify-source with clang

clang generates internal calls for some _chk symbol, so add internal
aliases for them, and stub some with rtld-stubbed-symbols to avoid
ld.so linker issues.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoconfigure: Only use -fno-fp-int-builtin-inexact if compiler supports it
Adhemerval Zanella [Thu, 20 Nov 2025 18:30:10 +0000 (15:30 -0300)] 
configure: Only use -fno-fp-int-builtin-inexact if compiler supports it

Checked on x86_64-linux-gnu.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agobenchtests: Add fmaf benchtests
Adhemerval Zanella [Thu, 13 Nov 2025 12:58:21 +0000 (09:58 -0300)] 
benchtests: Add fmaf benchtests

Random inputs in the range [0,10].

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agomath: Remove ldbl-96 fma implementation
Adhemerval Zanella [Thu, 13 Nov 2025 12:58:19 +0000 (09:58 -0300)] 
math: Remove ldbl-96 fma implementation

It is worse than the ldbl-64 version on recent x86 hardware.  With
Zen3 and gcc-15:

ldbl-96 removal
reciprocal-throughput        master        patched   improvement
x86_64                    1176.2200       289.4640         4.06x
i686                      1476.0600       636.8660         2.32x

latency                      master        patched   improvement
x86_64                    1176.2200        293.7360        4.00x
i686                      1480.0700        658.4160        2.25x

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

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agobenchtests: Add fma benchtests
Adhemerval Zanella [Thu, 13 Nov 2025 12:58:18 +0000 (09:58 -0300)] 
benchtests: Add fma benchtests

Random inputs in the range [0,10].

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agohtl: Move pthread_atfork compatibility symbol to libc
Samuel Thibault [Wed, 19 Nov 2025 19:16:18 +0000 (20:16 +0100)] 
htl: Move pthread_atfork compatibility symbol to libc

There is no new symbol version because of the compatibility symbol
status.

2 weeks agohtl: move pthread_spin_{destroy, lock, init, trylock, unlock) and remove _pthread_spi...
gfleury [Thu, 20 Nov 2025 08:56:47 +0000 (10:56 +0200)] 
htl: move pthread_spin_{destroy, lock, init, trylock, unlock) and remove _pthread_spin_lock, into libc.

Message-ID: <20251120085647.326643-1-gfleury@disroot.org>

2 weeks agoImplement C23 const-preserving standard library macros
Joseph Myers [Thu, 20 Nov 2025 19:30:27 +0000 (19:30 +0000)] 
Implement C23 const-preserving standard library macros

C23 makes various standard library functions, that return a pointer
into an input array, into macros that return a pointer to const when
the relevant argument passed to the macro is a pointer to const.  (The
requirement is for macros, with the existing function types applying
when macro expansion is suppressed.  When a null pointer constant is
passed, such as integer 0, that's the same as a pointer to non-const.)

Implement this feature.  This only applies to C, not C++, since such
macros are not an appropriate way of doing this for C++ and all the
affected functions other than bsearch have overloads to implement an
equivalent feature for C++ anyway.  Nothing is done to apply such a
change to any non-C23 functions with the same property of returning a
pointer into an input array.

The feature is also disabled when _LIBC is defined, since there are
various places in glibc that either redefine these identifiers as
macros, or define the functions themselves, and would need changing to
work in the presence of these macro definitions.  A natural question
is whether we should in fact change those places and not disable the
macro definitions for _LIBC.  If so, we'd need a solution for the
places in glibc that define the macro *before* including the relevant
header (in order in effect to disable the header declaration of the
function by renaming that declaration).

One testcase has #undef added to avoid conflicting with this feature
and another has const added; -Wno-discarded-qualifiers is added for
building zic (but could be removed once there's a new upstream tzcode
release that's const-safe with this C23 change and glibc has updated
to code from that new release).  Probably other places in glibc proper
would need const added if we remove the _LIBC conditionals.

Another question would be whether some GCC extension should be added
to support this feature better with macros that only expand each
argument once (as well as reducing duplication of diagnostics for bad
usages such as non-pointer and pointer-to-volatile-qualfied
arguments).

Tested for x86_64.

2 weeks agoCheck if linker supports -Wl,--undefined-version
Adhemerval Zanella [Thu, 20 Nov 2025 12:20:41 +0000 (09:20 -0300)] 
Check if linker supports -Wl,--undefined-version

Although binutils has supported --no-undefined-version for a long timei
(319416359200 back in 2002), --undefined-version was only added more
recently (27fb6a1a7fcd on 2.40).

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agonptl: Replace FALLTHROUGH with [[fallthrough]]
Adhemerval Zanella [Tue, 18 Nov 2025 16:00:19 +0000 (13:00 -0300)] 
nptl: Replace FALLTHROUGH with [[fallthrough]]

The b9579342c6 reinstate '/* FALLTHROUGH */' that were replaced
the the C23 [[fallthrough]] by 970364dac0.

2 weeks agohurd: Add missing free_sized and free_aligned_sized
Samuel Thibault [Wed, 19 Nov 2025 18:37:18 +0000 (19:37 +0100)] 
hurd: Add missing free_sized and free_aligned_sized

56549264d1e1 ("malloc: add free_sized and free_aligned_sized from C23")
missed adding them.

2 weeks agoUse __fstat64_time64 in __fts64_children_time64 (bug 33653)
Andreas Schwab [Thu, 20 Nov 2025 11:16:15 +0000 (12:16 +0100)] 
Use __fstat64_time64 in __fts64_children_time64 (bug 33653)

Make sure that fts_safe_changedir can handle a directory with a time stamp
after y2038.

2 weeks agomalloc: Use _int_free_chunk in tcache_thread_shutdown
Wilco Dijkstra [Fri, 29 Aug 2025 12:47:54 +0000 (12:47 +0000)] 
malloc: Use _int_free_chunk in tcache_thread_shutdown

Directly call _int_free_chunk during tcache shutdown to avoid recursion.
Calling __libc_free on a block from tcache gets flagged as a double free,
and tcache_double_free_verify checks every tcache chunk (quadratic
overhead).

Reviewed-by: Arjun Shankar <arjun@redhat.com>
2 weeks agomath: Sync atanh from CORE-MATH
Adhemerval Zanella [Wed, 19 Nov 2025 18:21:44 +0000 (15:21 -0300)] 
math: Sync atanh from CORE-MATH

The CORE-MATH commit 703d7487 fixes some issues for RNDZ:

Failure: Test: atanh_towardzero (0x5.96200b978b69cp-4)
Result:
 is:          3.6447730550366463e-01   0x1.753989ed16faap-2
 should be:   3.6447730550366458e-01   0x1.753989ed16fa9p-2
 difference:  5.5511151231257827e-17   0x1.0000000000000p-54
 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.

2 weeks agomalloc: add free_sized and free_aligned_sized from C23
Justin King [Wed, 22 Oct 2025 12:51:43 +0000 (05:51 -0700)] 
malloc: add free_sized and free_aligned_sized from C23

Signed-off-by: Justin King <jcking@google.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agomath: Sync acosh from CORE-MATH
Adhemerval Zanella [Wed, 19 Nov 2025 15:54:04 +0000 (12:54 -0300)] 
math: Sync acosh from CORE-MATH

The CORE-MATH commit 6736002f fixes some issues for RNDZ:

Failure: Test: acosh_towardzero (0x1.08000c1e79fp+0)
Result:
 is:          2.4935636091994373e-01   0x1.feae8c399b18cp-3
 should be:   2.4935636091994370e-01   0x1.feae8c399b18bp-3
 difference:  2.7755575615628913e-17   0x1.0000000000000p-55
 ulp       :  1.0000
 max.ulp   :  0.0000
Failure: Test: acosh_towardzero (0x1.080016353964ep+0)
Result:
 is:          2.4935874767710369e-01   0x1.feafcc91f518ep-3
 should be:   2.4935874767710367e-01   0x1.feafcc91f518dp-3
 difference:  2.7755575615628913e-17   0x1.0000000000000p-55
 ulp       :  1.0000
 max.ulp   :  0.0000
Maximal error of `acosh_towardzero'
 is      : 1 ulp
 accepted: 0 ulp

This only happens when the ISA supports fma, such as x86_64-v3, aarch64,
or powerpc.

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

2 weeks agolinux/termios: test the kernel-side termios canonicalization
H. Peter Anvin [Tue, 18 Nov 2025 18:21:18 +0000 (10:21 -0800)] 
linux/termios: test the kernel-side termios canonicalization

Verify that the kernel side of the termios interface gets the various
speed fields set according to our current canonicalization policy.

[ v2.1: fix formatting - Adhemerval Netto ]
[ v4: fix typo in patch description - Dan Horák ]

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (v2.1)
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agonss: Remove effectively unused __nss_*_database variables
Florian Weimer [Tue, 18 Nov 2025 19:18:06 +0000 (20:18 +0100)] 
nss: Remove effectively unused __nss_*_database variables

Use of this cache was removed in commit f8847d83e17774ed5e9c0f75ef693
("nsswitch: use new internal API (core)").

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agoAArch64: Remove WANT_SIMD_EXCEPT from aarch64 AdvSIMD math routines
Dylan Fleming [Tue, 18 Nov 2025 15:34:41 +0000 (15:34 +0000)] 
AArch64: Remove WANT_SIMD_EXCEPT from aarch64 AdvSIMD math routines

Remove legacy code for supporting an old Arm Optimised Routines
deprecated feature for throwing SIMD Exceptions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agoAArch64: Fix and improve SVE pow(f) special cases
Pierre Blanchard [Tue, 18 Nov 2025 15:09:05 +0000 (15:09 +0000)] 
AArch64: Fix and improve SVE pow(f) special cases

powf:

Update scalar special case function to best use new interface.

pow:

Make specialcase NOINLINE to prevent str/ldr leaking in fast path.
Remove depency in sv_call2, as new callback impl is not a
performance gain.
Replace with vectorised specialcase since structure of scalar
routine is fairly simple.

Throughput gain of about 5-10% on V1 for large values and 25% for subnormal `x`.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2 weeks agoAArch64: fix SVE tanpi(f) [BZ #33642]
Pierre Blanchard [Tue, 18 Nov 2025 15:03:10 +0000 (15:03 +0000)] 
AArch64: fix SVE tanpi(f) [BZ #33642]

Fixed svld1rq using incorrect predicates (BZ #33642).
Next to no performance variations (tested on V1).

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2 weeks agohtl: move pthread_hurd_cond_timedwait_np, pthread_hurd_cond_wait_np into libc.
gfleury [Tue, 18 Nov 2025 12:50:44 +0000 (14:50 +0200)] 
htl: move pthread_hurd_cond_timedwait_np, pthread_hurd_cond_wait_np into libc.

Message-ID: <20251118125044.1160780-3-gfleury@disroot.org>

2 weeks agohtl: move pthread_getname_np/setname_np into libc.
gfleury [Tue, 18 Nov 2025 12:50:43 +0000 (14:50 +0200)] 
htl: move pthread_getname_np/setname_np into libc.

Message-ID: <20251118125044.1160780-2-gfleury@disroot.org>

2 weeks agohtl: fix compatibility
gfleury [Tue, 18 Nov 2025 12:50:42 +0000 (14:50 +0200)] 
htl: fix compatibility

This fix 91fb9914d867320d65a2abe284fb623d91ae5efb which break a system
built with an old glibc
Message-ID: <20251118125044.1160780-1-gfleury@disroot.org>

2 weeks agoAdd new AArch64 HWCAP3 definitions from Linux 6.17 to bits/hwcap.h
Adhemerval Zanella [Thu, 2 Oct 2025 19:43:33 +0000 (16:43 -0300)] 
Add new AArch64 HWCAP3 definitions from Linux 6.17 to bits/hwcap.h

Linux 7c7f55039b8d6 added HWCAP3_MTE_FAR and f620372209bfe added
HWCAP3_MTE_STORE_ONLY.

2 weeks agomalloc: Simplify tst-free-errno munmap failure test
Arjun Shankar [Thu, 13 Nov 2025 20:26:08 +0000 (21:26 +0100)] 
malloc: Simplify tst-free-errno munmap failure test

The Linux specific test-case in tst-free-errno was backing up malloc
metadata for a large mmap'd block, overwriting the block with its own
mmap, then restoring malloc metadata and calling free to force an munmap
failure.  However, the backed up pages containing metadata can
occasionally be overlapped by the overwriting mmap, leading to a
metadata corruption.

This commit replaces this Linux specific test case with a simpler,
generic, three block allocation, expecting the kernel to coalesce the
VMAs, then cause a fragmentation to trigger the same failure.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agoRemove support for lock elision.
Stefan Liebler [Tue, 28 Oct 2025 14:21:18 +0000 (15:21 +0100)] 
Remove support for lock elision.

The support for lock elision was already deprecated with glibc 2.42:
commit 77438db8cfa6ee66b3906230156bdae11c49a195
"Mark support for lock elision as deprecated."
See also discussions:
https://sourceware.org/pipermail/libc-alpha/2025-July/168492.html

This patch removes the architecture specific support for lock elision
for x86, powerpc and s390 by removing the elision-conf.h, elision-conf.c,
elision-lock.c, elision-timed.c, elision-unlock.c, elide.h, htm.h/hle.h files.
Those generic files are also removed.

The architecture specific structures are adjusted and the elision fields are
marked as unused.  See struct_mutex.h files.
Furthermore in struct_rwlock.h, the leftover __rwelision was also removed.
Those were originally removed with commit 0377a7fde6dfcc078dda29a1225d7720a0931357
"nptl: Remove rwlock elision definitions"
and by chance reintroduced with commit 7df8af43ad1cd8ce527444de50bee6f35eebe071
"nptl: Add struct_rwlock.h"

The common code (e.g. the pthread_mutex-files) are changed back to the time
before lock elision was introduced with the x86-support:
- commit 1cdbe579482c07e9f4bb3baa4864da2d3e7eb837
"Add the low level infrastructure for pthreads lock elision with TSX"
- commit b023e4ca99f5e81f90d87d23cd267ef2abd2388c
"Add new internal mutex type flags for elision."
- commit 68cc29355f3334c7ad18f648ff9a6383a0916d23
"Add minimal test suite changes for elision enabled kernels"
- commit e8c659d74e011346785355eeef03b7fb6f533c61
"Add elision to pthread_mutex_{try,timed,un}lock"
- commit 49186d21ef2d87986bccaf0a7c45c48c91b265f3
"Disable elision for any pthread_mutexattr_settype call"
- commit 1717da59aed9612becd56aaa1249aac695af4c8a
"Add a configure option to enable lock elision and disable by default"

Elision is removed also from the tunables, the initialization part, the
pretty-printers and the manual.

Some extra handling in the testsuite is removed as well as the full tst-mutex10
testcase, which tested a race while enabling lock elision.

I've also searched the code for "elision", "elide", "transaction" and e.g.
cleaned some comments.

I've run the testsuite on x86_64 and s390x and run the build-many-glibcs.py
script.
Thanks to Sachin Monga, this patch is also tested on powerpc.

A NEWS entry also mentions the removal.
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agonss: Remove effectively unused struct nss_database_default_cache
Florian Weimer [Mon, 17 Nov 2025 17:43:50 +0000 (18:43 +0100)] 
nss: Remove effectively unused struct nss_database_default_cache

We always start with a zero-initialized cache, so this is completely
ineffective.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agonss: Clean up function pointer/void * unions
Florian Weimer [Mon, 17 Nov 2025 16:18:00 +0000 (17:18 +0100)] 
nss: Clean up function pointer/void * unions

All our targets support casts between function pointers and void *,
so we might as well use them.

This change was largely auto-generated, with the following prompts.

@getXXbyYY_r.c Remove the use of the `fct` union and replace it by
pointer casts.

Apply the same change to ether_* getnetgrent_r getnssent_r netname
publickey .

Do not use explicit `*` in function pointer calls. Replace
`(*((lookup_function) fct))` and similar with `((lookup_function) fct)`.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agolinux/termios: factor out the kernel interface from termios_internal.h
H. Peter Anvin [Mon, 20 Oct 2025 20:42:10 +0000 (13:42 -0700)] 
linux/termios: factor out the kernel interface from termios_internal.h

Factor out the internal kernel interface from termios_internal.h, so
that it can be used in test code without causing breakage due to glibc
internals used in headers.

[ v3: fix Alpha build breakage ]

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agolinux/termios: clear k_termios.c_cflag & CIBAUD for non-split speed [BZ 33340]
H. Peter Anvin [Mon, 20 Oct 2025 20:42:09 +0000 (13:42 -0700)] 
linux/termios: clear k_termios.c_cflag & CIBAUD for non-split speed [BZ 33340]

After getting more experience with the various broken direct-to-ioctl
termios2 hacks using Fedora 43 beta, I have found a fair number of
cases where the software would fail to set, or clear CIBAUD for
non-split-speed operation.

Thus it seems will help improve compatibility to clear the kernel-side
version of c_cflag & CIBAUD (having the same meaning to the Linux
kernel as the speed 0 has for cfsetibaud(), i.e. force the input speed
to equal the output speed) for non-split-speed operation, rather than
having it explicitly equal the output speed in CBAUD.

When writing the code that went into glibc 2.42 I had considered this
issue, and had to make an educated guess which way would be more
likely to break fewer things.  Unfortunately, it appears I guessed
wrong.

A third option would be to *always* set CIBAUD to __BOTHER, even for
the standard baud rates.  However, that is an even bigger departure
from legacy behavior, whereas this variant mostly preserves current
behavior in terms of under what conditions buggy utilities will
continue to work.

This change is in tcsetattr() rather than
___termios2_canonicalize_speeds(), as it should not be run for
tcgetattr(); that would break split speed support for the legacy
interface versions of cfgetispeed() and cfsetispeed().

[ v2: fixed comment style ]

Resolves: BZ #33340
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agomanual: don't use the FSF's old address in license text.
Collin Funk [Tue, 11 Nov 2025 19:49:07 +0000 (11:49 -0800)] 
manual: don't use the FSF's old address in license text.

Update to latest text from Gnulib commit
08f579c56d81cf78c60fcd3568190f97e6e7f684, file doc/lgpl-2.1.texi.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agoposix: execvpe: fix UMR with file > NAME_MAX [BZ #33627]
Pádraig Brady [Fri, 14 Nov 2025 13:58:58 +0000 (13:58 +0000)] 
posix: execvpe: fix UMR with file > NAME_MAX [BZ #33627]

* posix/execvpe.c (__execvpe_common): Since strnlen doesn't inspect
beyond NAME_MAX and NAME_MAX does not cover the NUL, we need
to explicitly check for the NUL.  I.e. the existing check for,
file_len-1 > NAME_MAX, was never true.  This check is required
so that we're guaranteed that file_len includes the NUL, as we
depend on that in the following memcpy to properly terminate
the file buffer passed to execve().  Otherwise that call will trigger
UMR when inspecting the passed file, which can be seen with valgrind.
Note returning ENAMETOOLONG early here for FILE names > NAME_MAX
will also avoid redundant processing of ENAMETOOLONG on each entry
in $PATH, after the change in [BZ #33626] is applied.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agoconfigure: Remove for redirection of built-in functions
Adhemerval Zanella [Mon, 10 Nov 2025 13:29:02 +0000 (10:29 -0300)] 
configure: Remove for redirection of built-in functions

The check was initially used to define HAVE_BUILTIN_REDIRECTION, which
enables or not libc_hidden_builtin_proto support. It was later removed
with 3ce1f2959437e952b9db4eaeed2407424f11a4d1, making the feature
mandatory. The configure check was kept as a transition knob.

Current minimum gcc/linker always supports this, as well as clang with
some extra care. Also, missing hidden_proto/hidden_def support is
already flagged in the check-localplt test.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agomath: Handle fabsf128 !__USE_EXTERN_INLINES
Adhemerval Zanella [Mon, 10 Nov 2025 13:29:01 +0000 (10:29 -0300)] 
math: Handle fabsf128 !__USE_EXTERN_INLINES

Work around the clang limitation wrt inline function and attribute
definition, where it does not allow to 'add' new attribute if a
function is already defined:

clang on x86_64 fails to build s_fabsf128.c with:

../sysdeps/ieee754/float128/../ldbl-128/s_fabsl.c:32:1: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
   32 | libm_alias_ldouble (__fabs, fabs)
      | ^
../sysdeps/generic/libm-alias-ldouble.h:63:38: note: expanded from macro 'libm_alias_ldouble'
   63 | #define libm_alias_ldouble(from, to) libm_alias_ldouble_r (from, to, )
      |                                      ^
../sysdeps/ieee754/float128/float128_private.h:133:43: note: expanded from macro 'libm_alias_ldouble_r'
  133 | #define libm_alias_ldouble_r(from, to, r) libm_alias_float128_r (from, to, r)
      |                                           ^
../sysdeps/ieee754/float128/s_fabsf128.c:5:3: note: expanded from macro 'libm_alias_float128_r'
    5 |   static_weak_alias (from ## f128 ## r, to ## f128 ## r);       \
      |   ^
./../include/libc-symbols.h:166:46: note: expanded from macro 'static_weak_alias'
  166 | #  define static_weak_alias(name, aliasname) weak_alias (name, aliasname)
      |                                              ^
./../include/libc-symbols.h:154:38: note: expanded from macro 'weak_alias'
  154 | # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
      |                                      ^
./../include/libc-symbols.h:156:52: note: expanded from macro '_weak_alias'
  156 |   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
      |                                                    ^
../include/math.h:134:1: note: previous definition is here
  134 | fabsf128 (_Float128 x)

If compiler does not support __USE_EXTERN_INLINES we need to route
fabsf128 call to an internal symbol.

2 weeks agox86: Fix strstr ifunc on clang
Adhemerval Zanella [Mon, 10 Nov 2025 13:28:59 +0000 (10:28 -0300)] 
x86: Fix strstr ifunc on clang

Work around the clang limitation wrt inline function and attribute
definition, where it does not allow to 'add' new attribute if a
function is already defined:

Buildint with clang triggers multiple issue on how ifunc macro are
used:

  ../sysdeps/x86_64/multiarch/strstr.c:38:54: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
     38 | extern __typeof (__redirect_strstr) __strstr_generic attribute_hidden;
        |                                                      ^
  ./../include/libc-symbols.h:356:43: note: expanded from macro 'attribute_hidden'
    356 | # define attribute_hidden __attribute__ ((visibility ("hidden")))
        |                                           ^
  ../string/strstr.c:76:1: note: previous definition is here
     76 | STRSTR (const char *haystack, const char *needle)
        | ^
  ../sysdeps/x86_64/multiarch/strstr.c:27:16: note: expanded from macro 'STRSTR'
     27 | #define STRSTR __strstr_generic
        |                ^
  ../sysdeps/x86_64/multiarch/strstr.c:65:43: error: redefinition of '__libc_strstr'
     65 | libc_ifunc_redirected (__redirect_strstr, __libc_strstr, IFUNC_SELECTOR ());
        |                                           ^

And

  ../sysdeps/x86_64/multiarch/strstr.c:65:43: error: redefinition of '__libc_strstr'
     65 | libc_ifunc_redirected (__redirect_strstr, __libc_strstr, IFUNC_SELECTOR ());
        |                                           ^
  ../sysdeps/x86_64/multiarch/strstr.c:59:13: note: previous definition is here
     59 | libc_ifunc (__libc_strstr,
        |             ^

Refactor to use a auxiliary function like other selection (for instance,
x86_64/multiarch/strcmp.c).

2 weeks agox86: Use -mavx instead of -msse2avx
Adhemerval Zanella [Mon, 10 Nov 2025 13:28:58 +0000 (10:28 -0300)] 
x86: Use -mavx instead of -msse2avx

clang supports -msse2avx from version 19 and onwards, but it should
be gated as an option to assembler (either with -Wa or -Xassembler).

The -DSSE2AVX option was used because there were asm statements with
SSE-only instructions which was fixed by commit ff8be6152bc.

Now we can simply use -mavx.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agomath: Don't redirect inlined builtin math functions
Adhemerval Zanella [Mon, 10 Nov 2025 13:28:56 +0000 (10:28 -0300)] 
math: Don't redirect inlined builtin math functions

When we want to inline builtin math functions, like truncf, for

  extern float truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));
  extern float __truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));

  float (truncf) (float) asm ("__truncf");

compiler may redirect truncf calls to __truncf, instead of inlining it
(for instance, clang).  The USE_TRUNCF_BUILTIN is 1 to indicate that
truncf should be inlined.  In this case, we don't want the truncf
redirection:

  1. For each math function which may be inlined, we define

  #if USE_TRUNCF_BUILTIN
   # define NO_truncf_BUILTIN inline_truncf
   #else
   # define NO_truncf_BUILTIN truncf
   #endif

in <math-use-builtins.h>.

  2. Include <math-use-builtins.h> in include/math.h.

  3. Change MATH_REDIRECT to

   #define MATH_REDIRECT(FUNC, PREFIX, ARGS) \
    float (NO_ ## FUNC ## f ## _BUILTIN) (ARGS (float)) \
      asm (PREFIX #FUNC "f");

With this change If USE_TRUNCF_BUILTIN is 0, we get

  float (truncf) (float) asm ("__truncf");
  truncf will be redirected to __truncf.

And for USE_TRUNCF_BUILTIN 1, we get:

  float (inline_truncf) (float) asm ("__truncf");

In both cases either truncf will be inlined or the internal alias
(__truncf) will be called.

It is not required for all math-use-builtin symbol, only the one
defined in math.h.  It also allows to remove all the math-use-builtin
inclusion, since it is now implicitly included by math.h.

For MIPS, some math-use-builtin headers include sysdep.h and this
in turn includes a lot of extra headers that do not allow ldbl-128
code to override alias definition (math.h will include
some stdlib.h definition).  The math-use-builtin only requires
the __mips_isa_rev, so move the defintion to sgidefs.h.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agoUpdate COPYING, COPYING.LIB from gnulib, using gnulib file names
Florian Weimer [Mon, 17 Nov 2025 10:15:13 +0000 (11:15 +0100)] 
Update COPYING, COPYING.LIB from gnulib, using gnulib file names

The new file names are COPYINGv2 and COPYING.LESSERv2.  Lots of
copyright headers mention COPYING.LIB, so add a symbolic link.
(This is not the first symbolic link in the repository, so this
should be fine.)

The files come from gnulib commit 3cc5b69dda06890929a2d0433f30708.

Signed-off-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 weeks agoAdd COPYINGv3 with the GPL version 3 text
Florian Weimer [Mon, 17 Nov 2025 10:15:13 +0000 (11:15 +0100)] 
Add COPYINGv3 with the GPL version 3 text

The license is referenced in various headers, so we should ship it.
The text was copied from gnulib commit d64d66cc4897d605f543257dcd0,
file doc/COPYINGv3.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Signed-off-by: Florian Weimer <fweimer@redhat.com>
3 weeks agoReference COPYING.LIB in <sframe.h> copyright header
Florian Weimer [Mon, 17 Nov 2025 10:15:13 +0000 (11:15 +0100)] 
Reference COPYING.LIB in <sframe.h> copyright header

Commit 3360913c37f5c3a0c8737b76321fd5ce2608fcd5 ("elf: Add SFrame
stack tracing") added this file with an inconsistent copyright header.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 weeks agohtl: move pthread_create to into libc
Samuel Thibault [Sun, 16 Nov 2025 14:09:11 +0000 (14:09 +0000)] 
htl: move pthread_create to into libc

This is notably needed for the main thread structure to be always
initialized so that some pthread functions can work from the main thread
without other threads, e.g. pthread_cancel.