]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
3 hours agoldd: define the "unused" variable master
Aurelien Jarno [Fri, 12 Sep 2025 19:18:41 +0000 (21:18 +0200)] 
ldd: define the "unused" variable

The "unused" variable could be use unitialized, which is an issue if ldd
is ran with "-u". Fix that by defining the variable to an empty value,
just like it is already done for the bind_now, warn and verbose
variables.

Reported-by: Johan Palmqvist <johan.palmqvist@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
3 hours agoi686: Compile .op files and gmon tests with -mfentry
H.J. Lu [Thu, 4 Sep 2025 23:24:14 +0000 (16:24 -0700)] 
i686: Compile .op files and gmon tests with -mfentry

On i686, after GCC 16 commit:

commit 07d8de9174c421d719649639a1452b8b9f2eee32
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jul 2 08:58:23 2025 +0800

    x86-64: Add --enable-x86-64-mfentry

which warns ‘-pg’ without ‘-mfentry’, when glibc is configured with
--disable-default-pie, GCC 16 fails to compile .op files and gmon tests
with error:

cc1: error: ‘-pg’ without ‘-mfentry’ may be unreliable with shrink wrapping [-Werror]

Compile .op files and gmon tests with -mfentry if it is supported by
CC/TEST_CC and glibc is configured with --disable-default-pie.  This
fixes BZ #33376.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Joseph Myers <josmyers@redhat.com>
13 hours agosupport: add check_mem_access function
Yury Khrustalev [Tue, 9 Sep 2025 14:15:29 +0000 (15:15 +0100)] 
support: add check_mem_access function

Add check_mem_access(addr) function to check if memory at addr can
be written or read returning false if memory is not accessible.

This function changes signal handler for SIGSEGV and SIGBUS signals
when it is called first, and it is not thread-safe.

Co-authored-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
26 hours agoi386: Use __seg_gs qualifier to cast access to TCB in THREAD_GSCOPE_RESET_FLAG()
Uros Bizjak [Wed, 10 Sep 2025 18:43:06 +0000 (20:43 +0200)] 
i386: Use __seg_gs qualifier to cast access to TCB in THREAD_GSCOPE_RESET_FLAG()

Use the __seg_gs named address space qualifier to cast access to the
gscope_flag in the TCB as a %gs: prefixed address.  This enables the
use of the "m" operand constraint, which informs the compiler about
memory access in the inline assembly.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
26 hours agox86_64: Use __seg_fs qualifier to cast access to TCB in THREAD_GSCOPE_RESET_FLAG()
Uros Bizjak [Wed, 10 Sep 2025 18:30:56 +0000 (20:30 +0200)] 
x86_64: Use __seg_fs qualifier to cast access to TCB in THREAD_GSCOPE_RESET_FLAG()

Use the __seg_fs named address space qualifier to cast access to the
gscope_flag in the TCB as a %fs: prefixed address.  This enables the
use of the "m" operand constraint, which informs the compiler about
memory access in the inline assembly.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
2 days agoFix RISC-V soft-float _FPU_SETCW for GCC 16 set-but-not-used warnings
Joseph Myers [Wed, 3 Sep 2025 16:30:11 +0000 (16:30 +0000)] 
Fix RISC-V soft-float _FPU_SETCW for GCC 16 set-but-not-used warnings

The soft-float RISC-V definition of _FPU_SETCW results in a
-Werror=unused-but-set-variable= build failure with GCC mainline (in
math/setfpucw.c) because it does not use the dummy cw variable.
Change it to (void) (cw) as on other architectures to avoid this build
failure.

Tested with build-many-glibcs.py (compilers) for
riscv64-linux-gnu-rv64imac-lp64, which previously failed.
Reviewed-by: Sam James <sam@gentoo.org>
3 days agonss: Group merge does not react to ERANGE during merge (bug 33361)
Florian Weimer [Fri, 12 Sep 2025 19:33:34 +0000 (21:33 +0200)] 
nss: Group merge does not react to ERANGE during merge (bug 33361)

The break statement in CHECK_MERGE is expected to exit the surrounding
while loop, not the do-while loop with in the macro.  Remove the
do-while loop from the macro.  It is not needed to turn the macro
expansion into a single statement due to the way CHECK_MERGE is used
(and the statement expression would cover this anyway).

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 days agoLoongArch: Use the generic shmlab.h.
caiyinyu [Fri, 3 Jan 2025 07:23:46 +0000 (15:23 +0800)] 
LoongArch: Use the generic shmlab.h.

The shmlba.h file related to the LoongArch architecture was introduced
in commit 3eed5f3a1ee to address the mismatch in the SHMLBA definition
between glibc and the kernel. See [1].  The SHMLBA definition was later
updated in commit d23b77953f5a. See [2].  Now, we adopt the definition
from the common layer.

[1]:
commit 3eed5f3a1ee356969afb403a1cf18d06f8d2d98a
Author: caiyinyu <caiyinyu@loongson.cn>
Date:   Thu May 25 17:01:11 2023 +0800

    LoongArch: Fix inconsistency in SHMLBA macro values between glibc and kernel

    The LoongArch glibc was using the value of the SHMLBA macro from common code,
    which is __getpagesize() (16k), but this was inconsistent with the value of
    the SHMLBA macro in the kernel, which is SZ_64K (64k). This caused several
    shmat-related tests in LTP (Linux Test Project) to fail. This commit fixes
    the issue by ensuring that the glibc's SHMLBA macro value matches the value
    used in the kernel like other architectures.

[2]:
commit d23b77953f5a4fbf94c05157b186aac2a247ae32
Author: Huacai Chen <chenhuacai@kernel.org>
Date:   Wed Jan 17 12:43:08 2024 +0800

    LoongArch: Change SHMLBA from SZ_64K to PAGE_SIZE

    LoongArch has hardware page coloring for L1 Cache, so we don't have
    cache aliases. But SFB (Store Fill Buffer) still has aliases. So we
    define SHMLBA to SZ_64K previously. But there are losts of applications
    use PAGE_SIZE rather than SHMLBA to mmap() file pages and shared pages.
    Of course we can fix them one by one, but not easy.

    On the other hand, we can simply disable SFB for 4KB page size to fix
    cache alias (there will be performance decrease, but acceptable), and
    in future we will fix SFB in hardware. So we can safely define SHMLBA to
    PAGE_SIZE (use the generic shmparam.h) to make life easier.

Signed-off-by: caiyinyu <caiyinyu@loongson.cn>
Reported-by: lixing <lixing@loongson.cn>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 days agoalpha: Fix missing inexact-flag raising for lround/lrint
Adhemerval Zanella [Sat, 6 Sep 2025 22:23:22 +0000 (19:23 -0300)] 
alpha: Fix missing inexact-flag raising for lround/lrint

The l*[rint|round]f implements uses alpha 'cvtst/s', 'addt/suc',
adn 'cvttq/svd' which are not not fully IEEE compliant w.r.t
inexact-flag raising..  Use the software fallback implementation
instead.

Checked on alpha-linux-gnu.

Tested-by: Michael Cree <mcree@orcon.net.nz>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 days agomath: Remove clz_uint64/ctz_uint64 and use stdbit.h
Adhemerval Zanella [Thu, 11 Sep 2025 17:13:22 +0000 (14:13 -0300)] 
math: Remove clz_uint64/ctz_uint64 and use stdbit.h

Checked on aarch64-linux-gnu and x86_64-linux-gnu
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
4 days agomath: Split erf and erfc
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:40 +0000 (13:38 -0300)] 
math: Split erf and erfc

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agomath: Use internal fesetround alias on fma
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:32 +0000 (13:38 -0300)] 
math: Use internal fesetround alias on fma

To avoid linknamespace issues on old standards.  It is required
if the fallback fma implementation is used if/when it is also
used internally for other implementation.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agomath: Use internal fetestexcept alias on fma
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:31 +0000 (13:38 -0300)] 
math: Use internal fetestexcept alias on fma

To avoid linknamespace issues on old standards.  It is required
if the fallback fma implementation is used if/when it is also
used internally for other implementation.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agomath: Add fetestexcept internal alias
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:30 +0000 (13:38 -0300)] 
math: Add fetestexcept internal alias

To avoid linknamespace issues on old standards.  It is required
if the fallback fma implementation is used if/when it is also
used internally for other implementation.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agomath: Use internal feholdexcept alias on fma
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:29 +0000 (13:38 -0300)] 
math: Use internal feholdexcept alias on fma

To avoid linknamespace issues on old standards.  It is required
if the fallback fma implementation is used if/when it is also
used internally for other implementation.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agomath: Use internal feupdateenv alias on fma
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:28 +0000 (13:38 -0300)] 
math: Use internal feupdateenv alias on fma

To avoid linknamespace issues on old standards.  It is required
if the fallback fma implementation is used if/when it is also
used internally for other implementation.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agomath: Use internal feholdexcept alias on fma
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:27 +0000 (13:38 -0300)] 
math: Use internal feholdexcept alias on fma

To avoid linknamespace issues on old standards.  It is required
if the fallback fma implementation is used if/when it is also
used internally for other implementation.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agomath: Add feclearexcept internal alias
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:26 +0000 (13:38 -0300)] 
math: Add feclearexcept internal alias

To avoid linknamespace issues on old standards.  It is required
if the fallback fma implementation is used if/when it is also
used internally for other implementation.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agobenchtests: Add workload directive for tgamma
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:25 +0000 (13:38 -0300)] 
benchtests: Add workload directive for tgamma

4 days agobenchtests: Add workload directive for erf and erfc
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:24 +0000 (13:38 -0300)] 
benchtests: Add workload directive for erf and erfc

4 days agobenchtests: Add workload for lgamma
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:23 +0000 (13:38 -0300)] 
benchtests: Add workload for lgamma

Random inputs in range [-20.00,20.00].
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agobenchtests: Add workload for asinh
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:22 +0000 (13:38 -0300)] 
benchtests: Add workload for asinh

Random input in range [-10,10].
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agobenchtests: Add workload for acosh
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:21 +0000 (13:38 -0300)] 
benchtests: Add workload for acosh

Random inputs in range [1.00,21.00]
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agoSHARED-FILES: Adjust core-math entries
Adhemerval Zanella [Mon, 25 Aug 2025 16:38:20 +0000 (13:38 -0300)] 
SHARED-FILES: Adjust core-math entries

And remove duplicate info on each file wrt glibc changes.  Also
add the core-math git repository link.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agomath: Fix x86_64 build for -Os (BZ 33367)
Adhemerval Zanella [Tue, 9 Sep 2025 20:47:21 +0000 (17:47 -0300)] 
math: Fix x86_64 build for -Os (BZ 33367)

The compiler might not inline the trunc function call for
USE_TRUNC_BUILTIN [1].

This patch adds an optimized __trunc/__truncf for x86 used
on modf ifunc variant to avoid the trunc libcall.

Checked on x86_64, x86_64-v2, x86_64-v3, and x86_64-v4. Used -O2 and
-Os options. Performed a full make check on x86_64 with both
 optimizations.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121861
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 days agomanual: fix typo
Yury Khrustalev [Thu, 11 Sep 2025 09:50:43 +0000 (10:50 +0100)] 
manual: fix typo

4 days agoUpdate to Unicode 17.0.0 [BZ #33289]
Mike FABIAN [Mon, 18 Aug 2025 07:24:06 +0000 (09:24 +0200)] 
Update to Unicode 17.0.0 [BZ #33289]

Unicode 17.0.0 Support: Character encoding, character type info, and
transliteration tables are all updated to Unicode 17.0.0, using
the generator scripts contributed by Mike FABIAN (Red Hat).

Changes in CHARMAP and WIDTH:

    Total added characters in newly generated CHARMAP: 4803
    Total removed characters in newly generated WIDTH: 0
    Total changed characters in newly generated WIDTH: 0
    Total added characters in newly generated WIDTH: 4512

Some combining characters and other non-spacing marks have been added
with WIDTH 0. Lots of characters have been added with WIDTH 2, most of
them are CJK Ideographs plus a few Tangut characters and 7 emoji.

Changes in ctype:

    alpha: Added 4672 characters in new ctype which were not in old ctype
    combining: Added 42 characters in new ctype which were not in old ctype
    combining_level3: Added 8 characters in new ctype which were not in old ctype
    graph: Added 4803 characters in new ctype which were not in old ctype
    lower: Missing: ʕ 0x295 LATIN LETTER PHARYNGEAL VOICED FRICATIVE
    lower: Added 27 characters in new ctype which were not in old ctype
    print: Added 4803 characters in new ctype which were not in old ctype
    punct: Added 131 characters in new ctype which were not in old ctype
    tolower: Added 28 characters in new ctype which were not in old ctype
    totitle: Added 28 characters in new ctype which were not in old ctype
    toupper: Added 28 characters in new ctype which were not in old ctype
    upper: Added 28 characters in new ctype which were not in old ctype

Nothing suspicious in the additions.

About the character removed from lower:

ʕ 0x295 LATIN LETTER PHARYNGEAL VOICED FRICATIVE

In UnicodeData.txt it changed from 'Ll' (Letter Lowercase) to 'Lo' (Letter Other):

-0295;LATIN LETTER PHARYNGEAL VOICED FRICATIVE;Ll;0;L;;;;;N;LATIN LETTER REVERSED GLOTTAL STOP;;;;
+0295;LATIN LETTER PHARYNGEAL VOICED FRICATIVE;Lo;0;L;;;;;N;LATIN LETTER REVERSED GLOTTAL STOP;;;;

Resolves: BZ #33289

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
5 days agoAArch64: add optimised strspn/strcspn
remph [Thu, 4 Sep 2025 12:53:56 +0000 (12:53 +0000)] 
AArch64: add optimised strspn/strcspn

Requires Neon (aka. Advanced SIMD).  Looks up 16 characters at a time,
for a 2-3x perfomance improvement, and a ~30% speedup on the strtok &
strsep benchtests, as tested on Cortex A-{53,72}.

Signed-off-by: remph <lhr@disroot.org>
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
5 days agoi386: Use __seg_gs qualifiers in {STACK, POINTER}_CHK_GUARD macros
Uros Bizjak [Tue, 9 Sep 2025 16:41:54 +0000 (18:41 +0200)] 
i386: Use __seg_gs qualifiers in {STACK, POINTER}_CHK_GUARD macros

Use the __seg_gs named address space qualifiers to cast reads of
the guard values in the TCB as %gs: prefixed addresses.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
5 days agox86_64: Use __seg_fs qualifiers in {STACK, POINTER}_CHK_GUARD macros
Uros Bizjak [Tue, 9 Sep 2025 16:41:53 +0000 (18:41 +0200)] 
x86_64: Use __seg_fs qualifiers in {STACK, POINTER}_CHK_GUARD macros

Use the __seg_fs named address space qualifiers to cast reads of
the guard values in the TCB as %fs: prefixed addresses.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
5 days agox86: Remove x86 version of thread_pointer.h
Uros Bizjak [Wed, 10 Sep 2025 06:43:54 +0000 (08:43 +0200)] 
x86: Remove x86 version of thread_pointer.h

The x86 version of thread_pointer.h is the same as the generic one.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
5 days agox86: Remove stale __GNUC_PREREQ (11, 1) test from __thread_pointer()
Uros Bizjak [Wed, 10 Sep 2025 06:43:53 +0000 (08:43 +0200)] 
x86: Remove stale __GNUC_PREREQ (11, 1) test from __thread_pointer()

GCC 12 is currently the minimum supported compiler version.
Remove no longer needed __GNUC_PREREQ (11, 1) test from
__thread_pointer().

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
5 days agomalloc: Cleanup libc_realloc
Wilco Dijkstra [Wed, 10 Sep 2025 09:11:27 +0000 (09:11 +0000)] 
malloc: Cleanup libc_realloc

Minor cleanup of libc_realloc: remove unnecessary special cases for mmap, move
ar_ptr initialization, first check for oldmem == NULL.

Reviewed-by: DJ Delorie <dj@redhat.com>
5 days agoatomics: Remove unused atomics
Wilco Dijkstra [Wed, 10 Sep 2025 09:07:39 +0000 (09:07 +0000)] 
atomics: Remove unused atomics

Remove all unused atomics.  Replace uses of catomic_increment and
catomic_decrement with atomic_fetch_add_relaxed which maps to a standard
compiler builtin. Relaxed memory ordering is correct for simple counters
since they only need atomicity.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6 days agomalloc: check "negative" tcache_key values by hand
Samuel Thibault [Tue, 9 Sep 2025 21:03:26 +0000 (23:03 +0200)] 
malloc: check "negative" tcache_key values by hand

instead of undefined cases from casting uintptr_t into intptr_t.

6 days agox86: Define atomic_compare_and_exchange_{val, bool}_acq using __atomic_compare_exchange_n
Uros Bizjak [Mon, 8 Sep 2025 12:38:23 +0000 (14:38 +0200)] 
x86: Define atomic_compare_and_exchange_{val, bool}_acq using __atomic_compare_exchange_n

No functional changes.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: Collin Funk <collin.funk1@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 days agox86: Define atomic_exchange_acq using __atomic_exchange_n
Uros Bizjak [Mon, 8 Sep 2025 12:38:22 +0000 (14:38 +0200)] 
x86: Define atomic_exchange_acq using __atomic_exchange_n

The resulting libc.so is identical on both x86_64 and
i386 targets compared to unpatched builds:

$ sha1sum libc-x86_64-old.so libc-x86_64-new.so
74eca1b87f2ecc9757a984c089a582b7615d93e7  libc-x86_64-old.so
74eca1b87f2ecc9757a984c089a582b7615d93e7  libc-x86_64-new.so
$ sha1sum libc-i386-old.so libc-i386-new.so
882bbab8324f79f4fbc85224c4c914fc6822ece7  libc-i386-old.so
882bbab8324f79f4fbc85224c4c914fc6822ece7  libc-i386-new.so

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: Collin Funk <collin.funk1@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 days agox86: Define atomic_full_barrier using __sync_synchronize
Uros Bizjak [Mon, 8 Sep 2025 12:38:21 +0000 (14:38 +0200)] 
x86: Define atomic_full_barrier using __sync_synchronize

For x86_64 targets, __sync_synchronize emits a full 64-bit
'LOCK ORQ $0x0,(%rsp)' instead of 'LOCK ORL $0x0,(%rsp)'.

No functional changes.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: Collin Funk <collin.funk1@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 days agox86: Remove catomic_* locking primitives
Uros Bizjak [Mon, 8 Sep 2025 12:38:20 +0000 (14:38 +0200)] 
x86: Remove catomic_* locking primitives

Remove obsolete catomic_* locking primitives which don't map
to standard compiler builtins.

There are still a couple of places in the tree that uses them
(malloc/arena.c and malloc/malloc.c).

x86 didn't define __arch_c_compare_and_exchange_bool_* primitives
so fallback code used __arch_c_compare_and_exchange_val_* primitives
instead.  This resulted in unoptimal code for
catomic_compare_and_exchange_bool_acq where superfluous
CMP was emitted after CMPXCHG, e.g. in arena_get2:

   775b8: 48 8d 4a 01           lea    0x1(%rdx),%rcx
   775bc: 48 89 d0              mov    %rdx,%rax
   775bf: 64 83 3c 25 18 00 00  cmpl   $0x0,%fs:0x18
   775c6: 00 00
   775c8: 74 01                 je     775cb <arena_get2+0x35b>
   775ca: f0 48 0f b1 0d 75 3d  lock cmpxchg %rcx,0x163d75(%rip)        # 1db348 <narenas>
   775d1: 16 00
   775d3: 48 39 c2              cmp    %rax,%rdx
   775d6: 74 7f                 je     77657 <arena_get2+0x3e7>

that now becomes:

   775b8: 48 8d 4a 01           lea    0x1(%rdx),%rcx
   775bc: 48 89 d0              mov    %rdx,%rax
   775bf: f0 48 0f b1 0d 80 3d  lock cmpxchg %rcx,0x163d80(%rip)        # 1db348 <narenas>
   775c6: 16 00
   775c8: 74 7f                 je     77649 <arena_get2+0x3d9>

OTOH, catomic_decrement does not fallback to atomic_fetch_add (, -1)
builtin but to the cmpxchg loop, so the generated code in arena_get2
regresses a bit, from using LOCK DECQ insn:

   77829: 64 83 3c 25 18 00 00  cmpl   $0x0,%fs:0x18
   77830: 00 00
   77832: 74 01                 je     77835 <arena_get2+0x5c5>
   77834: f0 48 ff 0d 0c 3b 16  lock decq 0x163b0c(%rip)        # 1db348 <narenas>
   7783b: 00

to a cmpxchg loop:

   7783d: 48 8b 0d 04 3b 16 00  mov    0x163b04(%rip),%rcx        # 1db348 <narenas>
   77844: 48 8d 71 ff           lea    -0x1(%rcx),%rsi
   77848: 48 89 c8              mov    %rcx,%rax
   7784b: f0 48 0f b1 35 f4 3a  lock cmpxchg %rsi,0x163af4(%rip)        # 1db348 <narenas>
   77852: 16 00
   77854: 0f 84 c9 fa ff ff     je     77323 <arena_get2+0xb3>
   7785a: eb e1                 jmp    7783d <arena_get2+0x5cd>

Defining catomic_exchange_and_add using __atomic_fetch_add solves the
above issue and generates optimal:

   77809: f0 48 83 2d 36 3b 16  lock subq $0x1,0x163b36(%rip)        # 1db348 <narenas>
   77810: 00 01

Depending on the target processor, the compiler may emit either
'LOCK ADD/SUB $1, m' or 'INC/DEC $1, m' instruction, due to partial
flag register stall issue.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: Collin Funk <collin.funk1@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 days agox86: Remove unused atomics
Uros Bizjak [Mon, 8 Sep 2025 12:38:19 +0000 (14:38 +0200)] 
x86: Remove unused atomics

Remove unused atomics from <sysdeps/x86/atomic-machine.h>.

The resulting libc.so is identical on both x86_64 and
i386 targets compared to unpatched builds:

$ sha1sum libc-x86_64-old.so libc-x86_64-new.so
b89aaa2b71efd435104ebe6f4cd0f2ef89fcac90  libc-x86_64-old.so
b89aaa2b71efd435104ebe6f4cd0f2ef89fcac90  libc-x86_64-new.so
$ sha1sum libc-i386-old.so libc-i386-new.so
aa70f2d64da2f0f516634b116014cfe7af3e5b1a  libc-i386-old.so
aa70f2d64da2f0f516634b116014cfe7af3e5b1a  libc-i386-new.so

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: Collin Funk <collin.funk1@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 days agoatomic: Switch atomic.h to builtin atomics
Wilco Dijkstra [Tue, 9 Sep 2025 10:36:45 +0000 (10:36 +0000)] 
atomic: Switch atomic.h to builtin atomics

Switch to standard builtin atomics by removing the defines for
!USE_ATOMIC_COMPILER_BUILTINS.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6 days agoatomic: Switch power to builtin atomics
Wilco Dijkstra [Tue, 9 Sep 2025 10:30:39 +0000 (10:30 +0000)] 
atomic: Switch power to builtin atomics

Switch power to builtin atomics.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6 days agoatomic: Switch hppa to builtin atomics
Wilco Dijkstra [Tue, 9 Sep 2025 10:29:55 +0000 (10:29 +0000)] 
atomic: Switch hppa to builtin atomics

Switch hppa to builtin atomics.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6 days agoatomic: Switch sh to builtin atomics
Wilco Dijkstra [Tue, 9 Sep 2025 10:29:29 +0000 (10:29 +0000)] 
atomic: Switch sh to builtin atomics

Switch sh to builtin atomics.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6 days agoatomic: Switch microblaze to builtin atomics
Wilco Dijkstra [Tue, 9 Sep 2025 10:28:29 +0000 (10:28 +0000)] 
atomic: Switch microblaze to builtin atomics

Switch microblaze to builtin atomics.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6 days agoatomic: Switch alpha to builtin atomics
Wilco Dijkstra [Tue, 9 Sep 2025 10:27:39 +0000 (10:27 +0000)] 
atomic: Switch alpha to builtin atomics

Switch alpha to builtin atomics.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6 days agoatomic: Switch m68k to builtin atomics
Wilco Dijkstra [Mon, 8 Sep 2025 17:16:03 +0000 (17:16 +0000)] 
atomic: Switch m68k to builtin atomics

Switch m68k to builtin atomics.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6 days agoatomic: Use builtin atomics with USE_ATOMIC_COMPILER_BUILTINS
Wilco Dijkstra [Mon, 8 Sep 2025 17:46:29 +0000 (17:46 +0000)] 
atomic: Use builtin atomics with USE_ATOMIC_COMPILER_BUILTINS

Use builtin atomics for atomic_compare_and_exchange_* and
atomic_exchange_and_add if USE_ATOMIC_COMPILER_BUILTINS is enabled.
This allows removing target atomic-machine.h headers.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 days agox86: Include <bits/stdlib-bsearch.h> in dl-cacheinfo.h
H.J. Lu [Tue, 9 Sep 2025 02:49:24 +0000 (19:49 -0700)] 
x86: Include <bits/stdlib-bsearch.h> in dl-cacheinfo.h

On x86-64, when glibc is configured with --enable-stack-protector=all
and compiled with -Os, ld.so crashes very early:

(gdb) r --direct
Starting program: /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/string/test-memswap --direct

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f41b0a in bsearch (__key=__key@entry=0x7fffffffda28,
    __base=__base@entry=0x7ffff7fca140 <intel_02_known>,
    __nmemb=__nmemb@entry=68, __size=__size@entry=8,
    __compar=__compar@entry=0x7ffff7f3b691 <intel_02_known_compare>)
    at ../bits/stdlib-bsearch.h:22
22 {
(gdb) disass
Dump of assembler code for function bsearch:
   0x00007ffff7f41af0 <+0>: push   %r15
   0x00007ffff7f41af2 <+2>: mov    %rcx,%r15
   0x00007ffff7f41af5 <+5>: push   %r14
   0x00007ffff7f41af7 <+7>: push   %r13
   0x00007ffff7f41af9 <+9>: mov    %rsi,%r13
   0x00007ffff7f41afc <+12>: push   %r12
   0x00007ffff7f41afe <+14>: mov    %rdi,%r12
   0x00007ffff7f41b01 <+17>: push   %rbp
   0x00007ffff7f41b02 <+18>: mov    %rdx,%rbp
   0x00007ffff7f41b05 <+21>: push   %rbx
   0x00007ffff7f41b06 <+22>: sub    $0x18,%rsp
=> 0x00007ffff7f41b0a <+26>: mov    %fs:0x28,%r14
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ We can't use stack protector at this point.
   0x00007ffff7f41b13 <+35>: mov    %r14,0x8(%rsp)
   0x00007ffff7f41b18 <+40>: mov    %r8,%r14
   0x00007ffff7f41b1b <+43>: test   %rbp,%rbp
   0x00007ffff7f41b1e <+46>: je     0x7ffff7f41b48 <bsearch+88>
   0x00007ffff7f41b20 <+48>: mov    %rbp,%rbx
   0x00007ffff7f41b23 <+51>: mov    %r12,%rdi
   0x00007ffff7f41b26 <+54>: shr    $1,%rbx
   0x00007ffff7f41b29 <+57>: imul   %r15,%rbx
   0x00007ffff7f41b2d <+61>: add    %r13,%rbx
   0x00007ffff7f41b30 <+64>: mov    %rbx,%rsi
(gdb) bt
 #0  0x00007ffff7f41b0a in bsearch (__key=__key@entry=0x7fffffffda28,
    __base=__base@entry=0x7ffff7fca140 <intel_02_known>,
    __nmemb=__nmemb@entry=68, __size=__size@entry=8,
    __compar=__compar@entry=0x7ffff7f3b691 <intel_02_known_compare>)
    at ../bits/stdlib-bsearch.h:22
 #1  0x00007ffff7f3c1be in intel_check_word (name=188, value=1979933440,
    has_level_2=has_level_2@entry=0x7fffffffda7f,
    no_level_2_or_3=no_level_2_or_3@entry=0x7fffffffda7e,
    cpu_features=<optimized out>) at ../sysdeps/x86/dl-cacheinfo.h:217
 #2  0x00007ffff7f3c29f in handle_intel (name=name@entry=188,
    cpu_features=<optimized out>) at ../sysdeps/x86/dl-cacheinfo.h:279
 #3  0x00007ffff7f3ccf9 in dl_init_cacheinfo (cpu_features=<optimized out>)
    at ../sysdeps/x86/dl-cacheinfo.h:852
 #4  init_cpu_features (cpu_features=<optimized out>)
    at ../sysdeps/x86/cpu-features.c:1153
 #5  0x00007ffff7f3d6f9 in __libc_start_main_impl (main=0x7ffff7f396dc <main>,
    argc=2, argv=0x7fffffffdbe8, init=<optimized out>, fini=<optimized out>,
    rtld_fini=0x0, stack_end=0x7fffffffdbd8) at ../csu/libc-start.c:269
 #6  0x00007ffff7f39901 in _start () at ../sysdeps/x86_64/start.S:115
(gdb)

The problem is that since __USE_EXTERN_INLINES isn't defined with -Os,
the inline bsearch in <bits/stdlib-bsearch.h> isn't available and the
external bsearch is compiled with stack protector.  Include
<bits/stdlib-bsearch.h> in dl-cacheinfo.h fixed BZ #33374.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 days agoLinux: Add missing si_code constants from Linux kernel
Thiago Jung Bauermann [Thu, 4 Sep 2025 02:26:21 +0000 (23:26 -0300)] 
Linux: Add missing si_code constants from Linux kernel

This brings the si_codes listed in siginfo-consts.h up-to-date with
Linux v6.16's include/uapi/asm-generic/siginfo.h.

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

Suggested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
7 days agoRemove futex_supports_pshared
Andreas Schwab [Thu, 12 Jan 2023 22:18:33 +0000 (23:18 +0100)] 
Remove futex_supports_pshared

Both NPTL and HTL support PTHREAD_PROCESS_SHARED, and since the removal of
the NaCL port there are no other pthread implementations.

7 days agomisc: Add support for Linux uio.h RWF_DONTCACHE flag
Xi Ruoyao [Thu, 28 Aug 2025 05:56:40 +0000 (13:56 +0800)] 
misc: Add support for Linux uio.h RWF_DONTCACHE flag

Linux 6.14 adds the new flag for uncached buffered IO on a filesystem
supporting it.

This caused two test failures as these tests expected the flag
0x00000080 is unused.  Add the flag definition to fix these tests on
Linux >= 6.14:

    FAIL: misc/tst-preadvwritev2
    FAIL: misc/tst-preadvwritev64v2

The test failures were not detected in routine test suite runs because
normally we create the test file in /tmp, where a tmpfs is usually
mounted, and tmpfs does not support this flag.  But it can be reproduced
with TMPDIR set to some directory in an ext4 file system.

Link: https://git.kernel.org/torvalds/c/af6505e5745b
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 days agoalpha: Align stack for alpha
Adhemerval Zanella [Sat, 6 Sep 2025 22:23:08 +0000 (19:23 -0300)] 
alpha: Align stack for alpha

As done already for x86_64 [1] and aarch64 [2].  It fixes
misc/tst-misalign-clone on alpha.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=27902
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=27939
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
7 days agomalloc: Fix Os build on some ABIs
Adhemerval Zanella [Sat, 6 Sep 2025 22:21:35 +0000 (19:21 -0300)] 
malloc: Fix Os build on some ABIs

I have not checked with all versions for all ABIs, but I saw failures
with gcc-14 on arm, alpha, hppa, i686, sparc, sh4, and microblaze.
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
10 days agolibio: Define AT_RENAME_* with the same tokens as Linux
Florian Weimer [Fri, 5 Sep 2025 17:02:57 +0000 (19:02 +0200)] 
libio: Define AT_RENAME_* with the same tokens as Linux

Linux uses different expressions for the RENAME_* and AT_RENAME_*
constants.  Mirror that in <stdio.h>, so that the macro redefinitions
do not result in preprocessor warnings.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
10 days agotestsuite: Update tests for 'xfclose' use
Maciej W. Rozycki [Fri, 5 Sep 2025 10:53:31 +0000 (11:53 +0100)] 
testsuite: Update tests for 'xfclose' use

Convert (some) tests to use 'xfclose' rather than using plain 'fclose'
call with no error checking or plain missing such a call.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
10 days agotestsuite: Update tests for 'xfmemopen' use
Maciej W. Rozycki [Fri, 5 Sep 2025 10:53:31 +0000 (11:53 +0100)] 
testsuite: Update tests for 'xfmemopen' use

Convert tests to use 'xfmemopen' rather than open-coding error checks
with 'fmemopen' or plain missing them, where 'fmemopen' itself is not
the scope of testing.  Leave 'fmemopen' tests alone.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
10 days agosupport: Implement 'xfmemopen' for seamless 'fmemopen' use
Maciej W. Rozycki [Fri, 5 Sep 2025 10:53:31 +0000 (11:53 +0100)] 
support: Implement 'xfmemopen' for seamless 'fmemopen' use

Add 'xfmemopen' wrapper for seamless 'fmemopen' use in tests, following
'xfopen', 'xfclose', etc., and providing a standardized error reporting
facility.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
11 days agox86_64: Unconditionally run test elf/check-dt-x86-64-plt
Arjun Shankar [Thu, 4 Sep 2025 18:30:41 +0000 (20:30 +0200)] 
x86_64: Unconditionally run test elf/check-dt-x86-64-plt

The intention of GLIBC_ABI_DT_X86_64_PLT is simply to mark the existence
of the fix in f8587a61892cbafd98ce599131bf4f103466f084
("x86-64: Ignore r_addend for R_X86_64_GLOB_DAT/R_X86_64_JUMP_SLOT").

Testing for GLIBC_ABI_DT_X86_64_PLT does not depend on the linker
supporting -z mark-plt.  Therefore remove this dependency on linker
support and test unconditionally.

Fixes commit 399384e0c8193e31aea014220ccfa24300ae5938
("x86-64: Add GLIBC_ABI_DT_X86_64_PLT [BZ #33212]")

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
12 days agoFix sysdeps/mips/dl-machine-reject-phdr.h build with GCC 16
Joseph Myers [Wed, 3 Sep 2025 16:04:49 +0000 (16:04 +0000)] 
Fix sysdeps/mips/dl-machine-reject-phdr.h build with GCC 16

Building for MIPS has been broken with GCC mainline since mid-July,
probably GCC commit 0eac9cfee8cb0b21de866a04d5d59685ab35208f "c, c++:
Extend -Wunused-but-set-* warnings [PR44677]", because the variable
perfect_match in elf_machine_reject_phdr_p is set unconditionally, but
only used if _MIPS_SIM == _ABIO32.  Mark it with __attribute__ ((unused)),
which seems cleaner in such a conditionally-used case than making all
other logic relating to this variable conditional.

Tested with build-many-glibcs.py (compilers build, which previously
failed) for mips64-linux-gnu.

13 days agoAArch64: Implement exp2m1 and exp10m1 routines
Hasaan Khan [Wed, 20 Aug 2025 11:27:23 +0000 (11:27 +0000)] 
AArch64: Implement exp2m1 and exp10m1 routines

Vector variants of the new C23 exp2m1 & exp10m1 routines.

Note: Benchmark inputs for exp2m1 & exp10m1 are identical to exp2 & exp10
respectively, this also includes the floating point variations.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agoTests: Create files with mode 0666, not 0777 (bug 33171)
Florian Weimer [Mon, 1 Sep 2025 13:05:16 +0000 (15:05 +0200)] 
Tests: Create files with mode 0666, not 0777 (bug 33171)

Mode 0777 should be used for directories only because it results
in executable entries (after typical umasks are applied).

Reviewed-by: Arjun Shankar <arjun@redhat.com>
2 weeks agonptl: Fix "Arch-sepecific" typo in comment
Jonathan Wakely [Mon, 1 Sep 2025 12:10:39 +0000 (13:10 +0100)] 
nptl: Fix "Arch-sepecific" typo in comment

2 weeks agonptl: Provide __pthread_rwlock_unlock compat symbol for versions before 2.43
Xi Ruoyao [Fri, 29 Aug 2025 03:39:36 +0000 (11:39 +0800)] 
nptl: Provide __pthread_rwlock_unlock compat symbol for versions before 2.43

The symbol was unintentionally leaked on ports introduced after
GLIBC_2.34, provide the compat symbol to avoid breaking ABI on them.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agonptl: Drop IS_IN (libpthread) around hidden_proto (__pthread_rwlock_unlock)
Xi Ruoyao [Fri, 29 Aug 2025 03:39:35 +0000 (11:39 +0800)] 
nptl: Drop IS_IN (libpthread) around hidden_proto (__pthread_rwlock_unlock)

Now libpthread is a dummy library and it no longer contains
__pthread_rwlock_unlock at all, thus IS_IN (libpthread) does not make
sense here.

It seems an left over from commit eb29dcde31e7 ("nptl: Move rwlock
functions with forwarders into libc") and it caused libc.so to export an
unversioned __pthread_rwlock_unlock on Linux ports introduced after the
2.34 release (loongarch and or1k) but the symbol is not ever supposed to
be exported on those new ports.  Only since the commit 3b2b88cceeb7
("elf: early conversion of elf p_flags to mprotect flags") the header
dependency change happened to pull in libc-lockP.h which sets
hidden_proto (__pthread_rwlock_unlock) correctly, the symbol is no
longer exported, breaking the ABI on those ports.

Remove this #if as a clean up and to prevent such a mess from happening
again.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agologin: fix ut_line comparison logic
DJ Delorie [Thu, 7 Aug 2025 21:07:53 +0000 (17:07 -0400)] 
login: fix ut_line comparison logic

ut_line[] is not a string, it's a fixed-width character field,
and may not be NUL terminated.  Thus, the use of strcmp is incorrect.
strncmp is more appropriate as it stops at the field size.

Note that differences beyond the field size do not count here,
as (1) this test doesn't do that, and (2) such differences are
traditionally ignored (i.e. logins that are silently truncated to
8 characters, etc)

While this is "only a test", we should still demonstrate the
correct way of doing things.  Also, using strncmp avoids a
"not a string" warning from gcc if you use -O1 or lower,
where it can't deduce that overflow won't happen.

Reviewed-by: Sam James <sam@gentoo.org>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agomalloc: add tst-mxfast to hugetlb exclusion list
DJ Delorie [Thu, 28 Aug 2025 21:02:15 +0000 (17:02 -0400)] 
malloc: add tst-mxfast to hugetlb exclusion list

tst-mxfast needs GLIBC_TUNABLES to be set to its own value.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agox86: Use flag output operands for inline asm in atomic-machine.h
Uros Bizjak [Fri, 29 Aug 2025 07:05:23 +0000 (09:05 +0200)] 
x86: Use flag output operands for inline asm in atomic-machine.h

Use the flag output constraints feature available in gcc 6+
("=@cc<cond>") instead of explicitly setting a boolean variable
with SETcc instruction.  This approach decouples the instruction
that sets the flags from the code that consumes them, allowing
the compiler to create better code when working with flags users.
Instead of e.g.:

   lock add %esi,(%rdi)
   sets   %sil
   test   %sil,%sil
   jne    <...>

the compiler now generates:

   lock add %esi,(%rdi)
   js     <...>

No functional changes intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agox32: Fix, optimize and cleanup RSEQ_* accessors
Uros Bizjak [Mon, 25 Aug 2025 07:50:37 +0000 (09:50 +0200)] 
x32: Fix, optimize and cleanup RSEQ_* accessors

Add missing "memory" clobber to accessors.  The "memory" clobber
tells the compiler that the assembly code performs memory reads
or writes to items other than those listed in the input and output
operands (for example, accessing the memory pointed to by one of
the input parameters).

Use MOVZBL instead of MOVB when reading 1-byte memory location
into a register.  MOVB to a register actually inserts into the LSB
of the word-sized register, making the result dependent on
the previous register value.  MOVZBL avoids this issue.

Change %P asm operand modifiers to %c.  The ‘c’ modifier is a
generic asm operand modifier that requires a constant operand and
prints the constant expression without punctuation.

Replace %b asm operand modifiers with explicit casts.  Explicit
casts inform the compiler which part of the register value is used,
allowing it to perform additional optimizations (e.g. narrowing the
preceding operation).

Remove %q asm operand modifiers.  Since the value is already cast
to 'long long int', the compiler will emit a 64-bit register name
in the assembly without needing %q.

No functional changes intended.

Tested-by: H.J. Lu <hjl.tools@gmail.com>
Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agox86/configure: Improve portability of isa level check
Henrik Lindström [Sat, 10 May 2025 09:02:05 +0000 (11:02 +0200)] 
x86/configure: Improve portability of isa level check

wc -l pads the output with leading spaces on some systems, e.g. FreeBSD.
This results in the check `test "$count" = 1` failing. Use -eq for integer
comparison instead.

Signed-off-by: Henrik Lindström <henrik@lxm.se>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
2 weeks agoelf: early conversion of elf p_flags to mprotect flags
Cupertino Miranda [Fri, 22 Aug 2025 10:37:00 +0000 (11:37 +0100)] 
elf: early conversion of elf p_flags to mprotect flags

This patch replaces _dl_stack_flags global variable by
_dl_stack_prot_flags.
The advantage is that any convertion from p_flags to final used mprotect
flags occurs at loading of p_flags. It avoids repeated spurious
convertions of _dl_stack_flags, for example in allocate_thread_stack.

This modification was suggested in:
  https://sourceware.org/pipermail/libc-alpha/2025-March/165537.html

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agomalloc: Support hugepages in mremap_chunk
Wilco Dijkstra [Wed, 27 Aug 2025 13:04:18 +0000 (13:04 +0000)] 
malloc: Support hugepages in mremap_chunk

Add mremap_chunk support for mmap()ed chunks using hugepages by accounting for
their alignment, to prevent the mremap call failing in most cases where the
size passed is not a hugepage size multiple. It also improves robustness for
reallocating hugepages since mremap is much less likely to fail, so running
out of memory when reallocating a larger size and having to copy the old
contents after mremap fails is also less likely.

To track whether an mmap()ed chunk uses hugepages, have a flag in the lowest
bit of the mchunk_prev_size field which is set after a call to sysmalloc_mmap,
and accessed later in mremap_chunk. Create macros for getting and setting this
bit, and for mapping the bit off when accessing the field for mmap()ed chunks.
Since the alignment cannot be lower than 8 bytes, this flag cannot affect the
alignment data.

Add malloc/tst-tcfree4-malloc-check to the tests-exclude-malloc-check list as
malloc-check prevents the tcache from being used to store chunks. This test
caused failures due to a bug in mem2chunk_check to be fixed in a later patch.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agomalloc: Change mmap chunk layout
Wilco Dijkstra [Fri, 8 Aug 2025 14:11:13 +0000 (14:11 +0000)] 
malloc: Change mmap chunk layout

Change the mmap chunk layout to be identical to a normal chunk.  This makes it
safe for tcache to hold mmap chunks and simplifies size calculations in
memsize and musable.  Add mmap_base() and mmap_size() macros to simplify code.

Reviewed-by: Cupertino Miranda <cupertino.miranda@oracle.com>
2 weeks agoadded benchmark inputs for rsqrtf and rsqrt
Paul Zimmermann [Tue, 29 Jul 2025 11:33:32 +0000 (13:33 +0200)] 
added benchmark inputs for rsqrtf and rsqrt

Changes with respect to v1:
- added missing rsqrt and rsqrtf in bench-math

2 weeks agoadd missing benchmark files for several C23 binary64 functions
Paul Zimmermann [Fri, 25 Jul 2025 07:08:22 +0000 (09:08 +0200)] 
add missing benchmark files for several C23 binary64 functions

These files were prepared together with Saban Houssein.

2 weeks agomanual: Refer to libc-alpha instead of a dead mailing list.
Collin Funk [Fri, 15 Aug 2025 01:13:07 +0000 (18:13 -0700)] 
manual: Refer to libc-alpha instead of a dead mailing list.

* manual/message.texi (Advanced gettext functions): Refer to
libc-alpha@sourceware.org instead of bug-glibc-manual@gnu.org which no
longer exists.
* NEWS: Likewise.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 weeks agoDon't pass -c to LIBC_TRY_TEST_CC_OPTION
H.J. Lu [Sat, 23 Aug 2025 14:04:48 +0000 (07:04 -0700)] 
Don't pass -c to LIBC_TRY_TEST_CC_OPTION

LIBC_TRY_TEST_CC_OPTION is defined with LIBC_TRY_CC_OPTION:

dnl Test a compiler option or options with an empty input file.
dnl LIBC_TRY_CC_OPTION([options], [action-if-true], [action-if-false])
AC_DEFUN([LIBC_TRY_CC_OPTION],
[AS_IF([AC_TRY_COMMAND([${CC-cc} $1 -xc /dev/null -S -o /dev/null])],
        [$2], [$3])])

which passes -S to compiler.  Unlike gcc, when -c is also passed to clang
20, we get

configure:7838: clang -c -Werror -fsemantic-interposition -xc /dev/null -S -o /dev/null
clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]

Don't pass -c to LIBC_TRY_TEST_CC_OPTION since -c isn't needed.

This fixes BZ #33318.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
3 weeks agoRemove test-have-mamx-tile from Makefile.in
H.J. Lu [Sat, 23 Aug 2025 21:12:30 +0000 (14:12 -0700)] 
Remove test-have-mamx-tile from Makefile.in

Since have-mamx-tile is for TEST_CC only as shown in
sysdeps/x86_64/configure.ac:

LIBC_CONFIG_VAR([have-mamx-tile], [$libc_cv_test_x86_have_amx_tile])

remove test-have-mamx-tile from Makefile.in.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
3 weeks agoDon't use -Wfree-labels/-Wmissing-parameter-name if unsupported
H.J. Lu [Sat, 23 Aug 2025 01:50:35 +0000 (18:50 -0700)] 
Don't use -Wfree-labels/-Wmissing-parameter-name if unsupported

Don't use -Wfree-labels/-Wmissing-parameter-name for "make check" if
they are unsupported by TEST_CC.

This fixes BZ #33310.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
3 weeks agoUndef __INT64_C/__UINT64_C for glibc build and test
H.J. Lu [Fri, 22 Aug 2025 22:31:23 +0000 (15:31 -0700)] 
Undef __INT64_C/__UINT64_C for glibc build and test

Since clang 20 defines __INT64_C and __UINT64_C as built-in macros, undef
them for glibc build and test.  This fixes BZ #33311.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 weeks agoRevert "Don't use -Wfree-labels/-Wmissing-parameter-name if unsupported"
H.J. Lu [Sat, 23 Aug 2025 01:03:46 +0000 (18:03 -0700)] 
Revert "Don't use -Wfree-labels/-Wmissing-parameter-name if unsupported"

This reverts commit ee06d98c5b9161fcaa03c562860d6ec4a8700cd2.

3 weeks agoDon't use -Wfree-labels/-Wmissing-parameter-name if unsupported
H.J. Lu [Fri, 22 Aug 2025 22:56:27 +0000 (15:56 -0700)] 
Don't use -Wfree-labels/-Wmissing-parameter-name if unsupported

Don't use -Wfree-labels/-Wmissing-parameter-name for "make check" if
they are unsupported by TEST_CC.

This fixes BZ #33310.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 weeks agox86: Set have-protected-data to no if unsupported
H.J. Lu [Fri, 22 Aug 2025 22:56:41 +0000 (15:56 -0700)] 
x86: Set have-protected-data to no if unsupported

If the building compiler enables no direct external data access by
default, access to protected data in shared libraries from executables
must be compiled with no direct external data access.  If the testing
compiler doesn't support it, set have-protected-data to no to disable
the tests which requires no direct external data access.

Add LIBC_TRY_CC_COMMAND to test a building compiler option or options
with an input file.

This fixes BZ #33286.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
3 weeks agostdio-common: Convert macros across scanf input specifier tests
Maciej W. Rozycki [Sat, 23 Aug 2025 00:02:10 +0000 (01:02 +0100)] 
stdio-common: Convert macros across scanf input specifier tests

Convert 'compare_real', 'read_real', and 'verify_input' macros to
functions so as to improve readability and avoid pitfalls.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agostdio-common: Adjust header inclusion in scanf input specifier tests
Maciej W. Rozycki [Sat, 23 Aug 2025 00:02:10 +0000 (01:02 +0100)] 
stdio-common: Adjust header inclusion in scanf input specifier tests

Move the inclusion of the data class header from the individual tests to
the data-type-specific skeleton, providing for the use of the data type
under test in the data class header and reducing duplication.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agostdio-common: Include correct skeleton in scanf input specifier tests
Maciej W. Rozycki [Sat, 23 Aug 2025 00:02:10 +0000 (01:02 +0100)] 
stdio-common: Include correct skeleton in scanf input specifier tests

Follow 'scanf' itself and use the system header inclusion variant for
the data-type-specific skeleton consistently across the remaining scanf
family functions so that any sysdeps/ variant takes precedence even in
the presence of a corresponding skeleton in stdio-common/ (though we
have no such arrangement at the moment).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agostdio-common: Fix NaN input data for scanf input specifier tests [BZ #32857]
Maciej W. Rozycki [Sat, 23 Aug 2025 00:02:10 +0000 (01:02 +0100)] 
stdio-common: Fix NaN input data for scanf input specifier tests [BZ #32857]

Update NaN input data with 'n-char-sequence' in reference data matching
data under test, removing test failures with the M68K host.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agostdio-common: Fix bad NaN crash in scanf input specifier tests [BZ #32857]
Maciej W. Rozycki [Sat, 23 Aug 2025 00:02:10 +0000 (01:02 +0100)] 
stdio-common: Fix bad NaN crash in scanf input specifier tests [BZ #32857]

Fix a null pointer dereference causing a crash in 'read_real' when the
terminating null character is written for use with the subsequent call
to 'nan' for invalid NaN reference input, such as:

%a:nan:1:3:nanny:

by moving all the 'n-char-sequence' handling under the check for the
opening parenthesis.

No test case added as it's a test case issue in the first place.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agostdio-common: Fix a crash in scanf input specifier tests [BZ #32857]
Maciej W. Rozycki [Sat, 23 Aug 2025 00:02:10 +0000 (01:02 +0100)] 
stdio-common: Fix a crash in scanf input specifier tests [BZ #32857]

Fix a null pointer dereference causing a crash in 'read_real' when the
terminating null character is written for use with the subsequent call
to 'nan' for NaN reference input using null 'n-char-sequence', such as:

%a:nan():1:5:nan():

by moving the memory allocation call ahead of the check for the closing
parenthesis.

No test case added as it's a test case issue in the first place.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agostdio-common: Fix error reporting in scanf input specifier tests
Maciej W. Rozycki [Sat, 23 Aug 2025 00:02:10 +0000 (01:02 +0100)] 
stdio-common: Fix error reporting in scanf input specifier tests

Remove buffer contents reporting from the real variant of 'verify_input'
where there has been an input data format error making the contents of
data buffers irrelevant.

For example given invalid float input data:

%a:nan:1:3:nan(:

these messages are produced:

error: ./tst-scanf-format-skeleton.c:240: input buffer: `0000c07f'
error: ./tst-scanf-format-skeleton.c:240: value buffer: `0000c07f'
error: ./tst-scanf-format-skeleton.c:242: input line 1: input data format error

with the two former lines irrelevant.  Remove them from output then,
only leaving:

error: ./tst-scanf-format-skeleton.c:242: input line 1: input data format error

No test case added as it's a test case issue in the first place.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agostdio-common: Reject insufficient character data in scanf [BZ #12701]
Maciej W. Rozycki [Sat, 23 Aug 2025 00:02:10 +0000 (01:02 +0100)] 
stdio-common: Reject insufficient character data in scanf [BZ #12701]

Reject invalid formatted scanf character data with the 'c' conversion
where there is not enough input available to satisfy the field width
requested.  It is required by ISO C that this conversion matches a
sequence of characters of exactly the number specified by the field
width and it is also already documented as such in our own manual:

"It reads precisely the next N characters, and fails if it cannot get
that many."

Currently a matching success is instead incorrectly produced where the
EOF condition is encountered before the required number of characters
has been retrieved, and the characters actually obtained are stored in
the buffer provided.

Add test cases accordingly and remove placeholders from 'c' conversion
input data for the existing scanf tests.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoDisable -Wimplicit-fallthrough when clang is in use
H.J. Lu [Fri, 22 Aug 2025 22:55:24 +0000 (15:55 -0700)] 
Disable -Wimplicit-fallthrough when clang is in use

Clang's -Wimplicit-fallthrough warning, which flags unannotated
fall-through in switch statements, does not recognize specific comments
like /* FALLTHROUGH */ for suppressing the warning, unlike GCC.  Since
fall through comments are used extensively in glibc, disable
-Wimplicit-fallthrough when clang is in use.

This fixes BZ #33312.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 weeks agolibio: Properly link in libio functions in static binaries
H.J. Lu [Thu, 21 Aug 2025 23:57:22 +0000 (16:57 -0700)] 
libio: Properly link in libio functions in static binaries

commit 3020f72618e4f1d7338cd42b8bc7b2813e961b5a
Author: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Date:   Tue Dec 27 18:11:43 2022 -0300

    libio: Remove the usage of __libc_IO_vtables

added

 #define libio_static_fn_required(name) __asm (".globl " #name);

to link in libio functions in static binaries.  But there is no relocation
in
.globl _IO_file_open

and "strip --strip-unneeded" will remove such unreferenced symbols which
breaks static binaries.  Redefine libio_static_fn_required to create a
reference to the required function with

static __typeof (name) *const name##_p __attribute__((used)) = name;

This fixes BZ #33300.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Tested-by: Xi Ruoyao <xry111@xry111.site>
3 weeks agox86_64: Use __seg_fs qualifiers in NPTL accessors
Uros Bizjak [Fri, 22 Aug 2025 05:33:13 +0000 (07:33 +0200)] 
x86_64: Use __seg_fs qualifiers in NPTL accessors

Use __seg_fs named address space qualifiers to cast NPTL accessors
to %fs: prefixed addresses.  Use volatile access only where
strictly necessary.

Use existing assembly RSEQ_* accessors for x32 to
work around the GCC bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121613

because negative value in __rseq_offset is used
as an offset from %fs.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
3 weeks agox86: Remove an extra space before THREAD_SELF
H.J. Lu [Fri, 22 Aug 2025 02:29:58 +0000 (19:29 -0700)] 
x86: Remove an extra space before THREAD_SELF

After

f6dd43d5f7 i386: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()
b0f0c41a5f x86_64: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()

removed the unnecessary __GNUC_PREREQ (6, 0) test, remove the extra space
before THREAD_SELF macro name.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agox86_64: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()
Uros Bizjak [Sun, 17 Aug 2025 15:49:54 +0000 (17:49 +0200)] 
x86_64: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()

Currenty GCC-12 is required as the minimum supported compiler
version.  Remove stalled __GNUC_PREREQ (6, 0) test for
GCC compiler version in THREAD_SELF() macro definition.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agoi386: Use __seg_gs qualifiers in NPTL accessors
Uros Bizjak [Sun, 17 Aug 2025 15:50:47 +0000 (17:50 +0200)] 
i386: Use __seg_gs qualifiers in NPTL accessors

Use __seg_gs named address space qualifiers to cast NPTL accessors
to %gs: prefixed addresses.  Use volatile access only where
strictly necessary.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agoi386: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()
Uros Bizjak [Sun, 17 Aug 2025 15:50:46 +0000 (17:50 +0200)] 
i386: Remove stalled __GNUC_PREREQ (6, 0) test in THREAD_SELF()

Currenty GCC-12 is required as the minimum supported compiler
version.  Remove stalled __GNUC_PREREQ (6, 0) test for
GCC compiler version in THREAD_SELF() macro definition.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agoi386: Use TESTB instead of TESTL in ____longjmp_chk()
Uros Bizjak [Mon, 18 Aug 2025 09:19:47 +0000 (11:19 +0200)] 
i386: Use TESTB instead of TESTL in ____longjmp_chk()

There is no need to use TESTL when checking the least-significant bit
with a TEST instruction. Use TESTB, which is three bytes shorter:

   f6 44 24 04 01          testb  $0x1,0x4(%esp)

vs:

   f7 44 24 04 01 00 00    testl  $0x1,0x4(%esp)
   00

for the same effect.

No functional changes intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agox86_64: Use TESTB instead of TESTL in CHECK_INVALID_LONGJMP
Uros Bizjak [Mon, 18 Aug 2025 09:18:55 +0000 (11:18 +0200)] 
x86_64: Use TESTB instead of TESTL in CHECK_INVALID_LONGJMP

There is no need to use TESTL when checking the least-significant bit
with a TEST instruction. Use TESTB, which is three bytes shorter:

   f6 44 24 f0 01          testb  $0x1,-0x10(%rsp)

vs:

   f7 44 24 f0 01 00 00    testl  $0x1,-0x10(%rsp)
   00

for the same effect.

No functional changes intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>