platform/upstream/glibc.git
20 months agostring: Hook up the default implementation on test-memchr
Adhemerval Zanella [Tue, 17 Jan 2023 13:14:03 +0000 (10:14 -0300)]
string: Hook up the default implementation on test-memchr

And remove SIMPLE_MEMCHR, which is not used anywhere.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agostring: Hook up the default implementation on test-strcpy
Adhemerval Zanella [Tue, 31 Jan 2023 19:29:58 +0000 (16:29 -0300)]
string: Hook up the default implementation on test-strcpy

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agostring: Hook up the default implementation on test-stpcpy
Adhemerval Zanella [Tue, 31 Jan 2023 19:29:53 +0000 (16:29 -0300)]
string: Hook up the default implementation on test-stpcpy

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agostring: Hook up the default implementation on test-strncmp
Adhemerval Zanella [Fri, 20 Jan 2023 20:50:41 +0000 (17:50 -0300)]
string: Hook up the default implementation on test-strncmp

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agostring: Hook up the default implementation on test-strcmp
Adhemerval Zanella [Tue, 17 Jan 2023 13:13:35 +0000 (10:13 -0300)]
string: Hook up the default implementation on test-strcmp

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agostring: Hook up the default implementation on test-strchr
Adhemerval Zanella [Tue, 17 Jan 2023 13:12:40 +0000 (10:12 -0300)]
string: Hook up the default implementation on test-strchr

Also remove the simple_STRCHR, which can be easily replaced.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agostring: Hook up the default implementation on test-strnlen
Adhemerval Zanella [Tue, 17 Jan 2023 13:11:36 +0000 (10:11 -0300)]
string: Hook up the default implementation on test-strnlen

Also remove the SIMPLE_STRNLEN, which is not used anywhere.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agostring: Hook up the default implementation on test-strlen
Adhemerval Zanella [Tue, 17 Jan 2023 13:10:21 +0000 (10:10 -0300)]
string: Hook up the default implementation on test-strlen

Also remove the simple_STRLEN and builtin_strlen, which are not used
anywhere.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agoriscv: Add string-fza.h and string-fzi.h
Adhemerval Zanella [Wed, 1 Feb 2023 15:44:17 +0000 (12:44 -0300)]
riscv: Add string-fza.h and string-fzi.h

It uses the bitmanip extension to optimize index_fist and index_last
with clz/ctz (using generic implementation that routes to compiler
builtin) and orc.b to check null bytes.

Checked the string test on riscv64 user mode.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agosh: Add string-fzb.h
Adhemerval Zanella [Tue, 10 Jan 2023 21:01:06 +0000 (18:01 -0300)]
sh: Add string-fzb.h

Use the SH cmp/str on has_{zero,eq,zero_eq}.

Checked on sh4-linux-gnu.

20 months agopowerpc: Add string-fza.h
Richard Henderson [Tue, 10 Jan 2023 21:01:05 +0000 (18:01 -0300)]
powerpc: Add string-fza.h

While ppc has the more important string functions in assembly,
there are still a few generic routines used.

Use the Power 6 CMPB insn for testing of zeros.

Checked on powerpc64le-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
20 months agoarm: Add string-fza.h
Richard Henderson [Tue, 10 Jan 2023 21:01:04 +0000 (18:01 -0300)]
arm: Add string-fza.h

While arm has the more important string functions in assembly,
there are still a few generic routines used.

Use the UQSUB8 insn for testing of zeros.

Checked on armv7-linux-gnueabihf

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
20 months agoalpha: Add string-fza, string-fzb.h, string-fzi.h, and string-shift.h
Richard Henderson [Tue, 10 Jan 2023 21:01:03 +0000 (18:01 -0300)]
alpha: Add string-fza, string-fzb.h, string-fzi.h, and string-shift.h

While alpha has the more important string functions in assembly,
there are still a few for find the generic routines are used.

Use the CMPBGE insn, via the builtin, for testing of zeros.  Use a
simplified expansion of __builtin_ctz when the insn isn't available.

Checked on alpha-linux-gnu.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
20 months agohppa: Add string-fza.h, string-fzc.h, and string-fzi.h
Richard Henderson [Tue, 10 Jan 2023 21:01:02 +0000 (18:01 -0300)]
hppa: Add string-fza.h, string-fzc.h, and string-fzi.h

Use UXOR,SBZ to test for a zero byte within a word.  While we can
get semi-decent code out of asm-goto, we would do slightly better
with a compiler builtin.

For index_zero et al, sequential testing of bytes is less expensive than
any tricks that involve a count-leading-zeros insn that we don't have.

Checked on hppa-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
20 months agohppa: Add memcopy.h
Richard Henderson [Tue, 10 Jan 2023 21:01:01 +0000 (18:01 -0300)]
hppa: Add memcopy.h

GCC's combine pass cannot merge (x >> c | y << (32 - c)) into a
double-word shift unless (1) the subtract is in the same basic block
and (2) the result of the subtract is used exactly once.  Neither
condition is true for any use of MERGE.

By forcing the use of a double-word shift, we not only reduce
contention on SAR, but also allow the setting of SAR to be hoisted
outside of a loop.

Checked on hppa-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
20 months agostring: Improve generic strrchr with memrchr and strlen
Adhemerval Zanella [Thu, 2 Feb 2023 16:44:13 +0000 (13:44 -0300)]
string: Improve generic strrchr with memrchr and strlen

Now that both strlen and memrchr have word vectorized implementation,
it should be faster to implement strrchr based on memrchr over the
string length instead of calling strchr on a loop.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powerpc64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

20 months agostring: Improve generic memrchr
Adhemerval Zanella [Tue, 10 Jan 2023 21:01:00 +0000 (18:01 -0300)]
string: Improve generic memrchr

New algorithm read the lastaligned address and mask off the unwanted
bytes.  The loop now read word-aligned address and check using the
has_eq macro.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powerpc64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agostring: Improve generic strnlen with memchr
Adhemerval Zanella [Tue, 10 Jan 2023 21:00:55 +0000 (18:00 -0300)]
string: Improve generic strnlen with memchr

It also cleanups the multiple inclusion by leaving the ifunc
implementation to undef the weak_alias and libc_hidden_def.

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agostring: Improve generic memchr
Adhemerval Zanella [Tue, 10 Jan 2023 21:00:59 +0000 (18:00 -0300)]
string: Improve generic memchr

New algorithm read the first aligned address and mask off the
unwanted bytes (this strategy is similar to arch-specific
implementations used on powerpc, sparc, and sh).

The loop now read word-aligned address and check using the has_eq
macro.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powerpc64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agostring: Improve generic strcpy
Adhemerval Zanella [Tue, 31 Jan 2023 19:28:42 +0000 (16:28 -0300)]
string: Improve generic strcpy

Now that stpcpy is vectorized based on op_t, it should be better to
call it instead of strlen plus memcpy.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agostring: Improve generic stpcpy
Adhemerval Zanella [Tue, 31 Jan 2023 18:46:08 +0000 (15:46 -0300)]
string: Improve generic stpcpy

It follows the strategy:

  - Align the destination on word boundary using byte operations.

  - If source is also word aligned, read a word per time, check for
    null (using has_zero from string-fzb.h), and write the remaining
    bytes.

  - If source is not word aligned, loop by aligning the source, and
    merging the result of two reads.  Similar to aligned case,
    check for null with has_zero, and write the remaining bytes if
    null is found.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agostring: Improve generic strncmp
Adhemerval Zanella [Fri, 20 Jan 2023 19:18:33 +0000 (16:18 -0300)]
string: Improve generic strncmp

It follows the strategy:

   - Align the first input to word boundary using byte operations.

   - If second input is also word aligned, read a word per time, check
     for  null (using has_zero), and check final words using byte
     operation.

   - If second input is not word aligned, loop by aligning the source,
     and merge the result of two reads.  Similar to aligned case, check
     for null with has_zero, and check final words using byte operation.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agostring: Improve generic strcmp
Adhemerval Zanella [Tue, 10 Jan 2023 21:00:58 +0000 (18:00 -0300)]
string: Improve generic strcmp

It follows the strategy:

  - Align the first input to word boundary using byte operations.

  - If second input is also word aligned, read a word per time, check for
    null (using has_zero), and check final words using byte operation.

  - If second input is not word aligned, loop by aligning the source, and
    merging the result of two reads.  Similar to aligned case, check for
    null with has_zero, and check final words using byte operation.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agostring: Improve generic strchr
Adhemerval Zanella [Tue, 10 Jan 2023 21:00:56 +0000 (18:00 -0300)]
string: Improve generic strchr

New algorithm now calls strchrnul.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powerpc64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agostring: Improve generic strchrnul
Adhemerval Zanella [Tue, 10 Jan 2023 21:00:57 +0000 (18:00 -0300)]
string: Improve generic strchrnul

New algorithm read the first aligned address and mask off the unwanted
bytes (this strategy is similar to arch-specific  implementations used
on powerpc, sparc, and sh).

The loop now read word-aligned address and check using the has_zero_eq
function.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agostring: Improve generic strlen
Adhemerval Zanella [Tue, 10 Jan 2023 21:00:54 +0000 (18:00 -0300)]
string: Improve generic strlen

New algorithm read the first aligned address and mask off the
unwanted bytes (this strategy is similar to arch-specific
implementations used on powerpc, sparc, and sh).

The loop now read word-aligned address and check using the has_zero
macro.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
and powercp64-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agoAdd string vectorized find and detection functions
Adhemerval Zanella [Tue, 10 Jan 2023 21:00:53 +0000 (18:00 -0300)]
Add string vectorized find and detection functions

This patch adds generic string find and detection meant to be used in
generic vectorized string implementation.  The idea is to decompose the
basic string operation so each architecture can reimplement if it
provides any specialized hardware instruction.

The 'string-misc.h' provides miscellaneous functions:

  - extractbyte: extracts the byte from an specific index.
  - repeat_bytes: setup an word by replicate the argument on each byte.

The 'string-fza.h' provides zero byte detection functions:

  - find_zero_low, find_zero_all, find_eq_low, find_eq_all,
    find_zero_eq_low, find_zero_eq_all, and find_zero_ne_all

The 'string-fzb.h' provides boolean zero byte detection functions:

  - has_zero: determine if any byte within a word is zero.
  - has_eq: determine byte equality between two words.
  - has_zero_eq: determine if any byte within a word is zero along with
    byte equality between two words.

The 'string-fzi.h' provides positions for string-fza.h results:

  - index_first: return index of first zero byte within a word.
  - index_last: return index of first byte different between two words.

The 'string-fzc.h' provides a combined version of fza and fzi:

  - index_first_zero_eq: return index of first zero byte within a word or
    first byte different between two words.
  - index_first_zero_ne: return index of first zero byte within a word or
    first byte equal between two words.
  - index_last_zero: return index of last zero byte within a word.
  - index_last_eq: return index of last byte different between two words.

The 'string-shift.h' provides a way to mask off parts of a work based on
some alignmnet (to handle unaligned arguments):

  - shift_find, shift_find_last.

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
20 months agoParameterize OP_T_THRES from memcopy.h
Richard Henderson [Tue, 10 Jan 2023 21:00:51 +0000 (18:00 -0300)]
Parameterize OP_T_THRES from memcopy.h

It moves OP_T_THRES out of memcopy.h to its own header and adjust
each architecture that redefines it.

Checked with a build and check with run-built-tests=no for all major
Linux ABIs.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agoParameterize op_t from memcopy.h
Adhemerval Zanella [Tue, 10 Jan 2023 21:00:50 +0000 (18:00 -0300)]
Parameterize op_t from memcopy.h

It moves the op_t definition out to an specific header, adds
the attribute 'may-alias', and cleanup its duplicated definitions.

Checked with a build and check with run-built-tests=no for all major
Linux ABIs.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20 months agoReplace rawmemchr (s, '\0') with strchr
Wilco Dijkstra [Fri, 3 Feb 2023 12:01:33 +0000 (12:01 +0000)]
Replace rawmemchr (s, '\0') with strchr

Almost all uses of rawmemchr find the end of a string.  Since most targets use
a generic implementation, replacing it with strchr is better since that is
optimized by compilers into strlen (s) + s.  Also fix the generic rawmemchr
implementation to use a cast to unsigned char in the if statement.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
20 months agoAArch64: Improve SVE memcpy and memmove
Wilco Dijkstra [Wed, 1 Feb 2023 18:45:19 +0000 (18:45 +0000)]
AArch64: Improve SVE memcpy and memmove

Improve SVE memcpy by copying 2 vectors if the size is small enough.
This improves performance of random memcpy by ~9% on Neoverse V1, and
33-64 byte copies are ~16% faster.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agoAccount for grouping in printf width (bug 30068)
Carlos O'Donell [Thu, 19 Jan 2023 11:50:20 +0000 (12:50 +0100)]
Account for grouping in printf width (bug 30068)

This is a partial fix for mishandling of grouping when formatting
integers.  It properly computes the width in the presence of grouping
characters when the width is larger than the number of significant
digits. The precision related issue is documented in bug 23432.

Co-authored-by: Andreas Schwab <schwab@suse.de>
20 months agoMove RETURN_TO to x86/sysdep.h and implement x86_64 version.
Flavio Cruz [Sun, 5 Feb 2023 08:23:25 +0000 (03:23 -0500)]
Move RETURN_TO to x86/sysdep.h and implement x86_64 version.

Message-Id: <Y99nfeBrTubZL9oi@jupiter.tail36e24.ts.net>

20 months agoRemove pthread-pi-defines.sym
Andreas Schwab [Fri, 3 Feb 2023 15:10:49 +0000 (16:10 +0100)]
Remove pthread-pi-defines.sym

It became unused with the removal of the assembler implementation of the
pthread functions.

20 months agostdlib: tests: don't double-define _FORTIFY_SOURCE
Sam James [Fri, 3 Feb 2023 04:00:31 +0000 (23:00 -0500)]
stdlib: tests: don't double-define _FORTIFY_SOURCE

If using -D_FORITFY_SOURCE=3 (in my case, I've patched GCC to add
=3 instead of =2 (we've done =2 for years in Gentoo)), building
glibc tests will fail on testmb like:
```
<command-line>: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>: note: this is the location of the previous definition
cc1: all warnings being treated as errors
make[2]: *** [../o-iterator.mk:9: /var/tmp/portage/sys-libs/glibc-2.36/work/build-x86-x86_64-pc-linux-gnu-nptl/stdlib/testmb.o] Error 1
make[2]: *** Waiting for unfinished jobs....
```

It's just because we're always setting -D_FORTIFY_SOURCE=2
rather than unsetting it first. If F_S is already 2, it's harmless,
but if it's another value (say, 1, or 3), the compiler will bawk.

(I'm not aware of a reason this couldn't be tested with =3,
but the toolchain support is limited for that (too new), and we want
to run the tests everywhere possible.)

Signed-off-by: Sam James <sam@gentoo.org>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
20 months agoLoongArch: Add new relocation types.
caiyinyu [Tue, 31 Jan 2023 12:40:10 +0000 (20:40 +0800)]
LoongArch: Add new relocation types.

20 months agoRemove sysdeps/mach/i386/machine-sp.h
Flavio Cruz [Thu, 2 Feb 2023 07:42:18 +0000 (02:42 -0500)]
Remove sysdeps/mach/i386/machine-sp.h

This file is not used today since we end up using
sysdeps/i386/htl/machine-sp.h. Getting the stack pointer does not need
to be hurd specific and can go into sysdeps/<arch>.
Message-Id: <Y9tpWs2WOgE/Duiq@jupiter.tail36e24.ts.net>

20 months agocdefs: Limit definition of fortification macros
Siddhesh Poyarekar [Thu, 2 Feb 2023 12:49:02 +0000 (07:49 -0500)]
cdefs: Limit definition of fortification macros

Define the __glibc_fortify and other macros only when __FORTIFY_LEVEL >
0.  This has the effect of not defining these macros on older C90
compilers that do not have support for variable length argument lists.

Also trim off the trailing backslashes from the definition of
__glibc_fortify and __glibc_fortify_n macros.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
20 months agohurd: Move some i386 bits to x86
Samuel Thibault [Wed, 1 Feb 2023 23:27:26 +0000 (00:27 +0100)]
hurd: Move some i386 bits to x86

As they will actually be usable on x86_64 too.

20 months agoRemove support setting custom demuxers during signal handling.
Flavio Cruz [Mon, 30 Jan 2023 06:52:53 +0000 (01:52 -0500)]
Remove support setting custom demuxers during signal handling.

We seem to call only into the exception and message server routines.
Message-Id: <Y9dpRZs3QYk2oZm+@jupiter.tail36e24.ts.net>

20 months agohurd: Implement SHM_ANON
Sergey Bugaev [Mon, 30 Jan 2023 12:52:16 +0000 (15:52 +0300)]
hurd: Implement SHM_ANON

This adds a special SHM_ANON value that can be passed into shm_open ()
in place of a name. When called in this way, shm_open () will create a
new anonymous shared memory file. The file will be created in the same
way that other shared memory files are created (i.e., under /dev/shm/),
except that it is not given a name and therefore cannot be reached from
the file system, nor by other calls to shm_open (). This is accomplished
by utilizing O_TMPFILE.

This is intended to be compatible with FreeBSD's API of the same name.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230130125216.6254-4-bugaevc@gmail.com>

20 months agohurd: Implement O_TMPFILE
Sergey Bugaev [Mon, 30 Jan 2023 12:52:15 +0000 (15:52 +0300)]
hurd: Implement O_TMPFILE

This is a flag that causes open () to create a new, unnamed file in the
same filesystem as the given directory. The file descriptor can be
simply used in the creating process as a temporary file, or shared with
children processes via fork (), or sent over a Unix socket. The file can
be left anonymous, in which case it will be deleted from the backing
file system once all copies of the file descriptor are closed, or given
a permanent name with a linkat () call, such as the following:

int fd = open ("/tmp", O_TMPFILE | O_RDWR, 0700);
/* Do something with the file... */
linkat (fd, "", AT_FDCWD, "/tmp/filename", AT_EMPTY_PATH);

In between creating the file and linking it to the file system, it is
possible to set the file content, mode, ownership, author, and other
attributes, so that the file visibly appears in the file system (perhaps
replacing another file) atomically, with all of its attributes already
set up.

The Hurd support for O_TMPFILE directly exposes the dir_mkfile RPC to
user programs. Previously, dir_mkfile was used by glibc internally, in
particular for implementing tmpfile (), but not exposed to user programs
through a Unix-level API.

O_TMPFILE was initially introduced by Linux. This implementation is
intended to be compatible with the Linux implementation, except that the
O_EXCL flag is not given the special meaning when used together with
O_TMPFILE, unlike on Linux.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230130125216.6254-3-bugaevc@gmail.com>

20 months agohurd: Consolidate file_name_lookup implementation
Sergey Bugaev [Mon, 30 Jan 2023 12:52:14 +0000 (15:52 +0300)]
hurd: Consolidate file_name_lookup implementation

Instead of __file_name_lookup_at delegating to __file_name_lookup
in simple cases, make __file_name_lookup_at deal with both cases, and
have __file_name_lookup simply wrap __file_name_lookup_at.

This factorizes handling the empy name case.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230130125216.6254-2-bugaevc@gmail.com>

20 months agoLinux: optimize clone3 internal usage
Adhemerval Zanella Netto [Thu, 12 Jan 2023 13:58:53 +0000 (10:58 -0300)]
Linux: optimize clone3 internal usage

Add an optimization to avoid calling clone3 when glibc detects that
there is no kernel support.  It also adds __ASSUME_CLONE3, which allows
skipping this optimization and issuing the clone3 syscall directly.

It does not handle the the small window between 5.3 and 5.5 for
posix_spawn (CLONE_CLEAR_SIGHAND was added in 5.5).

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agoaarch64: Add the clone3 wrapper
Adhemerval Zanella Netto [Thu, 12 Jan 2023 13:58:52 +0000 (10:58 -0300)]
aarch64: Add the clone3 wrapper

It follow the internal signature:

  extern int clone3 (struct clone_args *__cl_args, size_t __size,
 int (*__func) (void *__arg), void *__arg);

Checked on aarch64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agolinux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn
Adhemerval Zanella Netto [Thu, 12 Jan 2023 13:58:51 +0000 (10:58 -0300)]
linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn

The clone3 flag resets all signal handlers of the child not set to
SIG_IGN to SIG_DFL.  It allows to skip most of the sigaction calls
to setup child signal handling, where previously a posix_spawn
had to issue 2 times NSIG sigaction calls (one to obtain the current
disposition and another to set either SIG_DFL or SIG_IGN).

With POSIX_SPAWN_SETSIGDEF the child will setup the signal for the case
where the disposition is SIG_IGN.

The code must handle the fallback where clone3 is not available. This is
done by splitting __clone_internal_fallback from __clone_internal.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agoLinux: Do not align the stack for __clone3
Adhemerval Zanella Netto [Thu, 12 Jan 2023 13:58:50 +0000 (10:58 -0300)]
Linux: Do not align the stack for __clone3

All internal callers of __clone3 should provide an already aligned
stack.  Removing the stack alignment in __clone3 is a net gain: it
simplifies the internal function contract (mask/unmask signals) along
with the arch-specific code.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agolinux: Extend internal clone3 documentation
Adhemerval Zanella Netto [Thu, 12 Jan 2023 13:58:49 +0000 (10:58 -0300)]
linux: Extend internal clone3 documentation

Different than kernel, clone3 returns EINVAL for NULL struct
clone_args or function pointer.  This is similar to clone
interface that return EINVAL for NULL function argument.

It also clean up the Linux clone3.h interface, since it not
currently exported.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agolinux: Do not reset signal handler in posix_spawn if it is already SIG_DFL
Adhemerval Zanella Netto [Thu, 12 Jan 2023 13:58:48 +0000 (10:58 -0300)]
linux: Do not reset signal handler in posix_spawn if it is already SIG_DFL

There is no need to issue another sigaction if the disposition is
already SIG_DFL.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agoOpen master branch for glibc 2.38 development
Carlos O'Donell [Wed, 1 Feb 2023 03:38:53 +0000 (22:38 -0500)]
Open master branch for glibc 2.38 development

20 months agoCreate ChangeLog.old/ChangeLog.26. upstream-2.37 upstream/2.37
Carlos O'Donell [Wed, 1 Feb 2023 03:27:45 +0000 (22:27 -0500)]
Create ChangeLog.old/ChangeLog.26.

20 months agoPrepare for glibc 2.37 release.
Carlos O'Donell [Wed, 1 Feb 2023 02:29:05 +0000 (21:29 -0500)]
Prepare for glibc 2.37 release.

Update version.h, and include/features.h.

20 months agox86: Fix strncat-avx2.S reading past length [BZ #30065]
Noah Goldstein [Tue, 31 Jan 2023 23:46:56 +0000 (17:46 -0600)]
x86: Fix strncat-avx2.S reading past length [BZ #30065]

Occurs when `src` has no null-term.

Two cases:

1) Zero-length check is doing:
```
    test    %rdx, %rdx
    jl      L(zero_len)
```
which doesn't actually check zero (was at some point `decq` and the
flag never got updated).

The fix is just make the flag `jle` i.e:
```
    test    %rdx, %rdx
    jle     L(zero_len)
```

2) Length check in page-cross case checking if we should continue is
doing:
```
    cmpq    %r8, %rdx
    jb      L(page_cross_small)
```
which means we will continue searching for null-term if length ends at
the end of a page and there was no null-term in `src`.

The fix is to make the flag:
```
    cmpq    %r8, %rdx
    jbe     L(page_cross_small)
```

20 months agoUpdate install.texi, and regenerate INSTALL.
Carlos O'Donell [Tue, 31 Jan 2023 22:15:24 +0000 (17:15 -0500)]
Update install.texi, and regenerate INSTALL.

20 months agoUpdate manual/contrib.texi.
Carlos O'Donell [Tue, 31 Jan 2023 22:01:30 +0000 (17:01 -0500)]
Update manual/contrib.texi.

Thank Yinyu Cai for their maintainership of the LoongArch port.

Thank Vineet Gupta for their maintainership of the ARC port.

Thank Tulio Magno Quites Machado Filho for their past maintainership
of the PowerPC port.

Thank Rajalakshmi Srinivasaraghavan for their current maintainership
of the PowerPC port.

20 months agoUpdate NEWS file with bug fixes.
Carlos O'Donell [Tue, 31 Jan 2023 22:00:58 +0000 (17:00 -0500)]
Update NEWS file with bug fixes.

20 months agoRegenerate configure.
Carlos O'Donell [Tue, 31 Jan 2023 21:48:15 +0000 (16:48 -0500)]
Regenerate configure.

Run using vanilla upstream autoconf 2.69.

Minor whitespace change to sysdeps/loongarch/configure and
sysdeps/mach/configure, and nothing else.

20 months agoUpdate all PO files in preparation for release.
Carlos O'Donell [Tue, 31 Jan 2023 21:30:44 +0000 (16:30 -0500)]
Update all PO files in preparation for release.

20 months agodoc: correct _FORTIFY_SOURCE doc in features.h
fanquake [Tue, 31 Jan 2023 13:25:11 +0000 (13:25 +0000)]
doc: correct _FORTIFY_SOURCE doc in features.h

20 months agolibio: Update number of written bytes in dprintf implementation
Florian Weimer [Tue, 31 Jan 2023 21:22:02 +0000 (22:22 +0100)]
libio: Update number of written bytes in dprintf implementation

The __printf_buffer_flush_dprintf function needs to record that
the buffer has been written before reusing it.  Without this
accounting, dprintf always returns zero.

Fixes commit 8ece45e4f586abd212d1c02d74d38ef681a45600
("libio: Convert __vdprintf_internal to buffers").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
20 months agoAccount for octal marker in %#o format
Andreas Schwab [Fri, 27 Jan 2023 22:25:59 +0000 (23:25 +0100)]
Account for octal marker in %#o format

20 months agoUse binutils 2.40 branch in build-many-glibcs.py
Joseph Myers [Fri, 27 Jan 2023 20:53:50 +0000 (20:53 +0000)]
Use binutils 2.40 branch in build-many-glibcs.py

This patch makes build-many-glibcs.py use binutils 2.40 branch.

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

20 months agoUse MPFR 4.2.0, MPC 1.3.1 in build-many-glibcs.py
Joseph Myers [Fri, 27 Jan 2023 18:27:26 +0000 (18:27 +0000)]
Use MPFR 4.2.0, MPC 1.3.1 in build-many-glibcs.py

This patch makes build-many-glibcs.py use the new MPFR 4.2.0 and MPC
1.3.1 releases.

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

20 months agostdio-common: Handle -1 buffer size in __sprintf_chk & co (bug 30039)
Florian Weimer [Wed, 25 Jan 2023 07:01:00 +0000 (08:01 +0100)]
stdio-common: Handle -1 buffer size in __sprintf_chk & co (bug 30039)

This shows up as an assertion failure when sprintf is called with
a specifier like "%.8g" and libquadmath is linked in:

Fatal glibc error: printf_buffer_as_file.c:31
  (__printf_buffer_as_file_commit): assertion failed:
  file->stream._IO_write_ptr <= file->next->write_end

Fix this by detecting pointer wraparound in __vsprintf_internal
and saturate the addition to the end of the address space instead.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
20 months agoDocument '%F' format specifier
Paul Pluzhnikov [Wed, 25 Jan 2023 00:39:31 +0000 (00:39 +0000)]
Document '%F' format specifier

The '%F' format specifier was implemented in commit 6c46718f9f0 on
2000-08-23, but remains undocumented in the manual.
https://stackoverflow.com/questions/75157669/format-specifier-f-missing-from-glibcs-documentation

Fix that.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
20 months agosparc (64bit): Regenerate ulps
Andreas K. Hüttel [Sun, 22 Jan 2023 23:46:02 +0000 (00:46 +0100)]
sparc (64bit): Regenerate ulps

Linux catbus 5.15.69-gentoo #1 SMP Sat Sep 24 07:56:24 PDT 2022 sparc64 sun4v UltraSparc T5 (Niagara5) GNU/Linux
gcc (Gentoo 11.3.1_p20221209 p3) 11.3.1 20221209
GNU ld (Gentoo 2.38 p4) 2.38
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agoia64: Regenerate ulps
Andreas K. Hüttel [Sun, 22 Jan 2023 18:32:17 +0000 (19:32 +0100)]
ia64: Regenerate ulps

Linux guppy 5.13.0-00002-gdecb01746d6c #368 SMP Sat Aug 14 20:10:13 UTC 2021 ia64 Dual-Core Intel(R) Itanium(R) Processor 9040 GenuineIntel GNU/Linux
gcc (Gentoo 12.2.1_p20221231 p8) 12.2.1 20221231
GNU ld (Gentoo 2.40 p1) 2.40
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agoUpdate libc.pot for 2.37 release.
Carlos O'Donell [Mon, 23 Jan 2023 13:49:29 +0000 (08:49 -0500)]
Update libc.pot for 2.37 release.

20 months agox86: Cache computation for AMD architecture.
Sajan Karumanchi [Wed, 18 Jan 2023 17:29:04 +0000 (18:29 +0100)]
x86: Cache computation for AMD architecture.

All AMD architectures cache details will be computed based on
__cpuid__ `0x8000_001D` and the reference to __cpuid__ `0x8000_0006` will be
zeroed out for future architectures.

Reviewed-by: Premachandra Mallappa <premachandra.mallappa@amd.com>
20 months agomanual: Fix typo
Martin Joerg [Wed, 18 Jan 2023 17:34:08 +0000 (18:34 +0100)]
manual: Fix typo

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
20 months agoAdd STATX_DIOALIGN from Linux 6.1 to bits/statx-generic.h
Joseph Myers [Tue, 17 Jan 2023 20:41:34 +0000 (20:41 +0000)]
Add STATX_DIOALIGN from Linux 6.1 to bits/statx-generic.h

Linux 6.1 adds a new STATX_DIOALIGN constant.  Add it to glibc's
bits/statx-generic.h.

Tested for x86_64.

20 months agoAdd IPPROTO_L2TP from Linux 6.1 to netinet/in.h
Joseph Myers [Tue, 17 Jan 2023 20:41:04 +0000 (20:41 +0000)]
Add IPPROTO_L2TP from Linux 6.1 to netinet/in.h

Linux 6.1 adds a define IPPROTO_L2TP to its include/uapi/linux/in.h
(not strictly a new constant, since it's moved from
include/uapi/linux/l2tp.h).  Add this constant to glibc's
netinet/in.h.

Tested for x86_64.

20 months agoAArch64: Improve strrchr
Wilco Dijkstra [Wed, 11 Jan 2023 13:53:19 +0000 (13:53 +0000)]
AArch64: Improve strrchr

Use shrn for narrowing the mask which simplifies code and speeds up small
strings.  Unroll the first search loop to improve performance on large
strings.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agoAArch64: Optimize strnlen
Wilco Dijkstra [Wed, 11 Jan 2023 13:53:05 +0000 (13:53 +0000)]
AArch64: Optimize strnlen

Optimize strnlen using the shrn instruction and improve the main loop.
Small strings are around 10% faster, large strings are 40% faster on
modern CPUs.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agoAArch64: Optimize strlen
Wilco Dijkstra [Wed, 11 Jan 2023 13:52:53 +0000 (13:52 +0000)]
AArch64: Optimize strlen

Optimize strlen by unrolling the main loop.  Large strings are 64% faster on
modern CPUs.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agoAArch64: Optimize strcpy
Wilco Dijkstra [Wed, 11 Jan 2023 13:52:39 +0000 (13:52 +0000)]
AArch64: Optimize strcpy

Unroll the main loop.  Large strings are around 20% faster on modern CPUs.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agoAArch64: Improve strchrnul
Wilco Dijkstra [Wed, 11 Jan 2023 13:52:23 +0000 (13:52 +0000)]
AArch64: Improve strchrnul

Unroll the main loop, which improves performance slightly.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agoAArch64: Optimize strchr
Wilco Dijkstra [Wed, 11 Jan 2023 13:52:08 +0000 (13:52 +0000)]
AArch64: Optimize strchr

Simplify calculation of the mask using shrn.  Unroll the main loop.
Small strings are 20% faster on modern CPUs.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agoAArch64: Improve strlen_asimd
Wilco Dijkstra [Wed, 11 Jan 2023 13:51:48 +0000 (13:51 +0000)]
AArch64: Improve strlen_asimd

Use shrn for the mask, merge tst+bne into cbnz, and tweak code alignment.
Performance improves slightly as a result.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agoAArch64: Optimize memrchr
Wilco Dijkstra [Wed, 11 Jan 2023 13:51:17 +0000 (13:51 +0000)]
AArch64: Optimize memrchr

Optimize the main loop - large strings are 43% faster on modern CPUs.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agoAArch64: Optimize memchr
Wilco Dijkstra [Wed, 11 Jan 2023 13:50:59 +0000 (13:50 +0000)]
AArch64: Optimize memchr

Optimize the main loop - large strings are 40% faster on modern CPUs.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
20 months agohurd: Fix _NOFLSH value
Samuel Thibault [Sun, 15 Jan 2023 19:54:42 +0000 (20:54 +0100)]
hurd: Fix _NOFLSH value

shifting 1 (thus an integer) left 31 bit is undefined behavior. We have to
make it an unsigned integer to properly get 0x80000000 (like done in other
places).

20 months agoelf: Fix GL(dl_phdr) and GL(dl_phnum) for static builds [BZ #29864]
Adhemerval Zanella [Tue, 3 Jan 2023 12:56:28 +0000 (09:56 -0300)]
elf: Fix GL(dl_phdr) and GL(dl_phnum) for static builds [BZ #29864]

The 73fc4e28b9464f0e refactor did not add the GL(dl_phdr) and
GL(dl_phnum) for static build, relying on the __ehdr_start symbol,
which is always added by the static linker, to get the correct values.

This is problematic in some ways:

  - The segment may see its in-memory size differ from its in-file
    size (or the binary may have holes).  The Linux has fixed is to
    provide concise values for both AT_PHDR and AT_PHNUM (commit
    0da1d5002745c - "fs/binfmt_elf: Fix AT_PHDR for unusual ELF files")

  - Some archs (alpha for instance) the hidden weak reference is not
    correctly pulled by the static linker and  __ehdr_start address
    end up being 0, which makes GL(dl_phdr) and GL(dl_phnum) have both
    invalid values (and triggering a segfault later on libc.so while
    accessing TLS variables).

The safer fix is to just restore the previous behavior to setup
GL(dl_phdr) and GL(dl_phnum) for static based on kernel auxv.  The
__ehdr_start fallback can also be simplified by not assuming weak
linkage (as for PIE).

The libc-static.c auxv init logic is moved to dl-support.c, since
the later is build without SHARED and then GLRO macro is defined
to access the variables directly.

The _dl_phdr is also assumed to be always non NULL, since an invalid
NULL values does not trigger TLS initialization (which is used in
various libc systems).

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

Reviewed-by: Florian Weimer <fweimer@redhat.com>
20 months agostring: Suppress -Wmaybe-unitialized for wordcopy [BZ #19444]
Adhemerval Zanella [Wed, 11 Jan 2023 21:27:29 +0000 (18:27 -0300)]
string: Suppress -Wmaybe-unitialized for wordcopy [BZ #19444]

When compiling with GCC 6+ the sparc build warns that some variables
might be used uninitialized.  However it does not seem the fact, since
the variables are really initialized (and also other targets that use the
same code, like powerpc, do not warn about it).

So suppress the warning for now.

Changes from v1:
* Update patch description and the explanation for the suppresion.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agoscripts/build-many-glibcs.py: Remove unused RANLIB and STRIP option
Adhemerval Zanella [Wed, 11 Jan 2023 21:17:11 +0000 (18:17 -0300)]
scripts/build-many-glibcs.py: Remove unused RANLIB and STRIP option

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agoconfigure: Move nm, objdump, and readelf to LIBC_PROG_BINUTILS
Adhemerval Zanella [Wed, 11 Jan 2023 21:17:10 +0000 (18:17 -0300)]
configure: Move nm, objdump, and readelf to LIBC_PROG_BINUTILS

Allow the variables to be overriden or have the defaults come
from the compiler currently in use.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agoconfigure: Allow user override LD, AR, OBJCOPY, and GPROF
Adhemerval Zanella [Tue, 6 Dec 2022 16:02:41 +0000 (13:02 -0300)]
configure: Allow user override LD, AR, OBJCOPY, and GPROF

The only way to override LD, AR, OBJCOPY, and GPROF is through
--with-binutils (setting the environments variables on configure is
overridden by LIBC_PROG_BINUTILS).

The build-many-glibcs.py (bmg) glibcs option generates a working config,
but not fully concise (some tools will be set from environment variable,
while other will be set from $CC --print-prog-name).  So remove the
environment variable set to always use the "$CC --print-prog-name".
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agomath: Suppress -O0 warnings for soft-fp fsqrt [BZ #19444]
Adhemerval Zanella [Thu, 29 Dec 2022 12:58:02 +0000 (09:58 -0300)]
math: Suppress -O0 warnings for soft-fp fsqrt [BZ #19444]

The patch suppress the same warnings from 87c266d758d29e52bfb717f90,
that shows issues for microblaze, mips soft-fp, nios2, and or1k.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agosunrpc: Suppress GCC -O1 warning on user2netname [BZ #19444]
Adhemerval Zanella [Thu, 29 Dec 2022 12:58:00 +0000 (09:58 -0300)]
sunrpc: Suppress GCC -O1 warning on user2netname [BZ #19444]

The same issue described by 6128e82ebe973163d2dd614d31753c88c0c4d645
also happend with -O1.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
20 months agolocale: Use correct buffer size for utf8_sequence_error [BZ #19444]
Adhemerval Zanella [Thu, 29 Dec 2022 12:57:59 +0000 (09:57 -0300)]
locale: Use correct buffer size for utf8_sequence_error [BZ #19444]

The buffer used by snprintf might not be large enough for all possible
inputs, as indicated by gcc with -O1:

../locale/programs/linereader.c: In function ‘utf8_sequence_error’:
../locale/programs/linereader.c:713:58: error: ‘%02x’ directive output
may be truncated writing between 2 and 8 bytes into a region of size
between 1 and 13 [-Werror=format-truncation=]
  713 |     snprintf (buf, sizeof (buf), "0x%02x 0x%02x 0x%02x 0x%02x",
      |                                                          ^~~~
../locale/programs/linereader.c:713:34: note: directive argument in the
range [0, 2147483647]
  713 |     snprintf (buf, sizeof (buf), "0x%02x 0x%02x 0x%02x 0x%02x",
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../locale/programs/linereader.c:713:5: note: ‘snprintf’ output between
20 and 38 bytes into a destination of size 30
  713 |     snprintf (buf, sizeof (buf), "0x%02x 0x%02x 0x%02x 0x%02x",
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  714 |               ch1, ch2, ch3, ch4);
      |               ~~~~~~~~~~~~~~~~~~~

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
21 months agoAdd HWCAP2_SVE_EBF16 from Linux 6.1 to AArch64 bits/hwcap.h
Joseph Myers [Tue, 10 Jan 2023 15:51:58 +0000 (15:51 +0000)]
Add HWCAP2_SVE_EBF16 from Linux 6.1 to AArch64 bits/hwcap.h

Linux 6.1 adds a new AArch64 HWCAP2 value HWCAP2_SVE_EBF16; add it to
the corresponding bits/hwcap.h.

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

21 months agoAdd _FORTIFY_SOURCE implementation documentation [BZ #28998]
Siddhesh Poyarekar [Tue, 10 Jan 2023 15:22:38 +0000 (10:22 -0500)]
Add _FORTIFY_SOURCE implementation documentation [BZ #28998]

There have been multiple requests to provide more detail on how the
_FORTIFY_SOURCE macro works, so this patch adds a new node in the
Library Maintenance section that does this.  A lot of the description is
implementation detail, which is why I put this in the appendix and not
in the main documentation.

Resolves: BZ #28998.
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
21 months agoUpdate copyright dates not handled by scripts/update-copyrights
Joseph Myers [Fri, 6 Jan 2023 21:45:36 +0000 (21:45 +0000)]
Update copyright dates not handled by scripts/update-copyrights

I've updated copyright dates in glibc for 2023.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.

21 months agoUpdate copyright dates with scripts/update-copyrights
Joseph Myers [Fri, 6 Jan 2023 21:08:04 +0000 (21:08 +0000)]
Update copyright dates with scripts/update-copyrights

21 months agoRemove trailing whitespace in gmp.h
Joseph Myers [Fri, 6 Jan 2023 21:14:15 +0000 (21:14 +0000)]
Remove trailing whitespace in gmp.h

21 months agoRemove trailing whitespace
Joseph Myers [Fri, 6 Jan 2023 21:11:08 +0000 (21:11 +0000)]
Remove trailing whitespace

For some reason this causes a pre-commit check error for a copyright
date update commit, even though that commit doesn't touch anything
near the line with this whitespace.

21 months agoC2x semantics for <tgmath.h>
Joseph Myers [Fri, 6 Jan 2023 19:33:29 +0000 (19:33 +0000)]
C2x semantics for <tgmath.h>

<tgmath.h> implements semantics for integer generic arguments that
handle cases involving _FloatN / _FloatNx types as specified in TS
18661-3 plus some defect fixes.

C2x has further changes to the semantics for <tgmath.h> macros with
such types, which should also be considered defect fixes (although
handled through the integration of TS 18661-3 in C2x rather than
through an issue tracking process).  Specifically, the rules were
changed because of problems raised with using the macros with the
evaluation format types such as float_t and _Float32_t: the older
version of the rules didn't allow passing _FloatN / _FloatNx types to
the narrowing macros returning float or double, or passing float /
double / long double to the narrowing macros returning _FloatN /
_FloatNx, which was a problem with the evaluation format types which
could be either kind of type depending on the value of
FLT_EVAL_METHOD.

Thus the new rules allow cases of mixing types which were not allowed
before, and, as part of the changes, the handling of integer arguments
was also changed: if there is any _FloatNx generic argument, integer
generic arguments are treated as _Float32x (not double), while the
rule about treating integer arguments to narrowing macros returning
_FloatN or _FloatNx as _Float64 not double was removed (no longer
needed now double is a valid argument to such macros).

I've implemented the changes in GCC's __builtin_tgmath, which thus
requires updates to glibc's test expectations so that the tests
continue to build with GCC 13 (the test is also updated to test the
argument types that weren't allowed before but are now valid under C2x
rules).

Given those test changes, it's then also necessary to fix the
implementations in <tgmath.h> to have appropriate semantics with older
GCC so that the tests pass with GCC versions before GCC 13 as well.
For some cases (non-narrowing macros with two or three generic
arguments; narrowing macros returning _Float32x), the older version of
__builtin_tgmath doesn't correspond sufficiently well to C2x
semantics, so in those cases <tgmath.h> is adjusted to use the older
macro implementation instead of __builtin_tgmath.  The older macro
implementation is itself adjusted to give the desired semantics, with
GCC 7 and later.  (It's not possible to get the right semantics in all
cases for the narrowing macros with GCC 6 and before when the _FloatN
/ _FloatNx names are typedefs rather than distinct types.)

Tested as follows: with the full glibc testsuite for x86_64, GCC 6, 7,
11, 13; with execution of the math/tests for aarch64, arm, powerpc and
powerpc64le, GCC 6, 7, 12 and 13 (powerpc64le only with GCC 12 and
13); with build-many-glibcs.py with GCC 6, 7, 12 and 13.

21 months agotime: Set daylight to 1 for matching DST/offset change (bug 29951)
Florian Weimer [Thu, 5 Jan 2023 17:21:25 +0000 (18:21 +0100)]
time: Set daylight to 1 for matching DST/offset change (bug 29951)

The daylight variable is supposed to be set to 1 if DST is ever in
use for the current time zone.  But __tzfile_read used to do this:

  __daylight = rule_stdoff != rule_dstoff;

This check can fail to set __daylight to 1 if the DST and non-DST
offsets happen to be the same.

21 months agoFix ldbl-128 built-in function use
Joseph Myers [Thu, 5 Jan 2023 00:02:54 +0000 (00:02 +0000)]
Fix ldbl-128 built-in function use

Fix the following issues with built-in function use in
sysdeps/ieee754/ldbl-128 and sysdeps/ieee754/float128:

* fabsl used __builtin_fabsf128 unconditionally, breaking the build
  with GCC 6 for several architectures; it should use __builtin_fabsl
  with an appropriate redirection in float128_private.h.  (I'm not
  particularly concerned with building glibc with GCC 6; rather, I
  want to be able to run the tgmath.h tests with GCC 6, which is a
  significantly different case for tgmath.h compared to GCC 7 and
  later because of the lack of _FloatN / _FloatNx support in the
  compiler, and at present running the tests with a compiler means
  building glibc with that compiler.)

* Some (conditional) uses of built-in functions had been added to
  ldbl-128 without appropriate float128_private.h remapping (there was
  remapping for the macros controlling whether the built-in functions
  are used, just not for the functions themselves).

* s_llrintl.c called __builtin_round not __builtin_llrintl, which is
  obviously wrong.

Tested with build-many-glibcs.py for aarch64-linux-gnu, GCC 6 (where
it fixes the glibc build) and GCC 12, and with the glibc testsuite for
x86_64.

21 months agox86: Check minimum/maximum of non_temporal_threshold [BZ #29953]
H.J. Lu [Tue, 3 Jan 2023 21:06:48 +0000 (13:06 -0800)]
x86: Check minimum/maximum of non_temporal_threshold [BZ #29953]

The minimum non_temporal_threshold is 0x4040.  non_temporal_threshold may
be set to less than the minimum value when the shared cache size isn't
available (e.g., in an emulator) or by the tunable.  Add checks for
minimum and maximum of non_temporal_threshold.

This fixes BZ #29953.