]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
2 months agoresolv: Avoid duplicate query if search list contains '.' (bug 33804)
Carlos Peón Costa [Tue, 3 Mar 2026 17:48:47 +0000 (18:48 +0100)] 
resolv: Avoid duplicate query if search list contains '.' (bug 33804)

Co-authored-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 months agosupport: no_override_resolv_conf_search flag for resolver test framework
Florian Weimer [Tue, 3 Mar 2026 17:48:47 +0000 (18:48 +0100)] 
support: no_override_resolv_conf_search flag for resolver test framework

It is required to test "search ." in /etc/resolv.conf files.  The
default is to override the search path isolate from unexpected
settings in the test execution environment.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 months agoAArch64: Improve memset when len is 64
Wilco Dijkstra [Mon, 2 Mar 2026 17:17:04 +0000 (17:17 +0000)] 
AArch64: Improve memset when len is 64

Change the mask to 48 to support len==64. The second memory store now accesses
offset 32, whereas the third one accesses offset 16.  As a result performance
for len==64 almost doubles.

2 months agomalloc: Add asserts for malloc assumptions
Wilco Dijkstra [Mon, 2 Mar 2026 13:09:24 +0000 (13:09 +0000)] 
malloc: Add asserts for malloc assumptions

Currently malloc has various assumptions, some documented, some implicit.
Add a few asserts to check the most fundamental assumptions using verify().
Remove some odd #define void.

Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
2 months agotests: posix: use cpu clock for sleep
Yury Khrustalev [Mon, 2 Feb 2026 14:06:38 +0000 (14:06 +0000)] 
tests: posix: use cpu clock for sleep

On some emulated targets sleep may result in inconsistent wait
times which will lead to the failure of the tst-chmod test.

To account for this we use the CLOCK_PROCESS_CPUTIME_ID clock ID
while also consuming CPU time by repeatedly calling clock_gettime.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 months agoassert: Support assert as variadic macro for C++26 [PR27276]
Jonathan Wakely [Wed, 25 Feb 2026 14:01:23 +0000 (15:01 +0100)] 
assert: Support assert as variadic macro for C++26 [PR27276]

C++26 changes assert into a variadic macro to support using
assignment-expressions that would be interpreted as multiple macro
arguments, in particular one containing:
* template parameter lists: func<int, float>()
* calls to overloaded operator[] that accepts multiple arguments: arr[1, 2]
  this is C++23 feature, see libstdc++ PR/119855 [1]
* lambdas with explicit captures: [x, y] { ... }

The new expansion in form:
  (__VA_ARGS__) ? void (1 ? 1 : bool (__VA_ARGS__))
                : __assert_fail (...)
Has the following properties:
* Use of (__VA_ARGS__) ? ... : ..., requires that __VA_ARGS__
  is contextually convertible to bool. This means that enumerators
  of scoped enumeration are no longer accepted (they are only
  explicitly convertible). Thus this patch address the glibc PR/27276 [2].
* Nested ternary 1 ? 1 : bool (__VA_ARGS__) guarantees that
  expression expanded from __VA_ARGS__ is not evaluated twice.
  This is used instead of unevaluated context (like sizeof...)
  to support C++ expressions that are not allowed in unevaluated
  context (lambdas until C++20, co_await, co_yield).
* bool (__VA_ARGS__) is ill-formed if __VA_ARGS__ expands to
  multiple arguments: assert(1, 2)
* bool (__VA_ARGS__) also triggers warnings when __VA_ARGS__
  expands to x = 1: assert(x = 1)

To guarantee that the code snippets from assert/test-assert-c++-variadic.cc,
are actually checked for validity, we need to compile this test in C++26
(-std=c++26) mode. To achieve that, this patch compiles the file with
test-config-cxxflags-stdcxx26 variable as additional flag, that is set to
-std=c++26 if $(TEST_CXX) executable supports that flag, and empty otherwise.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119855
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=27276

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agomath: Sync atanh with CORE-MATH
Adhemerval Zanella [Tue, 27 Jan 2026 19:56:45 +0000 (19:56 +0000)] 
math: Sync atanh with CORE-MATH

It speeds the fast-path for |x|<0.25.  The CORE-MATH muldd is the
same as muldd2 from glibc ddcoremath.h.

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

Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
2 months agomath: Sync log10p1f with CORE-MATH
Adhemerval Zanella [Tue, 27 Jan 2026 19:56:44 +0000 (19:56 +0000)] 
math: Sync log10p1f with CORE-MATH

The new code shows a small performance increase in x86_64:

latency                      patched        sync   improvement
x86_64                       41.8873     40.2864         3.82%
x86_64v2                     40.5859     39.2079         3.40%
x86_64v3                     34.6393     33.5018         3.28%
aarch64                      15.2731     14.5953         4.44%
armhf-vpfv4                  17.0373     17.0186         0.11%
powerpc64le                   8.3341      8.3298         0.05%

reciprocal-throughput        patched        sync   improvement
x86_64                       15.6516     13.6373        12.87%
x86_64v2                     15.0551     13.2769        11.81%
x86_64v3                     12.8994     11.0628        14.24%
aarch64                       8.8306      9.1898        -4.07%
armhf-vpfv4                   9.5855     10.0199        -4.53%
powerpc64le                   4.0074      4.4466       -10.96%

x86_64 / i686      gcc version 15.2.1 20260112. Ryzen 5900X
aarch64:           gcc version 15.2.1 20251105, Neoverse-N1
armv7a-vpfv4:      gcc version 15.2.1 20251105, Neoverse-N1
powerpc64le:       gcc version 14.2.1 20241230, POWER10

The code size also show slight improvement, the s_log10pf.os
'size' output shows:

size                patched     sync   improvement
x86_64                 2345     2243         4.35%
x86_64v2               2345     2243         4.35%
x86_64v3               2226     2162         2.88%
aarch64                2104     2112        -0.38%
armhf-vpfv4            2016     2012         0.20%
powerpc64le            2324     2340        -0.69%

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

Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
2 months agomath: Sync log10f with CORE-MATH
Adhemerval Zanella [Tue, 27 Jan 2026 19:56:43 +0000 (19:56 +0000)] 
math: Sync log10f with CORE-MATH

The performance is similar:

latency                        master        sync  improvement
x86_64                        34.6851     32.7977        5.44%
x86_64v2                      34.0921     32.4295        4.88%
x86_64v3                      27.8292     27.6070        0.80%
aarch64                       11.7246     11.1351        5.03%
armhf-vpfv4                   13.3748     12.9055        3.51%
powerpc64le                    6.4036      6.5825       -2.79%

reciprocal-throughput          master        sync  improvement
x86_64                        10.2653     10.0437        2.16%
x86_64v2                      10.8432     10.7040        1.28%
x86_64v3                      10.9006     11.0765       -1.61%
aarch64                        6.6447      6.2743        5.57%
armhf-vpfv4                    6.8916      6.7538        2.00%
powerpc64le                    2.9494      2.7661        6.21%

x86_64 / i686      gcc version 15.2.1 20260112. Ryzen 5900X
aarch64:           gcc version 15.2.1 20251105, Neoverse-N1
armv7a-vpfv4:      gcc version 15.2.1 20251105, Neoverse-N1
powerpc64le:       gcc version 14.2.1 20241230, POWER10

The code size is also similar.

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

Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
2 months agomath: Sync log2p1f with CORE-MATH
Adhemerval Zanella [Tue, 27 Jan 2026 19:56:42 +0000 (19:56 +0000)] 
math: Sync log2p1f with CORE-MATH

The new code shows better performance overall:

latency                      patched        sync   improvement
x86_64                       48.5909     33.3368        31.39%
x86_64v2                     49.1357     33.9981        30.81%
x86_64v3                     39.2397     28.0957        28.40%
aarch64                      16.5372     12.8133        22.52%
armhf-vpfv4                  18.1434     14.5273        19.93%
powerpc64le                   9.0999     7.49235        17.67%

reciprocal-throughput        patched        sync   improvement
x86_64                       14.5197     10.9726        24.43%
x86_64v2                     14.7640     11.1358        24.57%
x86_64v3                     11.5523     9.83253        14.89%
aarch64                       8.2854      7.8479         5.28%
armhf-vpfv4                   8.8586      8.5245         3.77%
powerpc64le                   3.8995      4.0069        -2.75%

x86_64 / i686      gcc version 15.2.1 20260112. Ryzen 5900X
aarch64:           gcc version 15.2.1 20251105, Neoverse-N1
armv7a-vpfv4:      gcc version 15.2.1 20251105, Neoverse-N1
powerpc64le:       gcc version 14.2.1 20241230, POWER10

The sync also improves the internal table size, the s_log1pf.os
'size' output shows:

size                         master        sync   improvement
x86_64                         3417        2089        38.86%
x86_64v2                       3417        2089        38.86%
x86_64v3                       3228        2001        38.01%
i686                           3490        2151        38.37%
aarch64                        3200        1888        41.00%
armhf-vpfv4                    3080        1804        41.43%
powerpc64le                    3408        2148        36.97%

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

Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
2 months agomath: Sync log1pf with CORE-MATH
Adhemerval Zanella [Tue, 27 Jan 2026 19:56:41 +0000 (19:56 +0000)] 
math: Sync log1pf with CORE-MATH

The performance is similar, with some minor regression:

latency                      master        sync   improvement
x86_64                      38.2841     38.1375         0.38%
x86_64v2                    37.7338     37.4292         0.81%
x86_64v3                    31.3500     32.3576        -3.21%
aarch64                     13.7384     13.9030        -1.20%
armhf-vpfv4                 15.5730     16.5105        -6.02%
powerpc64le                  7.6038      7.5757         0.37%

reciprocal-throughput        master        sync   improvement
x86_64                      12.4910     11.9683         4.18%
x86_64v2                    12.2935     11.7614         4.33%
x86_64v3                    11.5444     10.6369         7.86%
aarch64                      7.7262      7.8954        -2.19%
armhf-vpfv4                  8.3502      8.8741        -6.27%
powerpc64le                  3.5883      3.5259         1.74%

x86_64 / i686      gcc version 15.2.1 20260112. Ryzen 5900X
aarch64:           gcc version 15.2.1 20251105, Neoverse-N1
armv7a-vpfv4:      gcc version 15.2.1 20251105, Neoverse-N1
powerpc64le:       gcc version 14.2.1 20241230, POWER10

The sync also improves the internal table size, the s_log1pf.os
'size' output shows:

size                         master       sync    improvement
x86_64                         2078       1641         21.03%
x86_64v2                       2078       1641         21.03%
x86_64v3                       1975       1514         23.34%
aarch64                        1808       1336         26.11%
armhf-vpfv4                    1716       1284         25.17%
powerpc64le                    2132       1616         24.20%

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

Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
2 months agohtl: Fix mt-safeness of libio
Samuel Thibault [Sun, 1 Mar 2026 16:57:54 +0000 (17:57 +0100)] 
htl: Fix mt-safeness of libio

Since d2e04918833 ("Single threaded stdio optimization")
we are supposed to call _IO_enable_locks when creating the first thread,
but that commit missed doing it for htl.

2 months agohurd: Sign-extend the sigcode passed to msg_sig_post
Samuel Thibault [Sun, 1 Mar 2026 16:01:25 +0000 (17:01 +0100)] 
hurd: Sign-extend the sigcode passed to msg_sig_post

The negative sigcodes are reserved for SI_* values, we need to keep them
negative when extending to exc_subcode's long type.

This fixes the comparison in HURD_PREEMPT_SIGNAL_P for the signal preemptor
for setitimer, thus fixing considering it.it_interval.

Reported-by: David Yang <mmyangfl@gmail.com>
2 months agoVectorise inverse hyperbolic special cases
Cosmina.Dunca@arm.com [Thu, 26 Feb 2026 14:23:45 +0000 (14:23 +0000)] 
Vectorise inverse hyperbolic special cases

Vectorise SVE and AdvSIMD special-case handling for inverse
hyperbolic functions (acosh, asinh, atanh).

General-case improvements yield an average 11% speedup, with
peak gains of up to 80%.

For benchmarking I used Neoverse V2 with GCC@15.

2 months agoAArch64: Single and Double precision entire exp family, SVE and AdvSIMD optimisations
Richard.Wild@arm.com [Thu, 26 Feb 2026 15:25:59 +0000 (15:25 +0000)] 
AArch64: Single and Double precision entire exp family, SVE and AdvSIMD optimisations

This patch vectorises remaining special cases and optimises some
fast path performance for single and double precision exp, SVE and
AdvSIMD.

Moves most special case functions to header files to minimise code size.

Uses NOINLINE in main case where half width alias is used to minimise
codegen.

Special case vectorisation performance increase of average 8x to
greatest 9.5x.

Special case improvements performance increase average 15% speed
improvement to greatest 40%.

Some fast path gains during rework of files. Fastest notable increase
in exp2m1 AdvSIMD double precision of 26% improvement. Most fast
paths improved by 5-10%. 8 unchanged. No regressions.

Benchmarked on Neoverse V2 with GCC@15

2 months agomanual: Document that EOPNOTSUPP and ENOTSUP are equal, not distinct (BZ 2363)
Nicolas Boulenguez [Thu, 26 Feb 2026 02:20:11 +0000 (03:20 +0100)] 
manual: Document that EOPNOTSUPP and ENOTSUP are equal, not distinct (BZ 2363)

The section 2.1 of the glibc manual says that EWOULDBLOCK == EAGAIN,
but forgets to mention that ENOTSUP == EOPNOTSUPP.

https://sourceware.org/legacy-ml/libc-alpha/2019-08/msg00629.html
https://sourceware.org/bugzilla/show_bug.cgi?id=2363
https://bugs.debian.org/337013

Signed-off-by: Nicolas Boulenguez <nicolas@debian.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agoAArch64: Vectorise SVE log/log2/log10 single and double precision special cases.
Richard.Wild@arm.com [Thu, 26 Feb 2026 11:04:46 +0000 (11:04 +0000)] 
AArch64: Vectorise SVE log/log2/log10 single and double precision special cases.

This patch vectorises scalar fallbacks for SVE logB(f) functions.

Special case performance increase of around 3x speedup for double
and 5x speedup for single precision.

Some fast path gains during rework of files. Most fast paths improved
by 2-3%. 2 unchanged. No regressions.

Benchmarked on Neoverse V2 with GCC@15.

2 months agoAArch64: Single and Double precision hyperbolics, SVE and AdvSIMD optimisations
Richard.Wild@arm.com [Thu, 26 Feb 2026 10:22:35 +0000 (10:22 +0000)] 
AArch64: Single and Double precision hyperbolics, SVE and AdvSIMD optimisations

This patch vectorises special cases and optimises some fast path
performance for single and double precision hyperbolics, sve and
advsimd.

Special case performance increase of average 4x to greatest 10x.

Some fast path gains during rework of files. Fastest notable increase
in sinh advsimd double precision of 2x. Most fast paths improved by
5-10%.

Benchmarked on Neoverse V2 with GCC@15.

2 months agomalloc: alignment might change in future versions
Paul Eggert [Thu, 26 Feb 2026 16:14:20 +0000 (08:14 -0800)] 
malloc: alignment might change in future versions

This follows up on a comment by Wilco Dijkstra; see:
https://sourceware.org/pipermail/libc-alpha/2026-February/174934.html
* NEWS: Mention this.
* manual/memory.texi (Malloc Examples):
Say that alignment guarantee might change for small allocations.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoSay malloc (0) != NULL is now common; resection
Paul Eggert [Thu, 26 Feb 2026 16:14:20 +0000 (08:14 -0800)] 
Say malloc (0) != NULL is now common; resection

* manual/memory.texi (Portable Allocation):
New section, split off from Malloc Examples.
Say that almost every system follows glibc's example
in having successful malloc (0) return non-null;
AIX is the only exception nowadays.
Document fundamental alignment portability.
Have examples match the new text, and use NULL rather than 0.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoDocument malloc alignment
Paul Eggert [Thu, 26 Feb 2026 16:14:20 +0000 (08:14 -0800)] 
Document malloc alignment

* manual/memory.texi (Malloc Examples, Changing Block Size)
(Allocating Cleared Space):
Document the alignment of the returned value.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoDocument max_align_t
Paul Eggert [Thu, 26 Feb 2026 16:14:20 +0000 (08:14 -0800)] 
Document max_align_t

* manual/lang.texi (Important Data Types): Mention max_align_t.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agomanual: Fix typo in documentation of iconv character set options
Florian Weimer [Thu, 26 Feb 2026 15:44:14 +0000 (16:44 +0100)] 
manual: Fix typo in documentation of iconv character set options

Reported-by: Andreas Schwab <schwab@suse.de>
2 months agodebug: Fix build with --enable-fortify-source=1 (BZ 33904)
Adhemerval Zanella [Thu, 26 Feb 2026 12:49:19 +0000 (09:49 -0300)] 
debug: Fix build with --enable-fortify-source=1 (BZ 33904)

The libio/bits/stdio2-decl.h only defined the prototypes for
__vasprintf_chk and __vfprintf_chk for __USE_FORTIFY_LEVEL > 1.
Also defined them for the internal header regardless.

Checked with a build with --enable-fortify-source=1 and
--enable-fortify-source=2 for all afftected ABIs.

2 months agolinux/mips: handle wait status 0x7f specially for WIFSIGNALED and WIFSTOPPED
Xi Ruoyao [Thu, 26 Feb 2026 10:50:53 +0000 (11:50 +0100)] 
linux/mips: handle wait status 0x7f specially for WIFSIGNALED and WIFSTOPPED

MIPS Linux has SIGRTMAX=127, thus the wait status 0x7f means the program
is terminated by SIGRTMAX, not stopped.

This cannot happen on other ports so make a special version of
waitstatus.h for MIPS to avoid adding redundant calculation to others.
I cannot find a way to use status only once in the expression, so use
inline functions instead of macros to avoid double-evaluating status.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoelf: Fix tst-link-map-contiguous-ldso build for Hurd
Adhemerval Zanella [Wed, 25 Feb 2026 18:35:41 +0000 (15:35 -0300)] 
elf: Fix tst-link-map-contiguous-ldso build for Hurd

Checked with a make check for i686-gnu.

2 months agoelf: parse /proc/self/maps as the last resort to find the gap for tst-link-map-contig...
Xi Ruoyao [Tue, 3 Feb 2026 08:20:12 +0000 (16:20 +0800)] 
elf: parse /proc/self/maps as the last resort to find the gap for tst-link-map-contiguous-ldso

The initialization process of libc.so calls mmap() several times and the
kernel may lay the maps into the gap.  If all pages in the gap are
occupied, the test would not be able to find the gap with mmap() and the
test would fail.

The failure reproduces most frequently on LoongArch because with the
commonly used page size (16 KiB) the gap only contains 4 pages and the
probability they are all occupied is not near to zero.

With the changes in the patch, a test run may output:

    info: ld.so link map is not contiguous
    info: object "/dev/zero" found at 0x7ffff1fe0000 - 0x7ffff1fe4000
    info: anonymous mapping found at 0x7ffff1fe4000 - 0x7ffff1fec000

Also take the chance to fix a mistake in the "object found at" message
which has puzzled me during the initial debug session.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agotests: fix tst-rseq with Linux 7.0
Michael Jeanson [Fri, 20 Feb 2026 16:01:00 +0000 (11:01 -0500)] 
tests: fix tst-rseq with Linux 7.0

A sub-test of tst-rseq is to validate the return code and errno of the
rseq syscall when attempting to register the exact same rseq area as was
done in the dynamic loader.

This involves finding the rseq area address by adding the
'__rseq_offset' to the thread pointer and calculating the area size from
the AT_RSEQ_FEATURE_SIZE auxiliary vector. However the test currently
calculates the size of the rseq area allocation in the TLS block which
must be a multiple of AT_RSEQ_ALIGN.

Up until now that happened to be the same value since the feature size
and alignment exposed by the kernel were below the minimum ABI size of
32. Starting with Linux 7.0 the feature size has reached 33 while the
alignment is now 64.

This results in the test trying to re-register the rseq area with a
different size and thus not getting the expected errno value.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 months agolibio: Fix deadlock between freopen, fflush (NULL) and fclose (bug 24963)
Florian Weimer [Mon, 23 Feb 2026 13:19:38 +0000 (14:19 +0100)] 
libio: Fix deadlock between freopen, fflush (NULL) and fclose (bug 24963)

The canonical lock ordering for stream list processing is
locking list_all_lock first, then individual streams as needed.
The fclose implementation reversed that, and the freopen
implementation performed list operations under the reverse order,
too.

Unlinking in fclose was already unconditional, and the early unlinking
looks unnecessary: _IO_file_close_it would call it even for
!_IO_IS_FILEBUF streams.

There is still a remaining concurrency defect because
_IO_new_file_init_internal links in the stream before it is
fully initialized, and it is not locked at this point.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
2 months agohurd: Define _POSIX_TIMERS to 200809L
Samuel Thibault [Sun, 22 Feb 2026 22:34:25 +0000 (23:34 +0100)] 
hurd: Define _POSIX_TIMERS to 200809L

We now have monotonic vs realtime clocks, and high-precision.

2 months agoelf: Use dl-symbol-redir-ifunc.h instead _dl_strlen
Adhemerval Zanella [Thu, 12 Feb 2026 12:48:53 +0000 (09:48 -0300)] 
elf: Use dl-symbol-redir-ifunc.h instead _dl_strlen

Also replace the loop with strlen And remove
-fno-tree-loop-distribute-patterns usage.

It requires redirect the strlen to the baseline implementation
for x86_64, aarch64, and loongarch64.

Checked on x86_64-linux-gnu{-v2,v3} and aarch64-linux-gnu with
both gcc-15 and clang-21.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 months agoposix: execvpe: skip $PATH components that are too long [BZ #33626]
Pádraig Brady [Fri, 13 Feb 2026 19:41:13 +0000 (19:41 +0000)] 
posix: execvpe: skip $PATH components that are too long [BZ #33626]

* posix/execvpe.c (__execvpe_common): Rather than error out
with ENAMETOOLONG, just ignore and try the next path.
Note we know the FILE length is <= NAME_MAX, so the ENAMETOOLONG
almost certainly pertains to the current $PATH entry.
* posix/tst-execvpe7.c: A new test based on tst-execvp3.c.
* posix/Makefile: Reference the new test.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agoRename __unused fields to __glibc_reserved.
Jakub Jelinek [Tue, 17 Feb 2026 16:06:48 +0000 (17:06 +0100)] 
Rename __unused fields to __glibc_reserved.

__unused is often defined to __attribute__((unused)) in BSD
sources and furthermore libstdc++ testsuite uses it as a macro
to verify libstdc++ headers don't use __unused identifiers.
In ~2012 glibc headers have been cleaned up, but some new
uses of __unused have reappeared (s390 fenv.h already many
years ago, the rest last November).

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoaarch64: Tests for locking GCS
Yury Khrustalev [Tue, 3 Feb 2026 15:51:11 +0000 (15:51 +0000)] 
aarch64: Tests for locking GCS

Check that GCS is locked properly based on the value of the
glibc.cpu.aarch64_gcs tunable.

Test tst-gcs-execv checks that a child process can be spawned correctly
when GCS is locked for the parent process.

Test tst-gcs-fork checks that if GCS is not locked for the parent
process, the forked child can disable GCS.

Tests tst-gcs-lock and tst-gcs-lock-static check that GCS is locked
for dynamic and static executables when run with aarch64_gcs=1.

Tests tst-gcs-unlock and tst-gcs-unlock-static check that GCS is not
locked for dynamic and static executables when run with aarch64_gcs=0.

Test tst-gcs-lock-ptrace checks via ptrace that when GCS is locked,
all GCS features are locked.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agoaarch64: Lock GCS status at startup
Yury Khrustalev [Mon, 2 Feb 2026 18:27:53 +0000 (18:27 +0000)] 
aarch64: Lock GCS status at startup

If GCS is enabled (see tunable glibc.cpu.aarch64_gcs), we lock all GCS
operations (including status, write on shadow stack, and push to shadow
stack) unless OPTIONAL policy is used.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agotests: aarch64: fix makefile dependencies for dlopen tests for BTI
Yury Khrustalev [Mon, 16 Feb 2026 12:46:39 +0000 (12:46 +0000)] 
tests: aarch64: fix makefile dependencies for dlopen tests for BTI

Some BTI tests in the sysdeps/unix/sysv/linux/aarch64 directory use
test shared objects via dlopen. Due to lack of direct makefile level
dependencies on these modules these tests could be run before the
required .so files would be created. This could lead to flaky test
results when running make check with -j flag. This commit fixes it.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 months agohurd: calling alarm() whilst handling SIGALRM can deadlock.
Mike Kelly [Sat, 14 Feb 2026 09:17:11 +0000 (09:17 +0000)] 
hurd: calling alarm() whilst handling SIGALRM can deadlock.

alarm() and restart_itimer() can attempt to acquire _hurd_siglock and
_hurd_itimer_lock in opposite sequence resulting in occasional
deadlock. Rearranged to always acquire the locks in the same sequence
with a new pre-condition that setitimer_locked() must be called with
both locks already acquired.
Message-ID: <20260214091715.157471-2-mike@weatherwax.co.uk>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 months agonss: Missing checks in __nss_configure_lookup, __nss_database_get (bug 28940)
Florian Weimer [Fri, 13 Feb 2026 08:02:07 +0000 (09:02 +0100)] 
nss: Missing checks in __nss_configure_lookup, __nss_database_get (bug 28940)

This avoids a null pointer dereference in the
nss_database_check_reload_and_get function, and assertion failures.

Reviewed-by: Sam James <sam@gentoo.org>
2 months agoLinux: In getlogin_r, use utmp fallback only for specific errors
Florian Weimer [Fri, 13 Feb 2026 08:02:07 +0000 (09:02 +0100)] 
Linux: In getlogin_r, use utmp fallback only for specific errors

Most importantly, if getwpuid_r fails, it does not make sense to retry
via utmp because the user ID obtained from there is less reliable than
the one from /proc/self/loginuid.

Reviewed-by: Sam James <sam@gentoo.org>
2 months agonss: Introduce dedicated struct nss_database_for_fork type
Florian Weimer [Fri, 13 Feb 2026 08:02:07 +0000 (09:02 +0100)] 
nss: Introduce dedicated struct nss_database_for_fork type

The initialized field in struct nss_database_data is rather confusing
because it is not used by the regular NSS code, only by the fork
state synchronization code.  Introduce a separate type and place
the initialized field there.

Reviewed-by: Sam James <sam@gentoo.org>
2 months agonscd: Add basic test
Florian Weimer [Thu, 12 Feb 2026 11:18:54 +0000 (12:18 +0100)] 
nscd: Add basic test

The innetgr tests are similar to a downstream test for rhbz#1054846.
This seems to be the first tests of this function.  The getnetgrent
tests are new, too.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 months agosupport: Add support for starting and stopping nscd
Florian Weimer [Thu, 12 Feb 2026 11:18:54 +0000 (12:18 +0100)] 
support: Add support for starting and stopping nscd

Reviewed-by: DJ Delorie <dj@redhat.com>
2 months agonscd: Pass TRY_AGAIN errors in the hosts cache to clients
Florian Weimer [Thu, 12 Feb 2026 11:18:54 +0000 (12:18 +0100)] 
nscd: Pass TRY_AGAIN errors in the hosts cache to clients

This is the minimal set of changes to get the upcoming test to pass.
The TTL extension logic is somewhat iffy.  There is a trade-off here:
correct operation under the DNS specification (no TTL extensions), or
reducing loading the infrastructure if TRY_AGAIN is the result of
overload from this client.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 months agosupport: Add missing NSS formatting and checking functions
Florian Weimer [Thu, 12 Feb 2026 11:18:54 +0000 (12:18 +0100)] 
support: Add missing NSS formatting and checking functions

This change is largely auto-generated.  The function implementations
are mechanical and use the glibc-specific support framework, so this
should be low-risk and therefore acceptable.

The struct etherent type is currently internal-only (although it
can be used by NSS modules), which is why it is not included here.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 months agosupport: Clean up NSS formatting and checking functions
Florian Weimer [Thu, 12 Feb 2026 11:18:54 +0000 (12:18 +0100)] 
support: Clean up NSS formatting and checking functions

Move <netdb.h> includes into the implementation files.  Use const
where appropriate.  Introduce support_check_nss and use it to
implement the check_* functions.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 months agoinclude: isolate __O_CLOEXEC flag for sys/mount.h and fcntl.h
DJ Delorie [Tue, 27 Jan 2026 03:24:42 +0000 (22:24 -0500)] 
include: isolate __O_CLOEXEC flag for sys/mount.h and fcntl.h

Including sys/mount.h should not implicitly include fcntl.h
as that causes namespace pollution and conflicts with kernel
headers.  It only needs O_CLOEXEC for OPEN_TREE_CLOEXEC
(although it shouldn't need that, but it's defined that way)
so we provide that define (via a private version) separately.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Tested-by: Florian Weimer <fweimer@redhat.com>
3 months agox86: Build tst-gnu2-tls2-x86* iff compiler supports TLS descriptor
Adhemerval Zanella [Thu, 5 Feb 2026 17:49:59 +0000 (14:49 -0300)] 
x86: Build tst-gnu2-tls2-x86* iff compiler supports TLS descriptor

The test modules are built with
-mtls-dialect=$(have-test-mtls-descriptor), similar to tst-gnu2-tls2.

Checked on x86_64-linux-gnu.

3 months agohurd: _hurd_intr_rpc_mach_msg() might not preserve the correct reply port
Mike Kelly [Mon, 9 Feb 2026 20:42:00 +0000 (20:42 +0000)] 
hurd: _hurd_intr_rpc_mach_msg() might not preserve the correct reply port

Calls to mach_msg_trap() that return MACH_SEND_INTERRUPTED modify the message header. A subsequent attempt at sending the message can return EINTR for handling by the caller. Mig generated code (expecting the message header to be unaltered) now fails assertion in __mig_dealloc_reply_port(). Fixed by restoring the altered message header content before reattempting RPC message delivery.
Message-ID: <20260209204213.91782-2-mike@weatherwax.co.uk>

3 months agohppa: Fix type punning in sysdeps/hppa/dl-fptr.c [BZ 33888]
John David Anglin [Tue, 10 Feb 2026 14:41:43 +0000 (09:41 -0500)] 
hppa: Fix type punning in sysdeps/hppa/dl-fptr.c [BZ 33888]

Compiling gcc with -Werror=strict-aliasing exposed a type punning
issue in dl-fptr.c.  It does a number of compare and swap operations
to atomically exchange function pointers, etc.  The PTR argument
is dereferenced to determine the type of the objects to exchange.
Casting the type of the PTR argument to a different type will
result in in an error with -Werror=strict-aliasing.  For example,
a `(ElfW(Addr) *' pointer is not strictly equivalent to a
`struct fdesc *' pointer.

Fix this by removing the casts from the COMPARE_AND_SWAP PTR
arguments and adjusting the type of the OLD and NEW arguments
to match the dereferenced PTR type.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
3 months agoUse Linux 6.19 in build-many-glibcs.py
Joseph Myers [Tue, 10 Feb 2026 13:53:46 +0000 (13:53 +0000)] 
Use Linux 6.19 in build-many-glibcs.py

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

3 months agox86-64: Use 32-bit zero idiom for shorter encoding
George Hu [Mon, 9 Feb 2026 19:22:18 +0000 (20:22 +0100)] 
x86-64: Use 32-bit zero idiom for shorter encoding

Replace the 64-bit zero idiom with the 32-bit form. In 64-bit mode,
zeroing the lower 32 bits of a GPR implicitly clears the entire
register. The 32-bit encoding is one byte shorter while preserving
identical semantics.

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 months agoSHARED-FILES: Update Unicode version to 17.0.0.
Carlos O'Donell [Fri, 6 Feb 2026 22:05:31 +0000 (17:05 -0500)] 
SHARED-FILES: Update Unicode version to 17.0.0.

In commit 88dc93cb400b832d2478c6c70bc4cf8c5b37432d we updated to
Unicode 17.0.0.

3 months agomalloc: Remove unused tcache code from unsorted bin scan
Wilco Dijkstra [Wed, 17 Dec 2025 16:16:23 +0000 (16:16 +0000)] 
malloc: Remove unused tcache code from unsorted bin scan

Now that fastbins have been removed, there is no need to add chunks
to tcache during an unsorted scan.  Small blocks can only be added
to unsorted as a result of a remainder chunk split off a larger block,
so there is no point in checking for additional chunks to place in
tcache.  The last remainder is checked first, and will be used if it
is large enough or an exact fit.  The unsorted bin scan becomes simpler
as a result.  Remove the tcache_unsorted_limit tunable and manual entries.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
3 months agotests: aarch64: clean up BTI and GCS tests
Yury Khrustalev [Thu, 5 Feb 2026 15:16:42 +0000 (15:16 +0000)] 
tests: aarch64: clean up BTI and GCS tests

No functional change, just cleaning up code, fixing style
and correcting typos.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agotests: aarch64: move BTI tests to linux/aarch64 folder
Yury Khrustalev [Thu, 5 Feb 2026 14:29:13 +0000 (14:29 +0000)] 
tests: aarch64: move BTI tests to linux/aarch64 folder

No functional change. BTI tests check Linux-related functionality
and belong in the linux/aarch64 directory.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agotst-{pthread|sched}-affinity-inheritance: Only use in-mask CPUs in affinity mask.
Stefan Liebler [Thu, 5 Feb 2026 12:03:08 +0000 (13:03 +0100)] 
tst-{pthread|sched}-affinity-inheritance: Only use in-mask CPUs in affinity mask.

On s390x, the two tests are failing on a lpar with linux 6.18 booted with nosmt:
FAIL:  misc/tst-sched-affinity-inheritance
FAIL:  nptl/tst-pthread-affinity-inheritance

Both tests were failing because they are claiming that the CPU affinity mask was
not correctly inherited in the forked process/thread.
The error already happened before forking, as the mask was set up to use
CPUs 0-14 in set_cpu_mask().  But according to e.g. lscpu or the line
"Cpus_allowed_list" in /proc/self/status, only the following CPUs were in mask at startup:
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
while 1, 3, 5, ... were configured, but not online.

Now the test first gets the current CPU mask at startup in do_test() and
set_cpu_mask() only selects those available CPUs.  The test is now just
counting the available CPUs instead of relying on get_nprocs().  This allows
to run the test even if it was already limited via taskset.

Therefore both concrete tests now have the get_my_affinity() function.  This
also allows to implement verify_my_affinity() in the common skeleton.

In order to ensure that the affinity mask is really set as expected,
verify_my_affinity() is now also called before forking a new process or
creating a new thread.

For also printing the list of mismatched CPU IDs in xor_set in
verify_my_affinity(), the argument order of CPU_ISSET_S is now fixed.
Furthermore we now keep iterating over all configured CPUs to print
the list of cpucount IDs instead of iterating over the first nproc CPUs.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 months agohurd: Take cancel_lock in critical section
Samuel Thibault [Tue, 3 Feb 2026 23:04:58 +0000 (23:04 +0000)] 
hurd: Take cancel_lock in critical section

read/write etc. shall be signal-safe, and take cancel_lock, so we have to
defer signal delivery while holding cancel_lock.

Reported-by: Michael Banck <mbanck@gmx.net>
3 months agomalloc: Extend malloc function hiding to tst-memalign-{2,3} (BZ #32366)
Adhemerval Zanella [Wed, 31 Dec 2025 15:38:25 +0000 (12:38 -0300)] 
malloc: Extend malloc function hiding to tst-memalign-{2,3} (BZ #32366)

clang 21 optimize out memalign.

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

3 months agoelf: Build tst-gnu2-tls2 iff compiler supports TLS descriptor
Adhemerval Zanella [Wed, 4 Feb 2026 14:03:20 +0000 (11:03 -0300)] 
elf: Build tst-gnu2-tls2 iff compiler supports TLS descriptor

The test modules are built with
-mtls-dialect=$(have-test-mtls-descriptor), similar to tst-gnu2-tls1.

Checked on x86_64-linux-gnu.

3 months agox86: Fix for cache computation on Hygon under hypervisors
Jiamei Xie [Wed, 4 Feb 2026 08:46:07 +0000 (09:46 +0100)] 
x86: Fix for cache computation on Hygon under hypervisors

On Hygon CPUs, glibc currently relies on CPUID leaf 0x8000001D to
compute cache parameters. This works correctly on bare-metal
systems. However, under some hypervisors (e.g. QEMU with -cpu
qemu64), the maximum supported extended CPUID leaf is only
0x8000000A, and CPUID 0x8000001D is not exposed. In this case,
cache information computed via 0x8000001D is zeroed out.

This patch introduces legacy fallback of cache computation based on
CPUID 0x80000005 and 0x80000006, consistent with the AMD
implementation, to restore correct cache information under such
environments.

Signed-off-by: Jiamei Xie <xiejiamei@hygon.cn>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 months agosupport: Also put libaudit, libcap into the testroot if present
Florian Weimer [Wed, 4 Feb 2026 08:46:07 +0000 (09:46 +0100)] 
support: Also put libaudit, libcap into the testroot if present

Some configurations of nscd are linked against those libraries.

3 months agoRules: Set up test infrastructure if tests-container is set
Florian Weimer [Wed, 4 Feb 2026 08:46:07 +0000 (09:46 +0100)] 
Rules: Set up test infrastructure if tests-container is set

Previously, if a subdirectory had only container-based tests (via
tests-container), the Makefile rules for the test infrastructure
were excluded.

3 months agohurd: Test FPU preservation on double-signal delivery
Samuel Thibault [Tue, 3 Feb 2026 21:54:35 +0000 (21:54 +0000)] 
hurd: Test FPU preservation on double-signal delivery

This test was fixed by 826484111a ("hurd: handling pending signals could
result in corruption of FPU state.")

3 months agohurd: handling pending signals could result in corruption of FPU state
Mike Kelly [Mon, 2 Feb 2026 07:25:02 +0000 (07:25 +0000)] 
hurd: handling pending signals could result in corruption of FPU state

Handling a pending signal calls _hurd_setup_sighandler() once again
after the initial signal handling. In this case a pointer to the
previous sigcontext is available to supply the interrupted thread's
original basic state, fpu state and fpu XSTATE. The original XSTATE
was not being preserved by the pending signal but instead overwritten
with the active XSTATE. XSTATE register values modified by the
signal handling code could therefore be wrongly propogated back to
the interrupted user code.

3 months agognulib: sync comment from upstream
Paul Eggert [Tue, 3 Feb 2026 17:28:23 +0000 (09:28 -0800)] 
gnulib: sync comment from upstream

3 months agoAArch64: Add if('fastmath') to math-vector-fortran.h [BZ #33226]
Wilco Dijkstra [Tue, 27 Jan 2026 14:28:35 +0000 (14:28 +0000)] 
AArch64: Add if('fastmath') to math-vector-fortran.h [BZ #33226]

Only enable vector math functions with -ffast-math by adding if('fastmath').
This uses a new annotation supported by GCC 16 (PR 118955).  If an older
compiler is used, it will disable the math function without an error.
This fixes BZ #33226.

3 months agoAArch64: Optimize memcpy for Kunpeng 950 processor
Weihong Ye [Tue, 3 Feb 2026 17:09:03 +0000 (17:09 +0000)] 
AArch64: Optimize memcpy for Kunpeng 950 processor

For copies ≤64 bytes, the implementation remains consistent with memcpy_sve.
For 65–128 bytes, it removes the 96-byte branch and reorders instructions,
improving performance by 18–32%.  For >128 bytes, it aligns the destination
to a 32-byte boundary and uses Pre-indexed load/store instructions to reduce
address-update overhead.

All benchmarks report execution time (lower is better). Geomean results
    (__memcpy_generic → this patch):
    - bench-memcpy:         16.74 → 12.11  (28% faster)
    - bench-memcpy-large:   24287 → 23302  (4% faster)
    - bench-memcpy-random: 107693 → 72153  (33% faster)

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agoDon't include <bits/openat2.h> directly (bug 33848)
Andreas Schwab [Tue, 3 Feb 2026 11:41:23 +0000 (12:41 +0100)] 
Don't include <bits/openat2.h> directly (bug 33848)

Headers from bits directories should never be included directly, only via
the official headers.

3 months agoposix: avoid a cast in regex syntax bit definitions
Collin Funk [Mon, 26 Jan 2026 02:52:34 +0000 (18:52 -0800)] 
posix: avoid a cast in regex syntax bit definitions

The cast doesn't have any benefit over using a UL suffix and prevents
the macro from being used in preprocessor directives.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
3 months agoelf: Add test case for LD_PROFILE/LD_PROFILE_OUTPUT interaction
Florian Weimer [Mon, 2 Feb 2026 20:15:48 +0000 (21:15 +0100)] 
elf: Add test case for LD_PROFILE/LD_PROFILE_OUTPUT interaction

This verifies that LD_PROFILE is correctly ignored if LD_PROFILE_OUTPUT
is not set.

The test was initially auto-generated, then heavily edited and re-edited
for brevity and clarity.  The test uses glibc-specific interfaces
(including one that did not exist at all a couple of hours ago), so
this should be unproblematic.

3 months agosupport: Add support_spawn_wrap and related functionality
Florian Weimer [Mon, 2 Feb 2026 20:15:48 +0000 (21:15 +0100)] 
support: Add support_spawn_wrap and related functionality

It allows us to write test cases in C that run tests with
dynamic linker wrapping.

The iconv test case was auto-generated.  The posix_spawn usage
is mechanical, and the interface it tests is newly added in this
commit, so this should be acceptable.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoarm: Fix tst-gnu2-tls2
Adhemerval Zanella [Tue, 20 Jan 2026 13:11:10 +0000 (10:11 -0300)] 
arm: Fix tst-gnu2-tls2

On armv7a vfpv4 tst-gnu2-tls2 fails with:

  open tst-gnu2-tls2mod0.so
  open tst-gnu2-tls2mod1.so
  open tst-gnu2-tls2mod2.so
  close tst-gnu2-tls2mod0.so
  close tst-gnu2-tls2mod1.so
  open tst-gnu2-tls2mod0.so
  open tst-gnu2-tls2mod1.so
  Didn't expect signal from child: got `Aborted'

Because AFTER_TLSDESC_CALL might clobber caller-saved registers and
the zero array might call the memset function resolution, which itself
might clobber some vector registers.

The AFTER_TLSDESC_CALL calls memset and memcmp, and both the
lazy resolution and the routines themselves can clobber the
caller-saved registes used in the tests.

Checked on arm-linux-gnueabihf (armv7-a vpfv4 / QEMU).

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 months agolinux: use PIDFD_GET_INFO ioctl for pidfd_getpid() if available
Luca Boccassi [Wed, 28 Jan 2026 15:37:56 +0000 (15:37 +0000)] 
linux: use PIDFD_GET_INFO ioctl for pidfd_getpid() if available

Linux v6.13 introduced a new ioctl to query info from a pidfd.
The advantage of this vs. parsing /proc/ is that it works even
when procfs is not mounted. It's also a single syscall, and doesn't
need manual string parsing. Use it when available.

Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoelf: Fix ambiguous error message for --f in sotruss [BZ #25257]
Avinal Kumar [Mon, 5 Jan 2026 13:29:27 +0000 (18:59 +0530)] 
elf: Fix ambiguous error message for --f in sotruss [BZ #25257]

The sotruss utility printed an incomplete error message when the
ambiguous option --f was used.  The message did not list the possible
matching options, making it unclear how to resolve the ambiguity.

This commit corrects the error message to report all valid alternatives.

Example after this change:

$ sotruss --f /bin/true
sotruss: option '--f' is ambiguous; possibilities: '--from' '--follow'
Try `sotruss --help' or `sotruss --usage' for more information.

This fixes BZ #25257.

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
Suggested-by: Carlos Santos <casantos@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agopowerpc: Add math-use-builtins-f{max,min}.h
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:26 +0000 (10:02 -0300)] 
powerpc: Add math-use-builtins-f{max,min}.h

ISA 2.06 (POWER7) added xsmindp/xsmaxdp, but we can only
use the builtin for GCC 14+ [1]

Checked on powerpc64le-linux-gnu.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103605

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agomath: Optimize f{max,min}imum_mag_num{f,l,f128}
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:25 +0000 (10:02 -0300)] 
math: Optimize f{max,min}imum_mag_num{f,l,f128}

Simplify order signal comparison and reorganize check to reduce
branches and allow targets to use conditional select/move.

With gcc-15 on aarch64 for fmaximum_mag_num:

* master:

0000000000000000 <__fmaximum_mag_num>:
   0:   d503245f        bti     c
   4:   1e60c004        fabs    d4, d0
   8:   1e60c023        fabs    d3, d1
   c:   1e632080        fcmp    d4, d3
  10:   5400008d        b.le    20 <__fmaximum_mag_num+0x20>
  14:   1e60401f        fmov    d31, d0
  18:   1e6043e0        fmov    d0, d31
  1c:   d65f03c0        ret
  20:   54000085        b.pl    30 <__fmaximum_mag_num+0x30>  // b.nfrst
  24:   1e60403f        fmov    d31, d1
  28:   1e6043e0        fmov    d0, d31
  2c:   d65f03c0        ret
  30:   54000161        b.ne    5c <__fmaximum_mag_num+0x5c>  // b.any
  34:   4f000402        movi    v2.4s, #0x0
  38:   1e6e101d        fmov    d29, #1.000000000000000000e+00
  3c:   6ee0f842        fneg    v2.2d, v2.2d
  40:   4ea21c5e        mov     v30.16b, v2.16b
  44:   2e7d1c22        bsl     v2.8b, v1.8b, v29.8b
  48:   2e7d1c1e        bsl     v30.8b, v0.8b, v29.8b
  4c:   1e6223d0        fcmpe   d30, d2
  50:   1e61ac1f        fcsel   d31, d0, d1, ge // ge = tcont
  54:   1e6043e0        fmov    d0, d31
  58:   d65f03c0        ret
  5c:   1e612020        fcmp    d1, d1
  60:   1e60403f        fmov    d31, d1
  64:   54ffff87        b.vc    54 <__fmaximum_mag_num+0x54>
  68:   1e602000        fcmp    d0, d0
  6c:   1e60401f        fmov    d31, d0
  70:   54ffff27        b.vc    54 <__fmaximum_mag_num+0x54>
  74:   1e61281f        fadd    d31, d0, d1
  78:   17fffff7        b       54 <__fmaximum_mag_num+0x54>

* patch:

0000000000000000 <__fminimum_mag_num>:
   0:   d503245f        bti     c
   4:   1e612000        fcmp    d0, d1
   8:   1e60401f        fmov    d31, d0
   c:   540000e6        b.vs    28 <__fminimum_mag_num+0x28>
  10:   1e60c01e        fabs    d30, d0
  14:   1e60c03d        fabs    d29, d1
  18:   1e7d23c0        fcmp    d30, d29
  1c:   54000160        b.eq    48 <__fminimum_mag_num+0x48>  // b.none
  20:   1e605c20        fcsel   d0, d1, d0, pl  // pl = nfrst
  24:   d65f03c0        ret
  28:   1e612020        fcmp    d1, d1
  2c:   1e604020        fmov    d0, d1
  30:   54ffffa7        b.vc    24 <__fminimum_mag_num+0x24>
  34:   1e7f23e0        fcmp    d31, d31
  38:   1e6043e0        fmov    d0, d31
  3c:   54ffff47        b.vc    24 <__fminimum_mag_num+0x24>
  40:   1e612be0        fadd    d0, d31, d1
  44:   d65f03c0        ret
  48:   9e660000        fmov    x0, d0
  4c:   f100001f        cmp     x0, #0x0
  50:   1e61bc00        fcsel   d0, d0, d1, lt  // lt = tstop
  54:   d65f03c0        ret

Checked on x86_64-linux-gnu, aarch64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu,
riscv64-linux-gnu-rv64imafdc-lp64d, and loongarch64-linux-gnuf64.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agomath: Optimize f{max,min}imum_mag{f,l,f128}
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:24 +0000 (10:02 -0300)] 
math: Optimize f{max,min}imum_mag{f,l,f128}

Simplify order signal comparison and reorganize check to reduce
branches and allow targets to use conditional select/move.

With gcc-15 on aarch64 for fmaximum_mag:

* master:

0000000000000000 <__fmaximum_mag>:
   0:   d503245f        bti     c
   4:   1e60c004        fabs    d4, d0
   8:   1e60c023        fabs    d3, d1
   c:   1e632080        fcmp    d4, d3
  10:   5400008d        b.le    20 <__fmaximum_mag+0x20>
  14:   1e60401f        fmov    d31, d0
  18:   1e6043e0        fmov    d0, d31
  1c:   d65f03c0        ret
  20:   54000085        b.pl    30 <__fmaximum_mag+0x30>  // b.nfrst
  24:   1e60403f        fmov    d31, d1
  28:   1e6043e0        fmov    d0, d31
  2c:   d65f03c0        ret
  30:   54000161        b.ne    5c <__fmaximum_mag+0x5c>  // b.any
  34:   4f000402        movi    v2.4s, #0x0
  38:   1e6e101d        fmov    d29, #1.000000000000000000e+00
  3c:   6ee0f842        fneg    v2.2d, v2.2d
  40:   4ea21c5e        mov     v30.16b, v2.16b
  44:   2e7d1c22        bsl     v2.8b, v1.8b, v29.8b
  48:   2e7d1c1e        bsl     v30.8b, v0.8b, v29.8b
  4c:   1e6223d0        fcmpe   d30, d2
  50:   1e61ac1f        fcsel   d31, d0, d1, ge // ge = tcont
  54:   1e6043e0        fmov    d0, d31
  58:   d65f03c0        ret
  5c:   1e61281f        fadd    d31, d0, d1
  60:   1e6043e0        fmov    d0, d31
  64:   d65f03c0        ret

* patch:

0000000000000000 <__fmaximum_mag>:
   0:   d503245f        bti     c
   4:   1e612000        fcmp    d0, d1
   8:   540000e6        b.vs    24 <__fmaximum_mag+0x24>
   c:   1e60c01f        fabs    d31, d0
  10:   1e60c03e        fabs    d30, d1
  14:   1e7e23e0        fcmp    d31, d30
  18:   540000a0        b.eq    2c <__fmaximum_mag+0x2c>  // b.none
  1c:   1e60dc20        fcsel   d0, d1, d0, le
  20:   d65f03c0        ret
  24:   1e612800        fadd    d0, d0, d1
  28:   d65f03c0        ret
  2c:   9e660000        fmov    x0, d0
  30:   f100001f        cmp     x0, #0x0
  34:   1e60bc20        fcsel   d0, d1, d0, lt  // lt = tstop
  38:   d65f03c0        ret

Checked on x86_64-linux-gnu, aarch64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu,
riscv64-linux-gnu-rv64imafdc-lp64d, and loongarch64-linux-gnuf64.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agomath: Optimize f{max,min}imum_num{f,l,f,f128}
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:23 +0000 (10:02 -0300)] 
math: Optimize f{max,min}imum_num{f,l,f,f128}

Add an isunordered check for fast-path and simplified sign check
and use the fmax/fmin when possible.

With gcc-15 on aarch64 for fmaximum_num:

* master

0000000000000000 <__fmaximum_num>:
   0:   d503245f        bti     c
   4:   1e612000        fcmp    d0, d1
   8:   5400008d        b.le    18 <__fmaximum_num+0x18>
   c:   1e60401f        fmov    d31, d0
  10:   1e6043e0        fmov    d0, d31
  14:   d65f03c0        ret
  18:   54000085        b.pl    28 <__fmaximum_num+0x28>  // b.nfrst
  1c:   1e60403f        fmov    d31, d1
  20:   1e6043e0        fmov    d0, d31
  24:   d65f03c0        ret
  28:   54000161        b.ne    54 <__fmaximum_num+0x54>  // b.any
  2c:   4f000402        movi    v2.4s, #0x0
  30:   1e6e101e        fmov    d30, #1.000000000000000000e+00
  34:   6ee0f842        fneg    v2.2d, v2.2d
  38:   4ea21c5d        mov     v29.16b, v2.16b
  3c:   2e7e1c22        bsl     v2.8b, v1.8b, v30.8b
  40:   2e7e1c1d        bsl     v29.8b, v0.8b, v30.8b
  44:   1e6223b0        fcmpe   d29, d2
  48:   1e61ac1f        fcsel   d31, d0, d1, ge // ge = tcont
  4c:   1e6043e0        fmov    d0, d31
  50:   d65f03c0        ret
  54:   1e612020        fcmp    d1, d1
  58:   1e60403f        fmov    d31, d1
  5c:   54ffff87        b.vc    4c <__fmaximum_num+0x4c>
  60:   1e602000        fcmp    d0, d0
  64:   1e60401f        fmov    d31, d0
  68:   54ffff27        b.vc    4c <__fmaximum_num+0x4c>
  6c:   1e61281f        fadd    d31, d0, d1
  70:   17fffff7        b       4c <__fmaximum_num+0x4c>

* patch:

0000000000000000 <__fmaximum_num>:
   0:   d503245f        bti     c
   4:   1e612000        fcmp    d0, d1
   8:   54000086        b.vs    18 <__fmaximum_num+0x18>
   c:   1e61681f        fmaxnm  d31, d0, d1
  10:   1e6043e0        fmov    d0, d31
  14:   d65f03c0        ret
  18:   1e612020        fcmp    d1, d1
  1c:   1e60403f        fmov    d31, d1
  20:   54ffff87        b.vc    10 <__fmaximum_num+0x10>
  24:   1e602000        fcmp    d0, d0
  28:   1e60401f        fmov    d31, d0
  2c:   54ffff27        b.vc    10 <__fmaximum_num+0x10>
  30:   1e61281f        fadd    d31, d0, d1
  34:   17fffff7        b       10 <__fmaximum_num+0x10>

And with gcc-15 on x86_64:

* master:

0000000000000000 <__fmaximum_num>:
   0:   66 0f 2e c1             ucomisd %xmm1,%xmm0
   4:   66 0f 28 d8             movapd %xmm0,%xmm3
   8:   77 5e                   ja     68 <__fmaximum_num+0x68>
   a:   66 0f 2e c8             ucomisd %xmm0,%xmm1
   e:   77 50                   ja     60 <__fmaximum_num+0x60>
  10:   66 0f 2e c1             ucomisd %xmm1,%xmm0
  14:   7a 5a                   jp     70 <__fmaximum_num+0x70>
  16:   75 58                   jne    70 <__fmaximum_num+0x70>
  18:   f3 0f 7e 05 00 00 00    movq   0x0(%rip),%xmm0        # 20 <__fmaximum_num+0x20>
  1f:   00
  20:   f2 0f 10 15 00 00 00    movsd  0x0(%rip),%xmm2        # 28 <__fmaximum_num+0x28>
  27:   00
  28:   66 0f 28 e0             movapd %xmm0,%xmm4
  2c:   66 0f 54 15 00 00 00    andpd  0x0(%rip),%xmm2        # 34 <__fmaximum_num+0x34>
  33:   00
  34:   66 0f 54 c1             andpd  %xmm1,%xmm0
  38:   66 0f 54 e3             andpd  %xmm3,%xmm4
  3c:   66 0f 56 e2             orpd   %xmm2,%xmm4
  40:   66 0f 56 d0             orpd   %xmm0,%xmm2
  44:   f2 0f c2 d4 02          cmplesd %xmm4,%xmm2
  49:   66 0f 54 da             andpd  %xmm2,%xmm3
  4d:   66 0f 55 d1             andnpd %xmm1,%xmm2
  51:   66 0f 56 d3             orpd   %xmm3,%xmm2
  55:   66 0f 28 c2             movapd %xmm2,%xmm0
  59:   c3                      ret
  5a:   66 0f 1f 44 00 00       nopw   0x0(%rax,%rax,1)
  60:   66 0f 28 c1             movapd %xmm1,%xmm0
  64:   c3                      ret
  65:   0f 1f 00                nopl   (%rax)
  68:   c3                      ret
  69:   0f 1f 80 00 00 00 00    nopl   0x0(%rax)
  70:   66 0f 2e c9             ucomisd %xmm1,%xmm1
  74:   66 0f 28 c1             movapd %xmm1,%xmm0
  78:   7b ea                   jnp    64 <__fmaximum_num+0x64>
  7a:   66 0f 2e db             ucomisd %xmm3,%xmm3
  7e:   66 0f 28 c3             movapd %xmm3,%xmm0
  82:   7b e0                   jnp    64 <__fmaximum_num+0x64>
  84:   f2 0f 58 c1             addsd  %xmm1,%xmm0
  88:   c3                      ret

* patch:

0000000000000000 <__fmaximum_num>:
   0:   66 0f 2e c1             ucomisd %xmm1,%xmm0
   4:   7a 2a                   jp     30 <__fmaximum_num+0x30>
   6:   77 18                   ja     20 <__fmaximum_num+0x20>
   8:   66 0f 2e c8             ucomisd %xmm0,%xmm1
   c:   77 08                   ja     16 <__fmaximum_num+0x16>
   e:   66 0f 50 c0             movmskpd %xmm0,%eax
  12:   a8 01                   test   $0x1,%al
  14:   74 0a                   je     20 <__fmaximum_num+0x20>
  16:   66 0f 28 c1             movapd %xmm1,%xmm0
  1a:   c3                      ret
  1b:   0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
  20:   66 0f 28 c8             movapd %xmm0,%xmm1
  24:   66 0f 28 c1             movapd %xmm1,%xmm0
  28:   c3                      ret
  29:   0f 1f 80 00 00 00 00    nopl   0x0(%rax)
  30:   66 0f 2e c9             ucomisd %xmm1,%xmm1
  34:   7b e0                   jnp    16 <__fmaximum_num+0x16>
  36:   66 0f 2e c0             ucomisd %xmm0,%xmm0
  3a:   7b e4                   jnp    20 <__fmaximum_num+0x20>
  3c:   f2 0f 58 c8             addsd  %xmm0,%xmm1
  40:   eb d4                   jmp    16 <__fmaximum_num+0x16>

Checked on x86_64-linux-gnu, aarch64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu,
riscv64-linux-gnu-rv64imafdc-lp64d, and loongarch64-linux-gnuf64.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agomath: Optimize f{max,min}imum{f,l,f128}
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:22 +0000 (10:02 -0300)] 
math: Optimize f{max,min}imum{f,l,f128}

Add an isunordered check for fast-path and simplified sign check
and use the fmax/fmin when possible.

With gcc-15 on aarch64:

* master:

0000000000000000 <__fmaximum>:
   0:   d503245f        bti     c
   4:   1e612000        fcmp    d0, d1
   8:   5400008d        b.le    18 <__fmaximum+0x18>
   c:   1e60401f        fmov    d31, d0
  10:   1e6043e0        fmov    d0, d31
  14:   d65f03c0        ret
  18:   54000085        b.pl    28 <__fmaximum+0x28>  // b.nfrst
  1c:   1e60403f        fmov    d31, d1
  20:   1e6043e0        fmov    d0, d31
  24:   d65f03c0        ret
  28:   54000161        b.ne    54 <__fmaximum+0x54>  // b.any
  2c:   4f000402        movi    v2.4s, #0x0
  30:   1e6e101e        fmov    d30, #1.000000000000000000e+00
  34:   6ee0f842        fneg    v2.2d, v2.2d
  38:   4ea21c5d        mov     v29.16b, v2.16b
  3c:   2e7e1c22        bsl     v2.8b, v1.8b, v30.8b
  40:   2e7e1c1d        bsl     v29.8b, v0.8b, v30.8b
  44:   1e6223b0        fcmpe   d29, d2
  48:   1e61ac1f        fcsel   d31, d0, d1, ge // ge = tcont
  4c:   1e6043e0        fmov    d0, d31
  50:   d65f03c0        ret
  54:   1e61281f        fadd    d31, d0, d1
  58:   1e6043e0        fmov    d0, d31
  5c:   d65f03c0        ret

* patch:

0000000000000000 <__fmaximum>:
   0:   d503245f        bti     c
   4:   1e612000        fcmp    d0, d1
   8:   54000086        b.vs    18 <__fmaximum+0x18>
   c:   1e61681f        fmaxnm  d31, d0, d1
  10:   1e6043e0        fmov    d0, d31
  14:   d65f03c0        ret
  18:   1e61281f        fadd    d31, d0, d1
  1c:   1e6043e0        fmov    d0, d31
  20:   d65f03c0        ret

And with gcc-15 on x86_64:

* master:

0000000000000000 <__fmaximum>:
   0:   66 0f 2e c1             ucomisd %xmm1,%xmm0
   4:   77 56                   ja     5c <__fmaximum+0x5c>
   6:   66 0f 2e c8             ucomisd %xmm0,%xmm1
   a:   77 4c                   ja     58 <__fmaximum+0x58>
   c:   66 0f 2e c1             ucomisd %xmm1,%xmm0
  10:   7a 4e                   jp     60 <__fmaximum+0x60>
  12:   75 4c                   jne    60 <__fmaximum+0x60>
  14:   f3 0f 7e 1d 00 00 00    movq   0x0(%rip),%xmm3        # 1c <__fmaximum+0x1c>
  1b:   00
  1c:   f2 0f 10 15 00 00 00    movsd  0x0(%rip),%xmm2        # 24 <__fmaximum+0x24>
  23:   00
  24:   66 0f 28 e3             movapd %xmm3,%xmm4
  28:   66 0f 54 15 00 00 00    andpd  0x0(%rip),%xmm2        # 30 <__fmaximum+0x30>
  2f:   00
  30:   66 0f 54 e0             andpd  %xmm0,%xmm4
  34:   66 0f 54 d9             andpd  %xmm1,%xmm3
  38:   66 0f 56 e2             orpd   %xmm2,%xmm4
  3c:   66 0f 56 d3             orpd   %xmm3,%xmm2
  40:   f2 0f c2 d4 02          cmplesd %xmm4,%xmm2
  45:   66 0f 54 c2             andpd  %xmm2,%xmm0
  49:   66 0f 55 d1             andnpd %xmm1,%xmm2
  4d:   66 0f 56 c2             orpd   %xmm2,%xmm0
  51:   c3                      ret
  52:   66 0f 1f 44 00 00       nopw   0x0(%rax,%rax,1)
  58:   66 0f 28 c1             movapd %xmm1,%xmm0
  5c:   c3                      ret
  5d:   0f 1f 00                nopl   (%rax)
  60:   f2 0f 58 c1             addsd  %xmm1,%xmm0
  64:   c3                      ret

* patched:

0000000000000000 <__fmaximum>:
   0:   66 0f 2e c1             ucomisd %xmm1,%xmm0
   4:   7a 2a                   jp     30 <__fmaximum+0x30>
   6:   77 18                   ja     20 <__fmaximum+0x20>
   8:   66 0f 2e c8             ucomisd %xmm0,%xmm1
   c:   77 08                   ja     16 <__fmaximum+0x16>
   e:   66 0f 50 c0             movmskpd %xmm0,%eax
  12:   a8 01                   test   $0x1,%al
  14:   74 0a                   je     20 <__fmaximum+0x20>
  16:   66 0f 28 c1             movapd %xmm1,%xmm0
  1a:   c3                      ret
  1b:   0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
  20:   66 0f 28 c8             movapd %xmm0,%xmm1
  24:   66 0f 28 c1             movapd %xmm1,%xmm0
  28:   c3                      ret
  29:   0f 1f 80 00 00 00 00    nopl   0x0(%rax)
  30:   f2 0f 58 c8             addsd  %xmm0,%xmm1
  34:   66 0f 28 c1             movapd %xmm1,%xmm0
  38:   c3                      ret

Checked on x86_64-linux-gnu, aarch64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu,
riscv64-linux-gnu-rv64imafdc-lp64d, and loongarch64-linux-gnuf64.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agomath: Order signed zeros in f{max,min}mag{f,l,f128}
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:21 +0000 (10:02 -0300)] 
math: Order signed zeros in f{max,min}mag{f,l,f128}

The functions are documented to behave like fmax/fmin when the
arguments have the same absolute value.

Checked on x86_64-linux-gnu, aarch64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu,
riscv64-linux-gnu-rv64imafdc-lp64d, and loongarch64-linux-gnuf64.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agomath: Order signed zeros in f{max,min}{f,l,f128}
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:20 +0000 (10:02 -0300)] 
math: Order signed zeros in f{max,min}{f,l,f128}

The C standard (at least from C99 until C23) does not require
fmin/fmax to order zeros by their sign, so glibc's previous behavior
was entirely standards-conforming.  However, the standard does
recommend that zeros be ordered in a footnote, saying:

"If possible, fmax is sensitive to the sign of zero, for example
fmax(−0.0, +0.0) ideally returns +0."

As this is indeed possible (and not too complicated), implement it as
a quality-of-implementation improvement.  It also remove possible
deviations between architectures, where for some architectures that
has direct mapping instruction (USE_FMA*_BUILTIN) they already do
the ordering.

Checked on x86_64-linux-gnu, aarch64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu,
riscv64-linux-gnu-rv64imafdc-lp64d, and loongarch64-linux-gnuf64.

Co-authored-by: James Y Knight <jyknight@google.com>
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agoi386: Remove f{max,min} assembly implementations
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:19 +0000 (10:02 -0300)] 
i386: Remove f{max,min} assembly implementations

The sNaN handling on i386 was not properly implemented or tested due to
ABI and compiler constraints [1] [2], and although GCC has an open bug
to try to fix at least the sNaN in the function call arguments [3], it
will most likely never be fixed.

To simplify the fix or the order signed zeros and make f{fmin,fmax} behave
semantically equal to the rest of the f{min,max}* function, this patch
removes all i386 assembly optimizations.  The f{min,max} functions should
not be hotspots in any meaningful code people are running on i386 nowadays.

Checked on i686-linux-gnu.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484#c11
[2] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=5aa4a1a1fd742479818a668d42d91ca9ec4a6318
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56831

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agox86_64: Remove f{max,min} assembly implementations
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:18 +0000 (10:02 -0300)] 
x86_64: Remove f{max,min} assembly implementations

Using recent gcc, the generic implementation generates the same code
for normal and subnormal numbers for float/double.

For long double, the generic implementations generates slight worse
code for the fast-path.  With gcc-15:

* sysdeps/x86_64/fpu/s_fmaxl.S

  fldt    8(%rsp)
  fldt    24(%rsp)
  fucomi  %st(1), %st
  jp      2f
  fcmovb  %st(1), %st
  fstp    %st(1)
  ret

* generic

  fldt     0x8(%rsp)
  fldt     0x18(%rsp)
  fucomi   %st(1),%st
  jp       18 <__fmaxl+0x18>
  fxch     %st(1)
  fcomi    %st(1),%st
  fcmovbe  %st(1),%st
  fstp     %st(1)
  ret

It could be optimized by using isgreater instead of a direct comparison
for the non unordered, but this prevents x86 to issue maxsd.

Checked on x86_64-linux-gnu.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agomath: Simplify f{max,min}mag template
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:17 +0000 (10:02 -0300)] 
math: Simplify f{max,min}mag template

On aarch64 with gcc-15 it optimizes the fast-path slightly, for fmaxmag:

* master

0000000000000000 <__fmaxmag>:
   0:   d503245f        bti     c
   4:   1e60c01e        fabs    d30, d0
   8:   1e60c03f        fabs    d31, d1
   c:   1e7f23c0        fcmp    d30, d31
  10:   5400004d        b.le    18 <__fmaxmag+0x18>
  14:   d65f03c0        ret
  18:   54000065        b.pl    24 <__fmaxmag+0x24>  // b.nfrst
  1c:   1e604020        fmov    d0, d1
  20:   d65f03c0        ret
  24:   540001e0        b.eq    60 <__fmaxmag+0x60>  // b.none
  [...]
  60:   1e612010        fcmpe   d0, d1
  64:   1e61cc00        fcsel   d0, d0, d1, gt
  68:   d65f03c0        ret

* patch:

0000000000000000 <__fmaxmag>:
   0:   d503245f        bti     c
   4:   1e612000        fcmp    d0, d1
   8:   540000e6        b.vs    24 <__fmaxmag+0x24>
   c:   1e60c01f        fabs    d31, d0
  10:   1e60c03e        fabs    d30, d1
  14:   1e7e23e0        fcmp    d31, d30
  18:   540001c0        b.eq    50 <__fmaxmag+0x50>  // b.none
  1c:   1e60dc20        fcsel   d0, d1, d0, le
  20:   d65f03c0        ret
  [...]
  50:   1e612010        fcmpe   d0, d1
  54:   1e61cc00        fcsel   d0, d0, d1, gt
  58:   d65f03c0        ret
  [...]

Checked on x86_64-linux-gnu, aarch64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu,
riscv64-linux-gnu-rv64imafdc-lp64d, and loongarch64-linux-gnuf64.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agomath: Simplify f{max,min} template
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:16 +0000 (10:02 -0300)] 
math: Simplify f{max,min} template

On x86_64, it allows the fast path (normal/subnormal inputs) to use maxsd.
With gcc-15 targetting x86_64 for fmax:

* master:

        ucomisd xmm0, xmm1
        jnb     .L1
        ucomisd xmm1, xmm0
        ja      .L13
        [...]
.L13:
        movapd  xmm0, xmm1
.L1:
        ret

* patch;

        ucomisd xmm0, xmm1
        jp      .L2
        maxsd   xmm0, xmm1
        ret

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agox86: Add __issignalingl inline
Adhemerval Zanella [Fri, 23 Jan 2026 13:02:15 +0000 (10:02 -0300)] 
x86: Add __issignalingl inline

Checked on x86_64-linux-gnu.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 months agomath: Add __issignaling inline
Wilco Dijkstra [Fri, 23 Jan 2026 13:02:14 +0000 (10:02 -0300)] 
math: Add __issignaling inline

Add __issignaling inline based on the issignaling_inline implementation.
Improve the __issignalingf inline.  Remove issignaling(f)_inline and its uses.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agomanual: Document //TRANSLIT and //IGNORE support in iconv_open [BZ #3794]
Avinal Kumar [Mon, 2 Feb 2026 15:26:13 +0000 (16:26 +0100)] 
manual: Document //TRANSLIT and //IGNORE support in iconv_open [BZ #3794]

The //TRANSLIT and //IGNORE suffix supported by iconv_open
was not documented in the glibc manual.  This commit adds the
documentation for the suffixes.

This fixes BZ #3794.

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 months agomanual: Document that iconv buffers may not overlap
Florian Weimer [Mon, 2 Feb 2026 14:20:57 +0000 (15:20 +0100)] 
manual: Document that iconv buffers may not overlap

As discussed here:

  Re: [bug-gnu-libiconv] iconv and overlapping input/output buffers
  <https://lists.gnu.org/archive/html/bug-gnu-libiconv/2026-01/msg00002.html>

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 months agostdio-common: Assume support for 'long long'
Alejandro Colomar [Tue, 11 Nov 2025 13:29:28 +0000 (14:29 +0100)] 
stdio-common: Assume support for 'long long'

GCC supports 'long long' since essentially forever.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 months agohurd: copy over start/end and entry too on fork
Samuel Thibault [Sat, 31 Jan 2026 16:04:53 +0000 (17:04 +0100)] 
hurd: copy over start/end and entry too on fork

gdb needs them to properly find libraries etc.

3 months agomanual: Fix some typos in the Threads chapter.
Collin Funk [Wed, 28 Jan 2026 07:44:51 +0000 (23:44 -0800)] 
manual: Fix some typos in the Threads chapter.

3 months agomanual: Fix some typos in the Low-Level Terminal Interface chapter.
Collin Funk [Wed, 28 Jan 2026 07:40:22 +0000 (23:40 -0800)] 
manual: Fix some typos in the Low-Level Terminal Interface chapter.

3 months agoriscv: Disable multiarch memset variants when !IS_IN(libc)
Yao Zihong [Mon, 26 Jan 2026 21:28:00 +0000 (15:28 -0600)] 
riscv: Disable multiarch memset variants when !IS_IN(libc)

This patch disables multiarch memset variants when !IS_IN(libc),
because rtld can only use a single fixed implementation.

Signed-off-by: Yao Zihong <zihong.plct@isrc.iscas.ac.cn>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoriscv: Disable multiarch memcpy variants when !IS_IN(libc)
Yao Zihong [Mon, 26 Jan 2026 21:24:40 +0000 (15:24 -0600)] 
riscv: Disable multiarch memcpy variants when !IS_IN(libc)

This patch disables multiarch memcpy variants when !IS_IN(libc),
because rtld can only use a single fixed implementation.

Signed-off-by: Yao Zihong <zihong.plct@isrc.iscas.ac.cn>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoposix: Run tst-wordexp-reuse-mem test
Florian Weimer [Mon, 26 Jan 2026 16:12:37 +0000 (17:12 +0100)] 
posix: Run tst-wordexp-reuse-mem test

The test was not properly scheduled for execution with a Makefile
dependency.

Fixes commit 80cc58ea2de214f85b0a1d902a3b668ad2ecb302 ("posix: Reset
wordexp_t fields with WRDE_REUSE (CVE-2025-15281 / BZ 33814").

3 months agomanual: Updates for the dynamic linker hardening recommendations
Florian Weimer [Mon, 26 Jan 2026 15:56:45 +0000 (16:56 +0100)] 
manual: Updates for the dynamic linker hardening recommendations

This update addresses text relocations, and clarifies
constructor/destructor priorities by mentioning the relevant
GCC attributes.

3 months agodlfcn: Add dlinfo request type RTLD_DI_ORIGIN_PATH (bug #24298)
Arjun Shankar [Mon, 26 Jan 2026 12:49:37 +0000 (13:49 +0100)] 
dlfcn: Add dlinfo request type RTLD_DI_ORIGIN_PATH (bug #24298)

The existing dlinfo request type RTLD_DI_ORIGIN used for querying the
value of the '$ORIGIN' dynamic string token is prone to buffer
overflows.

This commit adds a new request type named RTLD_DI_ORIGIN_PATH that
returns a pointer to the dynamic string token (i.e. the 'l_origin' field
in the link map) instead.  The dlinfo manual is updated with the new
request type, and the description of RTLD_DI_ORIGIN is updated to
recommend RTLD_DI_ORIGIN_PATH instead.

A test for the new request type is also added to tst-dlinfo.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agopo: Incorporate translatins (nl updated, ar new)
Andreas K. Hüttel [Mon, 26 Jan 2026 00:29:30 +0000 (01:29 +0100)] 
po: Incorporate translatins (nl updated, ar new)

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoFix ldbl-128ibm ceill, floorl, roundl and truncl zero-sign handling
Aurelien Jarno [Tue, 20 Jan 2026 17:25:08 +0000 (18:25 +0100)] 
Fix ldbl-128ibm ceill, floorl, roundl and truncl zero-sign handling

When the result of ceill, floorl, roundl and truncl is zero, the sign of
the result must match the sign of the input. For the IBM 128-bit long
double format, the sign is determined by the high part.

Ensure the correct sign when the high part is the result of
computations, by copying the sign from the input high part to the output
high part. On POWER, this conveniently maps to the fcpsgn instruction.

In addition add test for the values provided in BZ #33623, and for the
opposite value when the result is 0.

Fixes: BZ #33623
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>