platform/upstream/glibc.git
8 months agonptl: Rename tst-execstack to tst-execstack-threads
Florian Weimer [Mon, 20 Nov 2023 08:22:21 +0000 (09:22 +0100)]
nptl: Rename tst-execstack to tst-execstack-threads

So that the test is harder to confuse with elf/tst-execstack
(although the tests are supposed to be the same).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agoRemove untyped mach RPC code.
Flavio Cruz [Sun, 19 Nov 2023 05:08:47 +0000 (00:08 -0500)]
Remove untyped mach RPC code.

Existing MiG does not support untyped messages and the Hurd will
continue to use typed messages for the foreseeable future.
Message-ID: <ZVmYX6j4pYNUfqn4@jupiter.tail36e24.ts.net>

8 months ago_hurd_intr_rpc_mach_msg: handle message iteration correctly.
Flavio Cruz [Sat, 18 Nov 2023 23:18:44 +0000 (18:18 -0500)]
_hurd_intr_rpc_mach_msg: handle message iteration correctly.

The `ty` pointer is only set at the end of the loop so that
`msgtl_header.msgt_inline` and `msgtl_header.msgt_deallocate` remain
valid. Also, when deallocating memory, we use the length from the
message directly rather than hard coding mach_port_t since we want to
deallocate any kind of OOL data.
Message-ID: <ZVlGVD6eEN-dXsOr@jupiter.tail36e24.ts.net>

8 months agolocaledata: Convert oc_FR locale to UTF-8
Mike FABIAN [Thu, 16 Nov 2023 14:53:06 +0000 (15:53 +0100)]
localedata: Convert oc_FR locale to UTF-8

8 months agolocaledata: Add information for Occitan
Mike FABIAN [Thu, 16 Nov 2023 14:45:50 +0000 (15:45 +0100)]
localedata: Add information for Occitan

Resolves: BZ # 28787

8 months agoelf: Fix force_first handling in dlclose (bug 30981)
Florian Weimer [Thu, 16 Nov 2023 18:55:35 +0000 (19:55 +0100)]
elf: Fix force_first handling in dlclose (bug 30981)

The force_first parameter was ineffective because the dlclose'd
object was not necessarily the first in the maps array.  Also
enable force_first handling unconditionally, regardless of namespace.
The initial object in a namespace should be destructed first, too.

The _dl_sort_maps_dfs function had early returns for relocation
dependency processing which broke force_first handling, too, and
this is fixed in this change as well.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agoelf: Handle non-directory name in search path (BZ 31035)
Adhemerval Zanella [Fri, 10 Nov 2023 13:43:12 +0000 (10:43 -0300)]
elf: Handle non-directory name in search path (BZ 31035)

The open_path stops if a relative path in search path contains a
component that is a non directory (for instance, if the component
is an existing file).

For instance:

  $ cat > lib.c <<EOF
  > void foo (void) {}
  > EOF
  $ gcc -shared -fPIC -o lib.so lib.c
  $ cat > main.c <<EOF
  extern void foo ();
  int main () { foo (); return 0; }
  EOF
  $ gcc -o main main.c lib.so
  $ LD_LIBRARY_PATH=. ./main
  $ LD_LIBRARY_PATH=non-existing/path:. ./main
  $ LD_LIBRARY_PATH=$(pwd)/main:. ./main
  $ LD_LIBRARY_PATH=./main:. ./main
  ./main: error while loading shared libraries: lib.so: cannot open shared object file: No such file or directory

The invalid './main' should be ignored as a non-existent one,
instead as a valid but non accessible file.

Absolute paths do not trigger this issue because their status are
initialized as 'unknown' and open_path check if this is a directory.

Checked on x86_64-linux-gnu.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
8 months agoNew Zealand locales (en_NZ & mi_NZ) first day of week should be Monday
Mike FABIAN [Wed, 15 Nov 2023 15:28:01 +0000 (16:28 +0100)]
New Zealand locales (en_NZ & mi_NZ) first day of week should be Monday

Resolves: BZ #29486

8 months agox86: Fix unchecked AVX512-VBMI2 usage in strrchr-evex-base.S
Noah Goldstein [Wed, 1 Nov 2023 21:42:07 +0000 (16:42 -0500)]
x86: Fix unchecked AVX512-VBMI2 usage in strrchr-evex-base.S

strrchr-evex-base used `vpcompress{b|d}` in the page cross logic but
was missing the CPU_FEATURE checks for VBMI2 in the
ifunc/ifunc-impl-list.

The fix is either to add those checks or change the logic to not use
`vpcompress{b|d}`. Choosing the latter here so that the strrchr-evex
implementation is usable on SKX.

New implementation is a bit slower, but this is in a cold path so its
probably okay.

8 months agoposix: Check pidfd_spawn with tst-spawn7-pid
Adhemerval Zanella [Wed, 15 Nov 2023 13:28:34 +0000 (10:28 -0300)]
posix: Check pidfd_spawn with tst-spawn7-pid

Without using the macro, posix_spawn is used instead.

Checked on x86_64-linux-gnu.

8 months agosparc: Fix broken memset for sparc32 [BZ #31068]
Andreas Larsson [Wed, 15 Nov 2023 12:29:43 +0000 (13:29 +0100)]
sparc: Fix broken memset for sparc32 [BZ #31068]

Fixes commit a61933fe27df ("sparc: Remove bzero optimization") that
after moving code jumped to the wrong label 4.

Verfied by successfully running string/test-memset on sparc32.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Ludwig Rydberg <ludwig.rydberg@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agoy2038: Fix support for 64-bit time on legacy ABIs
Gaël PORTAY [Sat, 11 Nov 2023 17:32:36 +0000 (18:32 +0100)]
y2038: Fix support for 64-bit time on legacy ABIs

This fixes a typo.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agohurd: Fix spawni returning allocation errors.
Samuel Thibault [Tue, 14 Nov 2023 22:55:35 +0000 (23:55 +0100)]
hurd: Fix spawni returning allocation errors.

8 months agohurd: Make _hurd_intr_rpc_mach_msg avoid returning MACH_SEND_INTERRUPTED
Samuel Thibault [Tue, 14 Nov 2023 01:03:35 +0000 (02:03 +0100)]
hurd: Make _hurd_intr_rpc_mach_msg avoid returning MACH_SEND_INTERRUPTED

When the given options do not include MACH_SEND_INTERRUPT,
_hurd_intr_rpc_mach_msg (aka mach_msg) is not supposed to return
MACH_SEND_INTERRUPTED.  In such a case we thus have to retry sending the
message.

This was observed to fix various occurrences of spurious
"(ipc/send) interrupted" errors when running haskell programs.

8 months agoAArch64: Remove Falkor memcpy
Wilco Dijkstra [Thu, 26 Oct 2023 16:30:36 +0000 (17:30 +0100)]
AArch64: Remove Falkor memcpy

The latest implementations of memcpy are actually faster than the Falkor
implementations [1], so remove the falkor/phecda ifuncs for memcpy and
the now unused IS_FALKOR/IS_PHECDA defines.

[1] https://sourceware.org/pipermail/libc-alpha/2022-December/144227.html

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agoAArch64: Add memset_zva64
Wilco Dijkstra [Thu, 26 Oct 2023 16:07:21 +0000 (17:07 +0100)]
AArch64: Add memset_zva64

Add a specialized memset for the common ZVA size of 64 to avoid the
overhead of reading the ZVA size.  Since the code is identical to
__memset_falkor, remove the latter.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agoAArch64: Cleanup emag memset
Wilco Dijkstra [Thu, 26 Oct 2023 15:34:47 +0000 (16:34 +0100)]
AArch64: Cleanup emag memset

Cleanup emag memset - merge the memset_base64.S file, remove
the unused ZVA code (since it is disabled on emag).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agotest: Run the tst-tls-allocation-failure-static-patched with test-wrapper.
Yanzhang Wang [Thu, 26 Oct 2023 03:26:10 +0000 (11:26 +0800)]
test: Run the tst-tls-allocation-failure-static-patched with test-wrapper.

If we use cross test with ssh, this test needs to be ran on the remote.

8 months agoaarch64: Add vector implementations of log1p routines
Joe Ramsay [Fri, 3 Nov 2023 12:12:23 +0000 (12:12 +0000)]
aarch64: Add vector implementations of log1p routines

May discard sign of zero.

8 months agoaarch64: Add vector implementations of atan2 routines
Joe Ramsay [Fri, 3 Nov 2023 12:12:22 +0000 (12:12 +0000)]
aarch64: Add vector implementations of atan2 routines

8 months agoaarch64: Add vector implementations of atan routines
Joe Ramsay [Fri, 3 Nov 2023 12:12:21 +0000 (12:12 +0000)]
aarch64: Add vector implementations of atan routines

8 months agoaarch64: Add vector implementations of acos routines
Joe Ramsay [Fri, 3 Nov 2023 12:12:20 +0000 (12:12 +0000)]
aarch64: Add vector implementations of acos routines

8 months agoaarch64: Add vector implementations of asin routines
Joe Ramsay [Fri, 3 Nov 2023 12:12:19 +0000 (12:12 +0000)]
aarch64: Add vector implementations of asin routines

8 months agoFix type typo in “String/Array Conventions” doc
Paul Eggert [Thu, 9 Nov 2023 02:19:08 +0000 (18:19 -0800)]
Fix type typo in “String/Array Conventions” doc

* manual/string.texi (String/Array Conventions):
Fix typo reported by Alejandro Colomar <alx@kernel.org> in:
https://sourceware.org/pipermail/libc-alpha/2023-November/152646.html

8 months agostdlib: Avoid element self-comparisons in qsort
Florian Weimer [Wed, 8 Nov 2023 14:18:02 +0000 (15:18 +0100)]
stdlib: Avoid element self-comparisons in qsort

This improves compatibility with applications which assume that qsort
does not invoke the comparison function with equal pointer arguments.

The newly introduced branches should be predictable, as leading to a
call to the comparison function.  If the prediction fails, we avoid
calling the function.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 months agoelf: Add glibc.mem.decorate_maps tunable
Adhemerval Zanella [Wed, 1 Nov 2023 12:56:11 +0000 (09:56 -0300)]
elf: Add glibc.mem.decorate_maps tunable

The PR_SET_VMA_ANON_NAME support is only enabled through a configurable
kernel switch, mainly because assigning a name to a
anonymous virtual memory area might prevent that area from being
merged with adjacent virtual memory areas.

For instance, with the following code:

   void *p1 = mmap (NULL,
                    1024 * 4096,
                    PROT_READ | PROT_WRITE,
                    MAP_PRIVATE | MAP_ANONYMOUS,
                    -1,
                    0);

   void *p2 = mmap (p1 + (1024 * 4096),
                    1024 * 4096,
                    PROT_READ | PROT_WRITE,
                    MAP_PRIVATE | MAP_ANONYMOUS,
                    -1,
                    0);

The kernel will potentially merge both mappings resulting in only one
segment of size 0x800000.  If the segment is names with
PR_SET_VMA_ANON_NAME with different names, it results in two mappings.

Although this will unlikely be an issue for pthread stacks and malloc
arenas (since for pthread stacks the guard page will result in
a PROT_NONE segment, similar to the alignment requirement for the arena
block), it still might prevent the mmap memory allocated for detail
malloc.

There is also another potential scalability issue, where the prctl
requires
to take the mmap global lock which is still not fully fixed in Linux
[1] (for pthread stacks and arenas, it is mitigated by the stack
cached and the arena reuse).

So this patch disables anonymous mapping annotations as default and
add a new tunable, glibc.mem.decorate_maps, can be used to enable
it.

[1] https://lwn.net/Articles/906852/

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
8 months agolinux: Decorate __libc_fatal error buffer
Adhemerval Zanella [Wed, 1 Nov 2023 12:56:10 +0000 (09:56 -0300)]
linux: Decorate __libc_fatal error buffer

Reviewed-by: DJ Delorie <dj@redhat.com>
8 months agoassert: Decorate error message buffer
Adhemerval Zanella [Wed, 1 Nov 2023 12:56:09 +0000 (09:56 -0300)]
assert: Decorate error message buffer

Reviewed-by: DJ Delorie <dj@redhat.com>
8 months agomalloc: Decorate malloc maps
Adhemerval Zanella [Wed, 1 Nov 2023 12:56:08 +0000 (09:56 -0300)]
malloc: Decorate malloc maps

Add anonymous mmap annotations on loader malloc, malloc when it
allocates memory with mmap, and on malloc arena.  The /proc/self/maps
will now print:

   [anon: glibc: malloc arena]
   [anon: glibc: malloc]
   [anon: glibc: loader malloc]

On arena allocation, glibc annotates only the read/write mapping.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
8 months agonptl: Decorate thread stack on pthread_create
Adhemerval Zanella [Wed, 1 Nov 2023 12:56:07 +0000 (09:56 -0300)]
nptl: Decorate thread stack on pthread_create

Linux 4.5 removed thread stack annotations due to the complexity of
computing them [1], and Linux added PR_SET_VMA_ANON_NAME on 5.17
as a way to name anonymous virtual memory areas.

This patch adds decoration on the stack created and used by
pthread_create, for glibc crated thread stack the /proc/self/maps will
now show:

  [anon: glibc: pthread stack: <tid>]

And for user-provided stacks:

  [anon: glibc: pthread user stack: <tid>]

The guard page is not decorated, and the mapping name is cleared when
the thread finishes its execution (so the cached stack does not have any
name associated).

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

[1] https://github.com/torvalds/linux/commit/65376df582174ffcec9e6471bf5b0dd79ba05e4a

Co-authored-by: Ian Rogers <irogers@google.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
8 months agosupport: Add support_set_vma_name
Adhemerval Zanella [Wed, 1 Nov 2023 12:56:06 +0000 (09:56 -0300)]
support: Add support_set_vma_name

Check if kernel supports prctl (PR_SET_VMA, PR_SET_VMA_ANON_NAME, ...).
Reviewed-by: DJ Delorie <dj@redhat.com>
8 months agolinux: Add PR_SET_VMA_ANON_NAME support
Adhemerval Zanella [Wed, 1 Nov 2023 12:56:05 +0000 (09:56 -0300)]
linux: Add PR_SET_VMA_ANON_NAME support

Linux 5.17 added support to naming anonymous virtual memory areas
through the prctl syscall.  The __set_vma_name is a wrapper to avoid
optimizing the prctl call if the kernel does not support it.

If the kernel does not support PR_SET_VMA_ANON_NAME, prctl returns
EINVAL. And it also returns the same error for an invalid argument.
Since it is an internal-only API, it assumes well-formatted input:
aligned START, with (START, START+LEN) being a valid memory range,
and NAME with a limit of 80 characters without an invalid one
("\\`$[]").
Reviewed-by: DJ Delorie <dj@redhat.com>
8 months agohurd: statfsconv: Add missing f_ffree conversion
Samuel Thibault [Tue, 7 Nov 2023 11:51:25 +0000 (12:51 +0100)]
hurd: statfsconv: Add missing f_ffree conversion

9 months agoUpdate BAD_TYPECHECK to work on x86_64
Flavio Cruz [Mon, 6 Nov 2023 04:13:32 +0000 (23:13 -0500)]
Update BAD_TYPECHECK to work on x86_64

Message-ID: <ZUhn7LOcgLOJjKZr@jupiter.tail36e24.ts.net>

9 months agosysdeps: sem_open: Clear O_CREAT when semaphore file is expected to exist [BZ #30789]
Sergio Durigan Junior [Wed, 1 Nov 2023 22:15:23 +0000 (18:15 -0400)]
sysdeps: sem_open: Clear O_CREAT when semaphore file is expected to exist [BZ #30789]

When invoking sem_open with O_CREAT as one of its flags, we'll end up
in the second part of sem_open's "if ((oflag & O_CREAT) == 0 || (oflag
& O_EXCL) == 0)", which means that we don't expect the semaphore file
to exist.

In that part, open_flags is initialized as "O_RDWR | O_CREAT | O_EXCL
| O_CLOEXEC" and there's an attempt to open(2) the file, which will
likely fail because it won't exist.  After that first (expected)
failure, some cleanup is done and we go back to the label "try_again",
which lives in the first part of the aforementioned "if".

The problem is that, in that part of the code, we expect the semaphore
file to exist, and as such O_CREAT (this time the flag we pass to
open(2)) needs to be cleaned from open_flags, otherwise we'll see
another failure (this time unexpected) when trying to open the file,
which will lead the call to sem_open to fail as well.

This can cause very strange bugs, especially with OpenMPI, which makes
extensive use of semaphores.

Fix the bug by simplifying the logic when choosing open(2) flags and
making sure O_CREAT is not set when the semaphore file is expected to
exist.

A regression test for this issue would require a complex and cpu time
consuming logic, since to trigger the wrong code path is not
straightforward due the racy condition.  There is a somewhat reliable
reproducer in the bug, but it requires using OpenMPI.

This resolves BZ #30789.

See also: https://bugs.launchpad.net/ubuntu/+source/h5py/+bug/2031912

Signed-off-by: Sergio Durigan Junior <sergiodj@sergiodj.net>
Co-Authored-By: Simon Chopin <simon.chopin@canonical.com>
Co-Authored-By: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Fixes: 533deafbdf189f5fbb280c28562dd43ace2f4b0f ("Use O_CLOEXEC in more places (BZ #15722)")

9 months agoAdd SEGV_CPERR from Linux 6.6 to bits/siginfo-consts.h
Joseph Myers [Fri, 3 Nov 2023 16:36:35 +0000 (16:36 +0000)]
Add SEGV_CPERR from Linux 6.6 to bits/siginfo-consts.h

Linux 6.6 adds the constant SEGV_CPERR.  Add it to glibc's
bits/siginfo-consts.h.

Tested for x86_64.

9 months agolinux: Sync Linux 6.6 elf.h
Adhemerval Zanella [Tue, 31 Oct 2023 16:32:38 +0000 (13:32 -0300)]
linux: Sync Linux 6.6 elf.h

It adds NT_X86_SHSTK (2fab02b25ae7cf5), NT_RISCV_CSR/NT_RISCV_VECTOR
(9300f00439743c4), and NT_LOONGARCH_HW_BREAK/NT_LOONGARCH_HW_WATCH
(1a69f7a161a78ae).

9 months agolinux: Add HWCAP2_HBC from Linux 6.6 to AArch64 bits/hwcap.h
Adhemerval Zanella [Tue, 31 Oct 2023 16:32:37 +0000 (13:32 -0300)]
linux: Add HWCAP2_HBC from Linux 6.6 to AArch64 bits/hwcap.h

9 months agolinux: Add FSCONFIG_CMD_CREATE_EXCL from Linux 6.6 to sys/mount.h
Adhemerval Zanella [Tue, 31 Oct 2023 16:32:36 +0000 (13:32 -0300)]
linux: Add FSCONFIG_CMD_CREATE_EXCL from Linux 6.6 to sys/mount.h

The tst-mount-consts.py does not need to be updated because kernel
exports it as an enum (compare_macro_consts can not parse it).

9 months agolinux: Add MMAP_ABOVE4G from Linux 6.6 to sys/mman.h
Adhemerval Zanella [Tue, 31 Oct 2023 16:32:35 +0000 (13:32 -0300)]
linux: Add MMAP_ABOVE4G from Linux 6.6 to sys/mman.h

x86 added the flag (29f890d1050fc099f) for CET enabled.

Also update tst-mman-consts.py test.

9 months agoUpdate kernel version to 6.6 in header constant tests
Adhemerval Zanella [Tue, 31 Oct 2023 16:32:34 +0000 (13:32 -0300)]
Update kernel version to 6.6 in header constant tests

There are no new constants covered, the tst-mman-consts.py is
updated separately along with a header constant addition.

9 months agoUpdate syscall lists for Linux 6.6
Adhemerval Zanella [Tue, 31 Oct 2023 16:32:33 +0000 (13:32 -0300)]
Update syscall lists for Linux 6.6

Linux 6.6 has one new syscall for all architectures, fchmodat2, and
the map_shadow_stack on x86_64.

9 months agoFormat test results closer to what DejaGnu does
Maxim Kuvyrkov [Fri, 19 May 2023 08:28:21 +0000 (08:28 +0000)]
Format test results closer to what DejaGnu does

The years of dealing with Binutils, GCC and GDB test results
made the community create good tools for comparison and analysis
of DejaGnu test results.  This change allows to use those tools
for Glibc's test results as well.

The motivation for this change is Linaro's pre-commit testers,
which use a modified version of GCC's validate_failures.py
to create test xfail lists with baseline failures and known
flaky tests.  See below links for an example xfails file (only
one link is supposed to work at any given time):
- https://ci.linaro.org/job/tcwg_glibc_check--master-arm-build/lastSuccessfulBuild/artifact/artifacts/artifacts.precommit/sumfiles/xfails.xfail/*view*/
- https://ci.linaro.org/job/tcwg_glibc_check--master-arm-build/lastSuccessfulBuild/artifact/artifacts/sumfiles/xfails.xfail/*view*/

Specifacally, this patch changes format of glibc's .sum files from ...
<cut>
FAIL: elf/test1
PASS: string/test2
</cut>
... to ...
<cut>
             === glibc tests ===

Running elf ...
FAIL: elf/test1

Running string ...
PASS: string/test2
</cut>.

And output of "make check" from ...
<cut>
FAIL: elf/test1
</cut>
... to ...
<cut>
FAIL: elf/test1
=== Summary of results ===
      1 FAIL
      1 PASS
</cut>.

Signed-off-by: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoAArch64: Cleanup ifuncs
Wilco Dijkstra [Tue, 24 Oct 2023 12:51:07 +0000 (13:51 +0100)]
AArch64: Cleanup ifuncs

Cleanup ifuncs.  Remove uses of libc_hidden_builtin_def, use ENTRY rather than
ENTRY_ALIGN, remove unnecessary defines and conditional compilation.  Rename
strlen_mte to strlen_generic.  Remove rtld-memset.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
9 months agoUse correct subdir when building tst-rfc3484* for mach and arm
Arjun Shankar [Tue, 31 Oct 2023 09:44:32 +0000 (10:44 +0100)]
Use correct subdir when building tst-rfc3484* for mach and arm

Commit 7f602256ab5b85db1dbfb5f40bd109c4b37b68c8 moved the tst-rfc3484*
tests from posix/ to nss/, but didn't correct references to point to
their new subdir when building for mach and arm.  This commit fixes
that.

Tested with build-many-glibcs.sh for i686-gnu.

9 months agostdlib: Add more qsort{_r} coverage
Adhemerval Zanella [Tue, 3 Oct 2023 12:22:51 +0000 (09:22 -0300)]
stdlib: Add more qsort{_r} coverage

This patch adds a qsort and qsort_r to trigger the worst case
scenario for the quicksort (which glibc current lacks coverage).
The test is done with random input, dfferent internal types (uint8_t,
uint16_t, uint32_t, uint64_t, large size), and with
different set of element numbers.

Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
9 months agostdlib: Remove use of mergesort on qsort (BZ 21719)
Adhemerval Zanella [Tue, 3 Oct 2023 12:22:50 +0000 (09:22 -0300)]
stdlib: Remove use of mergesort on qsort (BZ 21719)

This patch removes the mergesort optimization on qsort implementation
and uses the introsort instead.  The mergesort implementation has some
issues:

  - It is as-safe only for certain types sizes (if total size is less
    than 1 KB with large element sizes also forcing memory allocation)
    which contradicts the function documentation.  Although not required
    by the C standard, it is preferable and doable to have an O(1) space
    implementation.

  - The malloc for certain element size and element number adds
    arbitrary latency (might even be worse if malloc is interposed).

  - To avoid trigger swap from memory allocation the implementation
    relies on system information that might be virtualized (for instance
    VMs with overcommit memory) which might lead to potentially use of
    swap even if system advertise more memory than actually has.  The
    check also have the downside of issuing syscalls where none is
    expected (although only once per execution).

  - The mergesort is suboptimal on an already sorted array (BZ#21719).

The introsort implementation is already optimized to use constant extra
space (due to the limit of total number of elements from maximum VM
size) and thus can be used to avoid the malloc usage issues.

Resulting performance is slower due the usage of qsort, specially in the
worst-case scenario (partialy or sorted arrays) and due the fact
mergesort uses a slight improved swap operations.

This change also renders the BZ#21719 fix unrequired (since it is meant
to fix the sorted input performance degradation for mergesort).  The
manual is also updated to indicate the function is now async-cancel
safe.

Checked on x86_64-linux-gnu.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
9 months agostdlib: Implement introsort for qsort (BZ 19305)
Adhemerval Zanella [Tue, 3 Oct 2023 12:22:49 +0000 (09:22 -0300)]
stdlib: Implement introsort for qsort (BZ 19305)

This patch makes the quicksort implementation to acts as introsort, to
avoid worse-case performance (and thus making it O(nlog n)).  It switch
to heapsort when the depth level reaches 2*log2(total elements).  The
heapsort is a textbook implementation.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
9 months agostdlib: qsort: Move some macros to inline function
Adhemerval Zanella [Tue, 3 Oct 2023 12:22:48 +0000 (09:22 -0300)]
stdlib: qsort: Move some macros to inline function

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
9 months agostdlib: Move insertion sort out qsort
Adhemerval Zanella [Tue, 3 Oct 2023 12:22:47 +0000 (09:22 -0300)]
stdlib: Move insertion sort out qsort

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
9 months agostdlib: Optimization qsort{_r} swap implementation
Adhemerval Zanella [Tue, 3 Oct 2023 12:22:46 +0000 (09:22 -0300)]
stdlib: Optimization qsort{_r} swap implementation

The optimization takes in consideration both the most common elements
are either 32 or 64 bit in size and inputs are aligned to the word
boundary.  This is similar to what msort does.

For large buffer the swap operation uses memcpy/mempcpy with a
small fixed size buffer (so compiler might inline the operations).

Checked on x86_64-linux-gnu.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
9 months agostring: Add internal memswap implementation
Adhemerval Zanella [Tue, 3 Oct 2023 12:22:45 +0000 (09:22 -0300)]
string: Add internal memswap implementation

The prototype is:

  void __memswap (void *restrict p1, void *restrict p2, size_t n)

The function swaps the content of two memory blocks P1 and P2 of
len N.  Memory overlap is NOT handled.

It will be used on qsort optimization.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
9 months agocrypt: Remove manul entry for --enable-crypt
Adhemerval Zanella [Tue, 31 Oct 2023 13:59:04 +0000 (10:59 -0300)]
crypt: Remove manul entry for --enable-crypt

9 months agoUse Linux 6.6 in build-many-glibcs.py
Joseph Myers [Tue, 31 Oct 2023 13:36:51 +0000 (13:36 +0000)]
Use Linux 6.6 in build-many-glibcs.py

This patch makes build-many-glibcs.py use Linux 6.6.

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

9 months agocrypt: Remove libcrypt support
Adhemerval Zanella [Mon, 2 Oct 2023 12:11:49 +0000 (09:11 -0300)]
crypt: Remove libcrypt support

All the crypt related functions, cryptographic algorithms, and
make requirements are removed,  with only the exception of md5
implementation which is moved to locale folder since it is
required by localedef for integrity protection (libc's
locale-reading code does not check these, but localedef does
generate them).

Besides thec code itself, both internal documentation and the
manual is also adjusted.  This allows to remove both --enable-crypt
and --enable-nss-crypt configure options.

Checked with a build for all affected ABIs.

Co-authored-by: Zack Weinberg <zack@owlfolio.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
9 months agosparc: Remove optimize md5, sha256, and sha512
Adhemerval Zanella [Mon, 2 Oct 2023 12:11:48 +0000 (09:11 -0300)]
sparc: Remove optimize md5, sha256, and sha512

The libcrypt was maked to be phase out on 2.38, and a better project
already exist that provide both compatibility and better API
(libxcrypt).  The sparc optimizations add the burden to extra
build-many-glibcs.py configurations.

Checked on sparc64 and sparcv9.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
9 months agobuild-many-glibcs: Fix traililing whitespace
Adhemerval Zanella [Mon, 30 Oct 2023 16:03:28 +0000 (13:03 -0300)]
build-many-glibcs: Fix traililing whitespace

From commit d846c2838942297c9644f2f38bdad0fb88f42245.

9 months agoLoongArch: Delete excessively allocated memory.
caiyinyu [Thu, 26 Oct 2023 09:27:21 +0000 (17:27 +0800)]
LoongArch: Delete excessively allocated memory.

9 months agoLoongArch: Update hwcap.h to sync with LoongArch kernel.
caiyinyu [Mon, 23 Oct 2023 07:53:38 +0000 (15:53 +0800)]
LoongArch: Update hwcap.h to sync with LoongArch kernel.

9 months agoLoongArch: Unify Register Names.
caiyinyu [Fri, 20 Oct 2023 01:20:02 +0000 (09:20 +0800)]
LoongArch: Unify Register Names.

9 months agoAArch64: Add support for MOPS memcpy/memmove/memset
Wilco Dijkstra [Tue, 17 Oct 2023 15:54:21 +0000 (16:54 +0100)]
AArch64: Add support for MOPS memcpy/memmove/memset

Add support for MOPS in cpu_features and INIT_ARCH.  Add ifuncs using MOPS for
memcpy, memmove and memset (use .inst for now so it works with all binutils
versions without needing complex configure and conditional compilation).

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
9 months agoMove getnameinfo from 'inet' to 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:28 +0000 (14:55 +0200)]
Move getnameinfo from 'inet' to 'nss'

getnameinfo is an entry points for nss functionality.  This commit moves
it from the 'inet' subdirectory to 'nss'.  The corresponding Versions
entry is also moved from 'posix' into 'nss'.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoMove getaddrinfo from 'posix' into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:27 +0000 (14:55 +0200)]
Move getaddrinfo from 'posix' into 'nss'

getaddrinfo is an entry point for nss functionality.  This commit moves
it from 'sysdeps/posix' to 'nss', gets rid of the stub in 'posix', and
moves all associated tests as well.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoMove 'services' routines from 'inet' into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:26 +0000 (14:55 +0200)]
Move 'services' routines from 'inet' into 'nss'

The getservby* and getservent* routines are entry points for nss
functionality.  This commit moves them from the 'inet' subdirectory to
'nss'.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoMove 'rpc' routines from 'inet' into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:25 +0000 (14:55 +0200)]
Move 'rpc' routines from 'inet' into 'nss'

The getrpcby* and getrpcent* routines are entry points for nss
functionality.  This commit moves them from the 'inet' subdirectory to
'nss'.  The Versions entries for these routines along with a test,
located in the 'sunrpc' subdirectory, are also moved into 'nss'.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoMove 'protocols' routines from 'inet' into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:24 +0000 (14:55 +0200)]
Move 'protocols' routines from 'inet' into 'nss'

The getprotoby* and getprotoent* routines are entry points for nss
functionality.  This commit moves them from the 'inet' subdirectory to
'nss'.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoMove 'networks' routines from 'inet' into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:23 +0000 (14:55 +0200)]
Move 'networks' routines from 'inet' into 'nss'

The getnetby* and getnetent* routines are entry points for nss
functionality.  This commit moves them from the 'inet' subdirectory to
'nss'.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoMove 'netgroup' routines from 'inet' into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:22 +0000 (14:55 +0200)]
Move 'netgroup' routines from 'inet' into 'nss'

These netgroup routines are entry points for nss functionality.
This commit moves them along with netgroup.h from the 'inet'
subdirectory to 'nss', and adjusts any references accordingly.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoMove 'hosts' routines from 'inet' into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:21 +0000 (14:55 +0200)]
Move 'hosts' routines from 'inet' into 'nss'

The gethostby* and gethostent* routines are entry points for nss
functionality.  This commit moves them from the 'inet' subdirectory to
'nss'.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoMove 'ethers' routines from 'inet' into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:20 +0000 (14:55 +0200)]
Move 'ethers' routines from 'inet' into 'nss'

ether_hostton and ether_ntohost are entry points for nss functionality.
This commit moves them from the 'inet' subdirectory to 'nss', and
adjusts any references accordingly.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoMove 'aliases' routines from 'inet' into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:19 +0000 (14:55 +0200)]
Move 'aliases' routines from 'inet' into 'nss'

The aliases routines are entry points for nss functionality.  This
commit moves aliases.h and the aliases routines from the 'inet'
subdirectory to 'nss', and adjusts any external references.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoRemove 'shadow' and merge into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:18 +0000 (14:55 +0200)]
Remove 'shadow' and merge into 'nss'

The majority of shadow routines are entry points for nss functionality.
This commit removes the 'shadow' subdirectory and moves all
functionality and tests to 'nss'.  References to shadow/ are accordingly
changed.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoRemove 'pwd' and merge into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:17 +0000 (14:55 +0200)]
Remove 'pwd' and merge into 'nss'

The majority of pwd routines are entry points for nss functionality.
This commit removes the 'pwd' subdirectory and moves all functionality
and tests to 'nss'.  References to pwd/ are accordingly changed.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoRemove 'gshadow' and merge into 'nss'
Arjun Shankar [Mon, 2 Oct 2023 12:55:16 +0000 (14:55 +0200)]
Remove 'gshadow' and merge into 'nss'

The majority of gshadow routines are entry points for nss functionality.
This commit removes the 'gshadow' subdirectory and moves all
functionality and tests to 'nss'.  References to gshadow/ are
accordingly changed.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoRemove 'grp' and merge into 'nss' and 'posix'
Arjun Shankar [Mon, 2 Oct 2023 12:55:15 +0000 (14:55 +0200)]
Remove 'grp' and merge into 'nss' and 'posix'

The majority of grp routines are entry points for nss functionality.
This commit removes the 'grp' subdirectory and moves all nss-relevant
functionality and all tests to 'nss', and the 'setgroups' stub into
'posix' (alongside the 'getgroups' stub).  References to grp/ are
accordingly changed.  In addition, compat-initgroups.c, a fallback
implementation of initgroups is renamed to initgroups-fallback.c so that
the build system does not confuse it for nss_compat/compat-initgroups.c.

Build time improves very slightly; e.g. down from an average of 45.5s to
44.5s on an 8-thread mobile x86_64 CPU.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agomalloc: Fix tst-tcfree3 build csky-linux-gnuabiv2 with fortify source
Adhemerval Zanella [Mon, 23 Oct 2023 16:33:47 +0000 (13:33 -0300)]
malloc: Fix tst-tcfree3 build csky-linux-gnuabiv2 with fortify source

With gcc 13.1 with --enable-fortify-source=2, tst-tcfree3 fails to
build on csky-linux-gnuabiv2 with:

../string/bits/string_fortified.h: In function ‘do_test’:
../string/bits/string_fortified.h:26:8: error: inlining failed in call
to ‘always_inline’ ‘memcpy’: target specific option mismatch
   26 | __NTH (memcpy (void *__restrict __dest, const void *__restrict
      __src,
      |        ^~~~~~
../misc/sys/cdefs.h:81:62: note: in definition of macro ‘__NTH’
   81 | #  define __NTH(fct)    __attribute__ ((__nothrow__ __LEAF)) fct
      |                                                              ^~~
tst-tcfree3.c:45:3: note: called from here
   45 |   memcpy (c, a, 32);
      |   ^~~~~~~~~~~~~~~~~

Instead of relying on -O0 to avoid malloc/free to be optimized away,
disable the builtin.

Reviewed-by: DJ Delorie <dj@redhat.com>
9 months agotest-container: disable ld.so system cache on DSO detection
Simon Chopin [Thu, 5 Oct 2023 12:54:31 +0000 (14:54 +0200)]
test-container: disable ld.so system cache on DSO detection

When building the testroot, the script runs the newly built ld.so on a
couple of binaries in order to copy over any additional libraries
needed. However, if the dependencies are found in the system cache, it
will be copied over using that path.

This is problematic if the system ld.so and the one built don't have the
exact same search configuration. We encountered this in Ubuntu, where we
build a variant of libc with -fno-omit-frame-pointer for accurate
performance profiling.

This variant is built using a non-standard slibdir to be able to be
co-installed with the default library (e.g. slibdir = /lib/libc6-prof).
Since we have /lib pointing to /usr/lib, any additional dependency
should still be reachable via /usr. However, resolving via the cache
might result in the additional DSOs being copied into $testroot/lib, out
of the search path in the container.

The problem has been triggered by 1d5024f4f052c12e404d42d3b5bfe9c3e9fd27c4
("support: Build with exceptions and asynchronous unwind tables [BZ #30587]")
which introduced a dependency on libgcc_s.so.1 under some circumstances.

Downstream bug: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/2031495
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agoaarch64: Add vector implementations of exp10 routines
Joe Ramsay [Thu, 5 Oct 2023 16:10:52 +0000 (17:10 +0100)]
aarch64: Add vector implementations of exp10 routines

Double-precision routines either reuse the exp table (AdvSIMD) or use
SVE FEXPA intruction.

9 months agoaarch64: Add vector implementations of log10 routines
Joe Ramsay [Thu, 5 Oct 2023 16:10:51 +0000 (17:10 +0100)]
aarch64: Add vector implementations of log10 routines

A table is also added, which is shared between AdvSIMD and SVE log10.

9 months agoaarch64: Add vector implementations of log2 routines
Joe Ramsay [Thu, 5 Oct 2023 16:10:50 +0000 (17:10 +0100)]
aarch64: Add vector implementations of log2 routines

A table is also added, which is shared between AdvSIMD and SVE log2.

9 months agoaarch64: Add vector implementations of exp2 routines
Joe Ramsay [Thu, 5 Oct 2023 16:10:49 +0000 (17:10 +0100)]
aarch64: Add vector implementations of exp2 routines

Some routines reuse table from v_exp_data.c

9 months agoaarch64: Add vector implementations of tan routines
Joe Ramsay [Thu, 5 Oct 2023 16:10:48 +0000 (17:10 +0100)]
aarch64: Add vector implementations of tan routines

This includes some utility headers for evaluating polynomials using
various schemes.

9 months agoelf: ldconfig should skip temporary files created by package managers
Florian Weimer [Fri, 20 Oct 2023 12:29:50 +0000 (14:29 +0200)]
elf: ldconfig should skip temporary files created by package managers

This avoids crashes due to partially written files, after a package
update is interrupted.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agotst-spawn-cgroup.c: Fix argument order of UNSUPPORTED message.
Stefan Liebler [Thu, 19 Oct 2023 12:35:59 +0000 (14:35 +0200)]
tst-spawn-cgroup.c: Fix argument order of UNSUPPORTED message.

The arguments for "expected" and "got" are mismatched.  Furthermore
this patch is dumping both values as hex.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
9 months agoAdd NT_PPC_DEXCR and NT_PPC_HASHKEYR from Linux 6.5 to elf.h
Joseph Myers [Thu, 19 Oct 2023 15:12:09 +0000 (15:12 +0000)]
Add NT_PPC_DEXCR and NT_PPC_HASHKEYR from Linux 6.5 to elf.h

Linux 6.5 adds constants NT_PPC_DEXCR and NT_PPC_HASHKEYR.  Add these
to glibc's elf.h.

Tested for x86_64.

9 months agos390: Fix undefined behaviour in feenableexcept, fedisableexcept [BZ #30960]
Stefan Liebler [Wed, 18 Oct 2023 13:08:40 +0000 (15:08 +0200)]
s390: Fix undefined behaviour in feenableexcept, fedisableexcept [BZ #30960]

If feenableexcept or fedisableexcept gets excepts=FE_INVALID=0x80
as input, we have a signed left shift: 0x80 << 24 which is not
representable as int and thus is undefined behaviour according to
C standard.

This patch casts excepts as unsigned int before shifting, which is
defined.

For me, the observed undefined behaviour is that the shift is done
with "unsigned"-instructions, which is exactly what we want.
Furthermore, I don't get any exception-flags.

After the fix, the code is using the same instruction sequence as
before.

9 months agoelf: Do not print the cache entry if --inhibit-cache is used
Adhemerval Zanella [Tue, 17 Oct 2023 14:50:35 +0000 (11:50 -0300)]
elf: Do not print the cache entry if --inhibit-cache is used

So --help informs the correct shared library search path.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
9 months agoRevert "elf: Always call destructors in reverse constructor order (bug 30785)"
Florian Weimer [Wed, 18 Oct 2023 09:30:38 +0000 (11:30 +0200)]
Revert "elf: Always call destructors in reverse constructor order (bug 30785)"

This reverts commit 6985865bc3ad5b23147ee73466583dd7fdf65892.

Reason for revert:

The commit changes the order of ELF destructor calls too much relative
to what applications expect or can handle.  In particular, during
process exit and _dl_fini, after the revert commit, we no longer call
the destructors of the main program first; that only happens after
some dlopen'ed objects have been destructed.  This robs applications
of an opportunity to influence destructor order by calling dlclose
explicitly from the main program's ELF destructors.  A couple of
different approaches involving reverse constructor order were tried,
and none of them worked really well.  It seems we need to keep the
dependency sorting in _dl_fini.

There is also an ambiguity regarding nested dlopen calls from ELF
constructors: Should those destructors run before or after the object
that called dlopen?  Commit 6985865bc3ad5b2314 used reverse order
of the start of ELF constructor calls for destructors, but arguably
using completion of constructors is more correct.  However, that alone
is not sufficient to address application compatibility issues (it
does not change _dl_fini ordering at all).

9 months agoRevert "elf: Fix compile error with -DNDEBUG [BZ #18755]"
Florian Weimer [Wed, 18 Oct 2023 09:30:38 +0000 (11:30 +0200)]
Revert "elf: Fix compile error with -DNDEBUG [BZ #18755]"

This reverts commit 964d15a007d7fb1258f2ad7c8cf4afcfb9a65719.

Reason for revert: Conflicts with revert of commit 6985865bc3ad5b23147.

9 months agoAdd strlcat/wcslcat testcase.
Sunil K Pandey [Thu, 27 Jul 2023 23:20:49 +0000 (16:20 -0700)]
Add strlcat/wcslcat testcase.

This patch implements comprehensive tests for strlcat/wcslcat
functions.  Tests are mostly derived from strncat test suites
and modified to incorporate strlcat/wcslcat specifications.

Reviewed-by: DJ Delorie <dj@redhat.com>
9 months agoAdd strlcpy/wcslcpy testcase
Sunil K Pandey [Thu, 27 Jul 2023 23:20:37 +0000 (16:20 -0700)]
Add strlcpy/wcslcpy testcase

This patch implements comprehensive tests for strlcpy/wcslcpy
functions.  Tests are mostly derived from strncpy test suites
and modified to incorporate strlcpy/wcslcpy specifications.

Reviewed-by: DJ Delorie <dj@redhat.com>
9 months agoAdd LE DSCP code point from RFC-8622.
Bruno Victal [Tue, 17 Oct 2023 17:00:27 +0000 (19:00 +0200)]
Add LE DSCP code point from RFC-8622.

Signed-off-by: Bruno Victal <mirai@makinata.eu>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
9 months agoAdd HWCAP2_MOPS from Linux 6.5 to AArch64 bits/hwcap.h
Joseph Myers [Tue, 17 Oct 2023 13:13:27 +0000 (13:13 +0000)]
Add HWCAP2_MOPS from Linux 6.5 to AArch64 bits/hwcap.h

Linux 6.5 adds a new AArch64 HWCAP2 value, HWCAP2_MOPS.  Add it to
glibc's bits/hwcap.h.

Tested with build-many-glibcs.py for aarch64-linux-gnu.

9 months agoAdd SCM_SECURITY, SCM_PIDFD to bits/socket.h
Joseph Myers [Mon, 16 Oct 2023 13:19:26 +0000 (13:19 +0000)]
Add SCM_SECURITY, SCM_PIDFD to bits/socket.h

Linux 6.5 adds a constant SCM_PIDFD (recall that the non-uapi
linux/socket.h, where this constant is added, is in fact a header
providing many constants that are part of the kernel/userspace
interface).  This shows up that SCM_SECURITY, from the same set of
definitions and added in Linux 2.6.17, is also missing from glibc,
although glibc has the first two constants from this set, SCM_RIGHTS
and SCM_CREDENTIALS; add both missing constants to glibc.

Tested for x86_64.

9 months agoAdd AT_HANDLE_FID from Linux 6.5 to bits/fcntl-linux.h
Joseph Myers [Mon, 16 Oct 2023 13:18:51 +0000 (13:18 +0000)]
Add AT_HANDLE_FID from Linux 6.5 to bits/fcntl-linux.h

Linux 6.5 adds a constant AT_HANDLE_FID; add it to glibc.  Because
this is a flag for the function name_to_handle_at declared in
bits/fcntl-linux.h, put the flag there rather than alongside other
AT_* flags in (OS-independent) fcntl.h.

Tested for x86_64.

9 months agoAvoid maybe-uninitialized warning in __kernel_rem_pio2
Andreas Schwab [Sun, 8 Oct 2023 16:23:30 +0000 (18:23 +0200)]
Avoid maybe-uninitialized warning in __kernel_rem_pio2

With GCC 14 on 32-bit x86 the compiler emits a maybe-uninitialized
warning:

../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function '__kernel_rem_pio2':
../sysdeps/ieee754/dbl-64/k_rem_pio2.c:364:20: error: 'fq' may be used uninitialized [-Werror=maybe-uninitialized]
  364 |           y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
      |                  ~~^~~

This is similar to the warning that is suppressed in the other branch of
the switch.  Help the compiler knowing that the variable is always
initialized, which also makes the suppression obsolete.

9 months agoFix WAIT_FOR_DEBUGGER for container tests.
Stefan Liebler [Thu, 28 Sep 2023 10:50:40 +0000 (12:50 +0200)]
Fix WAIT_FOR_DEBUGGER for container tests.

For container tests, gdb needs to set the sysroot to the corresponding
testroot.root directory.  The assumption was that PIDs < 3 means that
we are running within a container.

Starting with commit 2fe64148a81f0d78050c302f34a6853d21f7cae4
"Allow for unpriviledged nested containers", the default is to use
the PID namespace of the parent.  Thus support_test_main.c does not
recognize our container anymore.

This patch now assumes that we are running inside a container if
test-container.c has set PID_OUTSIDE_CONTAINER and always uses this
PID independent of having a new PID namespace or not.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 months agostdlib: fix grouping verification with multi-byte thousands separator (bug 30964)
Andreas Schwab [Wed, 11 Oct 2023 14:22:16 +0000 (16:22 +0200)]
stdlib: fix grouping verification with multi-byte thousands separator (bug 30964)

The grouping verification only worked for a single-byte thousands
separator.  With a multi-byte separator it returned as if no separators
were present.  The actual parsing in str_to_mpn will then go wrong when
there are multiple adjacent multi-byte separators in the number.

9 months agobuild-many-glibcs: Check for required system tools
DJ Delorie [Thu, 21 Sep 2023 21:24:05 +0000 (17:24 -0400)]
build-many-glibcs: Check for required system tools

Notes for future devs:

* Add tools as you find they're needed, with version 0,0
* Bump version when you find an old tool that doesn't work
* Don't add a version just because you know it works

Co-authored-by: Lukasz Majewski <lukma@denx.de>
Co-authored-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
10 months agox86: Prepare `strrchr-evex` and `strrchr-evex512` for AVX10
Noah Goldstein [Thu, 21 Sep 2023 14:38:37 +0000 (09:38 -0500)]
x86: Prepare `strrchr-evex` and `strrchr-evex512` for AVX10

This commit refactors `strrchr-evex` and `strrchr-evex512` to use a
common implementation: `strrchr-evex-base.S`.

The motivation is `strrchr-evex` needed to be refactored to not use
64-bit masked registers in preperation for AVX10.

Once vec-width masked register combining was removed, the EVEX and
EVEX512 implementations can easily be implemented in the same file
without any major overhead.

The net result is performance improvements (measured on TGL) for both
`strrchr-evex` and `strrchr-evex512`. Although, note there are some
regressions in the test suite and it may be many of the cases that
make the total-geomean of improvement/regression across bench-strrchr
are cold. The point of the performance measurement is to show there
are no major regressions, but the primary motivation is preperation
for AVX10.

Benchmarks where taken on TGL:
https://www.intel.com/content/www/us/en/products/sku/213799/intel-core-i711850h-processor-24m-cache-up-to-4-80-ghz/specifications.html

EVEX geometric_mean(N=5) of all benchmarks New / Original   : 0.74
EVEX512 geometric_mean(N=5) of all benchmarks New / Original: 0.87

Full check passes on x86.