]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
7 months agotst-resolv-invalid-cname.c: Explicitly cast 192 and 168 to char
H.J. Lu [Mon, 16 Dec 2024 21:54:52 +0000 (05:54 +0800)] 
tst-resolv-invalid-cname.c: Explicitly cast 192 and 168 to char

Explicitly cast 192 and 168 to char to silence Clang error:

tst-resolv-invalid-cname.c:313:17: error: implicit conversion from 'int' to 'char' changes value from 192 to -64 [-Werror,-Wconstant-conversion]
  313 |       addr[0] = 192;
      |               ~ ^~~
tst-resolv-invalid-cname.c:314:17: error: implicit conversion from 'int' to 'char' changes value from 168 to -88 [-Werror,-Wconstant-conversion]
  314 |       addr[1] = 168;
      |               ~ ^~~

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoSilence Clang #include_next error
H.J. Lu [Mon, 16 Dec 2024 21:56:53 +0000 (05:56 +0800)] 
Silence Clang #include_next error

Use "#include <...>" to silence Clang #include_next error:

In file included from ../sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c:19:
../sysdeps/x86_64/fpu/test-double-vlen4.h:19:2: error: #include_next in file found relative to primary source file or found by absolute path; will search from start of include path [-Werror,-Winclude-next-absolute-path]
   19 | #include_next <test-double-vlen4.h>
      |  ^
1 error generated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agocet: Pass -mshstk to compiler for tst-cet-legacy-10a[-static].c
H.J. Lu [Mon, 16 Dec 2024 22:18:55 +0000 (06:18 +0800)] 
cet: Pass -mshstk to compiler for tst-cet-legacy-10a[-static].c

Pass -mshstk to compiler to silence Clang:

In file included from ../sysdeps/x86_64/tst-cet-legacy-10a.c:2:
../sysdeps/x86_64/tst-cet-legacy-10.c:29:7: error: always_inline function '_get_ssp' requires target feature 'shstk', but would be inlined into function 'do_test' that is compiled without support for 'shstk'
   29 |   if (_get_ssp () != 0)
      |       ^

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoAArch64: Improve codegen of AdvSIMD expf family
Joana Cruz [Tue, 17 Dec 2024 14:50:33 +0000 (14:50 +0000)] 
AArch64: Improve codegen of AdvSIMD expf family

Load the polynomial evaluation coefficients into 2 vectors and use lanewise MLAs.
Also use intrinsics instead of native operations.
expf: 3% improvement in throughput microbenchmark on Neoverse V1, exp2f: 5%,
exp10f: 13%, coshf: 14%.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
7 months agoAArch64: Improve codegen of AdvSIMD atan(2)(f)
Joana Cruz [Tue, 17 Dec 2024 14:49:30 +0000 (14:49 +0000)] 
AArch64: Improve codegen of AdvSIMD atan(2)(f)

Load the polynomial evaluation coefficients into 2 vectors and use lanewise MLAs.
8% improvement in throughput microbenchmark on Neoverse V1.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
7 months agoAArch64: Improve codegen of AdvSIMD logf function family
Joana Cruz [Tue, 17 Dec 2024 14:47:31 +0000 (14:47 +0000)] 
AArch64: Improve codegen of AdvSIMD logf function family

Load the polynomial evaluation coefficients into 2 vectors and use lanewise MLAs.
8% improvement in throughput microbenchmark on Neoverse V1 for log2 and log,
and 2% for log10.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
7 months agoHide all malloc functions from compiler [BZ #32366]
H.J. Lu [Tue, 17 Dec 2024 10:41:45 +0000 (18:41 +0800)] 
Hide all malloc functions from compiler [BZ #32366]

Since -1 isn't a power of two, compiler may reject it, hide memalign from
Clang 19 which issues an error:

tst-memalign.c:86:31: error: requested alignment is not a power of 2 [-Werror,-Wnon-power-of-two-alignment]
   86 |   p = memalign (-1, pagesize);
      |                 ^~
tst-memalign.c:86:31: error: requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed [-Werror,-Wbuiltin-assume-aligned-alignment]
   86 |   p = memalign (-1, pagesize);
      |                 ^~

Update tst-malloc-aux.h to hide all malloc functions and include it in
all malloc tests to prevent compiler from optimizing out any malloc
functions.

Tested with Clang 19.1.5 and GCC 15 20241206 for BZ #32366.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agolibio: Use NULL instead of 0 as a null pointer constant
Alejandro Colomar [Mon, 16 Dec 2024 23:22:19 +0000 (00:22 +0100)] 
libio: Use NULL instead of 0 as a null pointer constant

This was missed in a recent global change.

Fixes: 53fcdf5f743a (2024-11-25, "Silence most -Wzero-as-null-pointer-constant diagnostics")
Reported-by: "Maciej W. Rozycki" <macro@redhat.com>
Cc: Siddhesh Poyarekar <siddhesh@sourceware.org>
Cc: Bruno Haible <bruno@clisp.org>
Cc: Martin Uecker <uecker@tugraz.at>
Cc: Xi Ruoyao <xry111@xry111.site>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Joseph Myers <josmyers@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Maciej W. Rozycki <macro@redhat.com>
7 months agomanual: Document more sigaction flags
DJ Delorie [Tue, 10 Dec 2024 22:07:21 +0000 (17:07 -0500)] 
manual: Document more sigaction flags

Adds documentation for three-argument handler

Adds remainder of the SA_* flags

Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 months agoRemove duplicated BUILD_CC in Makeconfig
H.J. Lu [Thu, 5 Dec 2024 07:47:53 +0000 (15:47 +0800)] 
Remove duplicated BUILD_CC in Makeconfig

Remove the second

ifndef BUILD_CC
BUILD_CC = $(CC)
endif

in Makeconfig.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
7 months agoiconv: do not report error exit with transliteration [BZ #32448]
Aurelien Jarno [Sat, 14 Dec 2024 10:44:11 +0000 (11:44 +0100)] 
iconv: do not report error exit with transliteration [BZ #32448]

Commit 6cbf845fcdc7 ("iconv: Preserve iconv -c error exit on invalid
inputs (bug 32046)") changed the error exit code to report an error when
an input character has been transliterated. This looks like a bug as the
moto in the iconv program is to report an error code in the same
condition as the iconv() function.

This happens because the STANDARD_TO_LOOP_ERR_HANDLER macro sets a
default value for result and later updates it if the transliteration
succeed. With the changes, setting the default value also marks the
input as illegal.

Fix that by setting up the default value of result only when the
transliteration is not used. This works because __gconv_transliterate()
calls __gconv_mark_illegal_input() to return an error. At the same time
also fix the typo outself -> ourselves.

Fixes: 6cbf845fcdc7
Resolves: BZ #32448
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
7 months agoFix sysdeps/x86/fpu/Makefile: Split and sort tests
H.J. Lu [Sun, 15 Dec 2024 21:57:28 +0000 (05:57 +0800)] 
Fix sysdeps/x86/fpu/Makefile: Split and sort tests

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agosysdeps/x86/fpu/Makefile: Split and sort tests
H.J. Lu [Sun, 15 Dec 2024 21:49:43 +0000 (05:49 +0800)] 
sysdeps/x86/fpu/Makefile: Split and sort tests

Split and sort tests in sysdeps/x86/fpu/Makefile.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoUse empty initializer to silence GCC 4.9 or older
H.J. Lu [Sun, 15 Dec 2024 14:44:49 +0000 (22:44 +0800)] 
Use empty initializer to silence GCC 4.9 or older

Use empty initializer to silence GCC 4.9 or older:

getaddrinfo.c: In function ‘gaih_inet’:
getaddrinfo.c:1135:24: error: missing braces around initializer [-Werror=missing-braces]
       / sizeof (struct gaih_typeproto)] = {0};
                        ^

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoLinux: Check for 0 return value from vDSO getrandom probe
Florian Weimer [Sun, 15 Dec 2024 16:05:25 +0000 (17:05 +0100)] 
Linux: Check for 0 return value from vDSO getrandom probe

As of Linux 6.13, there is no code in the vDSO that declines this
initialization request with the special ~0UL state size.  If the vDSO
has the function, the call succeeds and returns 0.  It's expected
that the code would follow the “a negative value indicating an error”
convention, as indicated in the __cvdso_getrandom_data function
comment, so that INTERNAL_SYSCALL_ERROR_P on glibc's side would return
true.  This commit changes the commit to check for zero to indicate
success instead, which covers potential future non-zero success
return values and error returns.

Fixes commit 4f5704ea347e52ac3f272d1341da10aed6e9973e ("powerpc: Use
correct procedure call standard for getrandom vDSO call (bug 32440)").

7 months agohppa: Update libm-test-ulps
John David Anglin [Sun, 15 Dec 2024 14:24:53 +0000 (09:24 -0500)] 
hppa: Update libm-test-ulps

Signed-off-by: John David Anglin <dave.anglin@bell.net>
7 months agoRevert "Add braces in initializers for GCC 4.9 or older"
H.J. Lu [Sun, 15 Dec 2024 10:49:43 +0000 (18:49 +0800)] 
Revert "Add braces in initializers for GCC 4.9 or older"

This reverts commit 8aa2a9e0339215012354f3c4a262edda838134e8.

as not all targets need braces.

7 months agotst-difftime.c: Use "main (void)"
H.J. Lu [Sun, 15 Dec 2024 07:01:57 +0000 (15:01 +0800)] 
tst-difftime.c: Use "main (void)"

Use "main (void)" instead of "main (void)" to avoid GCC 4.9 warning:

tst-difftime.c:62:1: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
 main ()
 ^
tst-difftime.c: In function ‘main’:
tst-difftime.c:62:1: error: old-style function definition [-Werror=old-style-definition]
cc1: all warnings being treated as errors

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoor1k: Update libm-test-ulps
Stafford Horne [Fri, 13 Dec 2024 11:24:12 +0000 (11:24 +0000)] 
or1k: Update libm-test-ulps

Regen to add new functions acospi, asinpi, atan2pi and atanpi.

7 months agohtl: move pthread_sigmask into libc.
gfleury [Thu, 12 Dec 2024 22:06:12 +0000 (00:06 +0200)] 
htl: move pthread_sigmask into libc.

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

7 months agohtl: move __pthread_sigstate into libc.
gfleury [Thu, 12 Dec 2024 22:06:11 +0000 (00:06 +0200)] 
htl: move __pthread_sigstate into libc.

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

7 months agohtl: move __pthread_sigstate_destroy into libc.
gfleury [Thu, 12 Dec 2024 22:06:10 +0000 (00:06 +0200)] 
htl: move __pthread_sigstate_destroy into libc.

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

7 months agoReturn EXIT_UNSUPPORTED if __builtin_add_overflow unavailable
H.J. Lu [Sat, 14 Dec 2024 12:12:21 +0000 (20:12 +0800)] 
Return EXIT_UNSUPPORTED if __builtin_add_overflow unavailable

Since GCC 4.9 doesn't have __builtin_add_overflow:

In file included from tst-stringtable.c:180:0:
stringtable.c: In function ‘stringtable_finalize’:
stringtable.c:185:7: error: implicit declaration of function ‘__builtin_add_overflow’ [-Werror=implicit-function-declaration]
       else if (__builtin_add_overflow (previous->offset,
       ^

return EXIT_UNSUPPORTED for GCC 4.9 or older.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoifuncmain9.c: Return EXIT_UNSUPPORTED for GCC 5.4 or older
H.J. Lu [Thu, 12 Dec 2024 21:22:47 +0000 (05:22 +0800)] 
ifuncmain9.c: Return EXIT_UNSUPPORTED for GCC 5.4 or older

Since elf/ifuncmain9.c fails at run-time when compiled with GCC 5.4 or
older (PR ipa/81128), return EXIT_UNSUPPORTED for GCC 5.4 or older.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoinclude/bits/sigstksz.h: Avoid #elif IS_IN (libsupport)
H.J. Lu [Thu, 12 Dec 2024 21:56:05 +0000 (05:56 +0800)] 
include/bits/sigstksz.h: Avoid #elif IS_IN (libsupport)

GCC 4.9 issues an error when generating misc/check-installed-headers-c.out:

In file included from ../signal/signal.h:328:0,
                 from ../include/signal.h:2,
                 from ../misc/sys/param.h:28,
                 from ../include/sys/param.h:1,
                 from /tmp/cih_test_e156ZB.c:10:
../include/bits/sigstksz.h:5:7: error: "IS_IN" is not defined [-Werror=undef]
 #elif IS_IN (libsupport)
       ^

Use "#else" instead.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoregex.h: Avoid #elif __STDC_VERSION__
H.J. Lu [Thu, 12 Dec 2024 23:13:00 +0000 (07:13 +0800)] 
regex.h: Avoid #elif __STDC_VERSION__

GCC 4.9 doesn't define __STDC_VERSION__ and issues an error:

In file included from ../include/regex.h:2:0,
                 from ../posix/re_comp.h:23,
                 from ../include/re_comp.h:1,
                 from /tmp/cih_test_7IKTRI.c:10:
../posix/regex.h:650:19: error: "__STDC_VERSION__" is not defined [-Werror=undef]
 # elif 199901L <= __STDC_VERSION__ || defined restrict
                   ^

Use "#else" instead.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agotst-assert-c++.cc: Return EXIT_UNSUPPORTED for GCC 4.9 or older
H.J. Lu [Thu, 12 Dec 2024 21:31:05 +0000 (05:31 +0800)] 
tst-assert-c++.cc: Return EXIT_UNSUPPORTED for GCC 4.9 or older

Since assert/tst-assert-c++.cc fails to compile with GCC 4.9:

./tst-assert-c++.cc: In function ‘constexpr int check_constexpr()’:
./tst-assert-c++.cc:30:1: error: body of constexpr function ‘constexpr int check_constexpr()’ not a return-statement
 }
 ^

return EXIT_UNSUPPORTED for GCC 4.9 or older.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoAdd braces in initializers for GCC 4.9 or older
H.J. Lu [Thu, 12 Dec 2024 21:38:57 +0000 (05:38 +0800)] 
Add braces in initializers for GCC 4.9 or older

Add braces to silence GCC 4.9 or older:

getaddrinfo.c: In function ‘gaih_inet’:
getaddrinfo.c:1135:24: error: missing braces around initializer [-Werror=missing-braces]
       / sizeof (struct gaih_typeproto)] = {0};
                        ^

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoReturn EXIT_UNSUPPORTED if __builtin_mul_overflow unavailable
H.J. Lu [Thu, 12 Dec 2024 21:59:59 +0000 (05:59 +0800)] 
Return EXIT_UNSUPPORTED if __builtin_mul_overflow unavailable

Since GCC 4.9 doesn't support __builtin_mul_overflow:

tst-fd_to_filename.c: In function ‘check_ranges’:
tst-fd_to_filename.c:51:3: error: implicit declaration of function ‘__builtin_mul_overflow’ [-Werror=implicit-function-declaration]
   while (!__builtin_mul_overflow (power, base, &power));
   ^
cc1: all warnings being treated as errors

return EXIT_UNSUPPORTED for GCC 4.9 or older.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agotst-minsigstksz-1.c: Return EXIT_UNSUPPORTED for GCC 4.9 or older
H.J. Lu [Thu, 12 Dec 2024 22:28:45 +0000 (06:28 +0800)] 
tst-minsigstksz-1.c: Return EXIT_UNSUPPORTED for GCC 4.9 or older

Since ATOMIC_INT_LOCK_FREE in GCC 4.9 is defined as

 #define ATOMIC_INT_LOCK_FREE                    \
  __atomic_type_lock_free (atomic_int)

GCC 4.9 fails to compile tst-minsigstksz-1.c:

tst-minsigstksz-1.c:45:6: error: missing binary operator before token "("
 # if ATOMIC_INT_LOCK_FREE != 2
      ^

Change tst-minsigstksz-1.c to define TEST_ATOMIC_OPS to 0 for GCC 4.9 or
older.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agotester.c: Use -Wmemset-transposed-args for GCC 5 or newer
H.J. Lu [Thu, 12 Dec 2024 22:51:22 +0000 (06:51 +0800)] 
tester.c: Use -Wmemset-transposed-args for GCC 5 or newer

Since GCC 4.9 issues an error:

In file included from inl-tester.c:6:0:
tester.c:58:1: error: unknown option after ‘#pragma GCC diagnostic’ kind [-Werror=pragmas]
 DIAG_IGNORE_NEEDS_COMMENT (5.0, "-Wmemset-transposed-args");
 ^

use it for GCC 5 or newer.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoMakefile.in: Add test to check xcheck rule
H.J. Lu [Sat, 14 Dec 2024 00:43:29 +0000 (08:43 +0800)] 
Makefile.in: Add test to check xcheck rule

Add test to check xcheck rule so that TEST_CC and TEST_CXX are used for
"make test".

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoDon't use TEST_CXX as CXX for build
H.J. Lu [Sat, 14 Dec 2024 00:43:01 +0000 (08:43 +0800)] 
Don't use TEST_CXX as CXX for build

Since the C++ compiler is also used to compile links-dso-program.cc in
libsupport, use TEST_CXX to get C++ headers for testing, but don't use
TEST_CXX as CXX for build.

Tested for m68k-linux-gnu-coldfire build and native build on x86-64.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoAArch64: Update libm-test-ulps
Wilco Dijkstra [Fri, 13 Dec 2024 16:50:25 +0000 (16:50 +0000)] 
AArch64: Update libm-test-ulps

Update ulps for acospi, asinpi, atanpi, atan2pi.

7 months agos390: Simplify elf_machine_{load_address, dynamic} [BZ #31799]
Stefan Liebler [Fri, 6 Dec 2024 11:50:09 +0000 (12:50 +0100)] 
s390: Simplify elf_machine_{load_address, dynamic} [BZ #31799]

If an executable is static PIE and has a non-zero load address
(compare to elf/tst-pie-address-static), it segfaults as
elf_machine_load_address() returns 0x0 and elf_machine_dynamic()
returns the run-time instead of link-time address of _DYNAMIC.

Now rely on __ehdr_start and _DYNAMIC as also done on other
architectures.

Checked back to old arch-levels that this approach works fine:
- 31bit: -march=g5
- 64bit: -march=z900

Note, that there is no static-PIE support on 31bit, but this
approach cleans it also up.

Furthermore this cleanup in glibc does not change anything
regarding the first GOT-element as the s390 ABI
(https://github.com/IBM/s390x-abi) explicitely defines:
The doubleword at _GLOBAL_OFFSET_TABLE_[0] is set by the linkage
editor to hold the address of the dynamic structure, referenced
with the symbol _DYNAMIC. This allows a program, such as the dynamic
linker, to find its own dynamic structure without having yet processed
its relocation entries. This is especially important for the dynamic
linker, because it must initialize itself without relying on other
programs to relocate its memory image.

7 months agoor1k: Update libm-test-ulps
Stafford Horne [Thu, 12 Dec 2024 21:04:50 +0000 (21:04 +0000)] 
or1k: Update libm-test-ulps

Pick up new functions cospi, "Imaginary part of csin", exp10m1, exp2m1,
log10p1, log2p1, sinpi and tanpi.

7 months agonptl: Add <thread_pointer.h> for or1k
Michael Jeanson [Fri, 1 Nov 2024 19:23:24 +0000 (15:23 -0400)] 
nptl: Add <thread_pointer.h> for or1k

This will be required by the rseq extensible ABI implementation on all
Linux architectures exposing the '__rseq_size' and '__rseq_offset'
symbols to set the initial value of the 'cpu_id' field which can be used
by applications to test if rseq is available and registered. As long as
the symbols are exposed it is valid for an application to perform this
test even if rseq is not yet implemented in libc for this architecture.

Compile tested with build-many-glibcs.py but I don't have access to any
hardware to run the tests.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Stafford Horne <shorne@gmail.com>
7 months agoImplement C23 atan2pi
Joseph Myers [Thu, 12 Dec 2024 20:57:44 +0000 (20:57 +0000)] 
Implement C23 atan2pi

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the atan2pi functions (atan2(y,x)/pi).

Tested for x86_64 and x86, and with build-many-glibcs.py.

7 months agoClear CXX and TEST_CXX if C++ link test fails
H.J. Lu [Thu, 12 Dec 2024 11:13:52 +0000 (19:13 +0800)] 
Clear CXX and TEST_CXX if C++ link test fails

Since the C++ compiler is used only for testing, use TEST_CXX as the C++
compiler if available.  If C++ link test fails, clear both CXX and
TEST_CXX so that the C++ compiler isn't used for glibc build nor test.

Tested for m68k-linux-gnu-coldfire build and native build on x86-64.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agomath: Remove __XXX math functions from installed math.h [BZ #32418]
H.J. Lu [Thu, 5 Dec 2024 00:05:04 +0000 (08:05 +0800)] 
math: Remove __XXX math functions from installed math.h [BZ #32418]

Since libm doesn't export __XXX math functions, don't declare them in
the installed math.h by adding <bits/mathcalls-macros.h> to declare
__XXX math functions internally for glibc build.  This fixes BZ #32418.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoOptimize bsearch() implementation for performance
Kuan-Wei Chiu [Mon, 9 Sep 2024 16:23:27 +0000 (00:23 +0800)] 
Optimize bsearch() implementation for performance

Optimize the bsearch() function to improve binary search performance.
Although the code size grew by 8 bytes, the new implementation achieves
a 15% reduction in execution time on my x86 machine, according to the
bench-bsearch benchmark results.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
7 months agobenchtests: Add benchmark test for bsearch
Kuan-Wei Chiu [Mon, 9 Sep 2024 16:23:26 +0000 (00:23 +0800)] 
benchtests: Add benchmark test for bsearch

Introduce a benchmark test for the bsearch function to evaluate its
performance.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
7 months agoImplement C23 atanpi
Joseph Myers [Wed, 11 Dec 2024 21:51:49 +0000 (21:51 +0000)] 
Implement C23 atanpi

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the atanpi functions (atan(x)/pi).

Tested for x86_64 and x86, and with build-many-glibcs.py.

7 months agopowerpc64: Fix dl-trampoline.S big-endian / non-ROP build failure
Peter Bergner [Wed, 11 Dec 2024 20:15:13 +0000 (23:15 +0300)] 
powerpc64: Fix dl-trampoline.S big-endian / non-ROP build failure

Fix a big-endian / non-ROP build failure caused by commit 4d9a4c02 when
building dl-trampoline.S.

Reported-by: Joseph Myers <josmyers@redhat.com>
7 months agopowerpc: Use correct procedure call standard for getrandom vDSO call (bug 32440)
Florian Weimer [Tue, 10 Dec 2024 15:17:06 +0000 (16:17 +0100)] 
powerpc: Use correct procedure call standard for getrandom vDSO call (bug 32440)

A plain indirect function call does not work on POWER because
success and failure are signaled through a flag register, and
not via the usual Linux negative return value convention.

This has potential security impact, in two ways: the return value
could be out of bounds (EAGAIN is 11 on powerpc6le), and no
random bytes have been written despite the non-error return value.

Fixes commit 461cab1de747f3842f27a5d24977d78d561d45f9 ("linux: Add
support for getrandom vDSO").

Reported-by: Ján Stanček <jstancek@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 months agoAdd TEST_CC and TEST_CXX support
H.J. Lu [Thu, 5 Dec 2024 20:44:05 +0000 (04:44 +0800)] 
Add TEST_CC and TEST_CXX support

Support testing glibc build with a different C compiler or a different
C++ compiler with

$ ../glibc-VERSION/configure TEST_CC="gcc-6.4.1" TEST_CXX="g++-6.4.1"

1. Add LIBC_TRY_CC_AND_TEST_CC_OPTION, LIBC_TRY_CC_AND_TEST_CC_COMMAND
and LIBC_TRY_CC_AND_TEST_LINK to test both CC and TEST_CC.
2. Add check and xcheck targets to Makefile.in and override build compiler
options with ones from TEST_CC and TEST_CXX.

Tested on Fedora 41/x86-64:

1. Building with GCC 14.2.1 and testing with GCC 6.4.1 and GCC 11.2.1.
2. Building with GCC 15 and testing with GCC 6.4.1.

Support for GCC versions older than GCC 6.2 may need to change the test
sources.  Other targets may need to update configure.ac under sysdeps and
modify Makefile.in to override target build compiler options.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agopowerpc64le: ROP changes for the dl-trampoline functions
Peter Bergner [Tue, 10 Dec 2024 03:41:08 +0000 (22:41 -0500)] 
powerpc64le: ROP changes for the dl-trampoline functions

Add ROP protection for the _dl_runtime_resolve and _dl_profile_resolve
functions.

7 months agomalloc: Add tcache path for calloc
Wangyang Guo [Wed, 4 Dec 2024 11:16:22 +0000 (19:16 +0800)] 
malloc: Add tcache path for calloc

This commit add tcache support in calloc() which can largely improve
the performance of small size allocation, especially in multi-thread
scenario. tcache_available() and tcache_try_malloc() are split out as
a helper function for better reusing the code.

Also fix tst-safe-linking failure after enabling tcache. In previous,
calloc() is used as a way to by-pass tcache in memory allocation and
trigger safe-linking check in fastbins path. With tcache enabled, it
needs extra workarounds to bypass tcache.

Result of bench-calloc-thread benchmark

Test Platform: Xeon-8380
Ratio: New / Original time_per_iteration (Lower is Better)

Threads#   | Ratio
-----------|------
1 thread   | 0.656
4 threads  | 0.470
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoImplement C23 asinpi
Joseph Myers [Tue, 10 Dec 2024 20:42:20 +0000 (20:42 +0000)] 
Implement C23 asinpi

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the asinpi functions (asin(x)/pi).

Tested for x86_64 and x86, and with build-many-glibcs.py.

7 months agomalloc: add indirection for malloc(-like) functions in tests [BZ #32366]
Sam James [Mon, 9 Dec 2024 23:11:25 +0000 (23:11 +0000)] 
malloc: add indirection for malloc(-like) functions in tests [BZ #32366]

GCC 15 introduces allocation dead code removal (DCE) for PR117370 in
r15-5255-g7828dc070510f8. This breaks various glibc tests which want
to assert various properties of the allocator without doing anything
obviously useful with the allocated memory.

Alexander Monakov rightly pointed out that we can and should do better
than passing -fno-malloc-dce to paper over the problem. Not least because
GCC 14 already does such DCE where there's no testing of malloc's return
value against NULL, and LLVM has such optimisations too.

Handle this by providing malloc (and friends) wrappers with a volatile
function pointer to obscure that we're calling malloc (et. al) from the
compiler.

Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
7 months agoImplement C23 acospi
Joseph Myers [Mon, 9 Dec 2024 23:01:29 +0000 (23:01 +0000)] 
Implement C23 acospi

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the acospi functions (acos(x)/pi).

Tested for x86_64 and x86, and with build-many-glibcs.py.

7 months agopowerpc64le: ROP changes for the *context and setjmp functions
Sachin Monga [Mon, 9 Dec 2024 21:47:40 +0000 (16:47 -0500)] 
powerpc64le: ROP changes for the *context and setjmp functions

Add ROP protection for the getcontext, setcontext, makecontext, swapcontext
and __sigsetjmp_symbol functions.

Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
7 months agonptl: Add <thread_pointer.h> for m68k
Michael Jeanson [Mon, 9 Dec 2024 20:24:26 +0000 (20:24 +0000)] 
nptl: Add <thread_pointer.h> for m68k

This will be required by the rseq extensible ABI implementation on all
Linux architectures exposing the '__rseq_size' and '__rseq_offset'
symbols to set the initial value of the 'cpu_id' field which can be used
by applications to test if rseq is available and registered. As long as
the symbols are exposed it is valid for an application to perform this
test even if rseq is not yet implemented in libc for this architecture.

Compile tested with build-many-glibcs.py but I don't have access to any
hardware to run the tests.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
7 months agonptl: Add <thread_pointer.h> for RISC-V
Michael Jeanson [Wed, 31 Jul 2024 15:20:36 +0000 (11:20 -0400)] 
nptl: Add <thread_pointer.h> for RISC-V

This will be required by the rseq extensible ABI implementation on all
Linux architectures exposing the '__rseq_size' and '__rseq_offset'
symbols to set the initial value of the 'cpu_id' field which can be used
by applications to test if rseq is available and registered. As long as
the symbols are exposed it is valid for an application to perform this
test even if rseq is not yet implemented in libc for this architecture.

Both code paths tested on a Visionfive 2 with Debian sid.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
7 months agonptl: add RSEQ_SIG for RISC-V
Michael Jeanson [Wed, 31 Jul 2024 17:18:18 +0000 (13:18 -0400)] 
nptl: add RSEQ_SIG for RISC-V

Enable RSEQ for RISC-V, support was added in Linux 5.18.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
7 months agoAArch64: Improve codegen in users of ADVSIMD expm1 helper
Pierre Blanchard [Mon, 9 Dec 2024 15:58:47 +0000 (15:58 +0000)] 
AArch64: Improve codegen in users of ADVSIMD expm1 helper

Add inline helper for expm1 and rearrange operations so MOV
is not necessary in reduction or around the special-case handler.
Reduce memory access by using more indexed MLAs in polynomial.
Speedup on Neoverse V1 for expm1 (19%), sinh (8.5%), and tanh (7.5%).

7 months agoAArch64: Improve codegen in users of ADVSIMD log1p helper
Pierre Blanchard [Mon, 9 Dec 2024 15:55:39 +0000 (15:55 +0000)] 
AArch64: Improve codegen in users of ADVSIMD log1p helper

Add inline helper for log1p and rearrange operations so MOV
is not necessary in reduction or around the special-case handler.
Reduce memory access by using more indexed MLAs in polynomial.
Speedup on Neoverse V1 for log1p (3.5%), acosh (7.5%) and atanh (10%).

7 months agoAArch64: Improve codegen in AdvSIMD logs
Pierre Blanchard [Mon, 9 Dec 2024 15:54:34 +0000 (15:54 +0000)] 
AArch64: Improve codegen in AdvSIMD logs

Remove spurious ADRP and a few MOVs.
Reduce memory access by using more indexed MLAs in polynomial.
Align notation so that algorithms are easier to compare.
Speedup on Neoverse V1 for log10 (8%), log (8.5%), and log2 (10%).
Update error threshold in AdvSIMD log (now matches SVE log).

7 months agoAArch64: Improve codegen in AdvSIMD pow
Pierre Blanchard [Mon, 9 Dec 2024 15:53:04 +0000 (15:53 +0000)] 
AArch64: Improve codegen in AdvSIMD pow

Remove spurious ADRP. Improve memory access by shuffling constants and
using more indexed MLAs.

A few more optimisation with no impact on accuracy
- force fmas contraction
- switch from shift-aided rint to rint instruction

Between 1 and 5% throughput improvement on Neoverse
V1 depending on benchmark.

7 months agos390x: Regenerated ULPs.
Stefan Liebler [Mon, 9 Dec 2024 09:25:24 +0000 (10:25 +0100)] 
s390x: Regenerated ULPs.

Needed after:
"Implement C23 cospi"
commit 0ae0af68d8fa3bf6cbe1e4f1de5929ff71de67b3
and
"Implement C23 sinpi"
commit 776938e8b8dcf2b59998979e91cc0f9db7d771a8
and
"Implement C23 tanpi"

7 months agohtl: move pthread_condattr_setpshared into libc.
gfleury [Tue, 26 Nov 2024 20:53:29 +0000 (22:53 +0200)] 
htl: move pthread_condattr_setpshared into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241126205329.2215295-8-gfleury@disroot.org>

7 months agohtl: move pthread_condattr_setclock into libc.
gfleury [Tue, 26 Nov 2024 20:53:28 +0000 (22:53 +0200)] 
htl: move pthread_condattr_setclock into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241126205329.2215295-7-gfleury@disroot.org>

7 months agohtl: move pthread_condattr_init into libc.
gfleury [Tue, 26 Nov 2024 20:53:27 +0000 (22:53 +0200)] 
htl: move pthread_condattr_init into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241126205329.2215295-6-gfleury@disroot.org>

7 months agohtl: move pthread_condattr_getpshared into libc.
gfleury [Tue, 26 Nov 2024 20:53:26 +0000 (22:53 +0200)] 
htl: move pthread_condattr_getpshared into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241126205329.2215295-5-gfleury@disroot.org>

7 months agohtl: move pthread_condattr_getclock into libc.
gfleury [Tue, 26 Nov 2024 20:53:25 +0000 (22:53 +0200)] 
htl: move pthread_condattr_getclock into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241126205329.2215295-4-gfleury@disroot.org>

7 months agohtl: move __pthread_default_condattr into libc.
gfleury [Tue, 26 Nov 2024 20:53:24 +0000 (22:53 +0200)] 
htl: move __pthread_default_condattr into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241126205329.2215295-3-gfleury@disroot.org>

7 months agohtl: move pthread_condattr_destroy into libc.
gfleury [Tue, 26 Nov 2024 20:53:23 +0000 (22:53 +0200)] 
htl: move pthread_condattr_destroy into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241126205329.2215295-2-gfleury@disroot.org>

7 months agomath: Add sinpi,cospi,tanpi sparc64 ulps
Andreas K. Hüttel [Sun, 8 Dec 2024 21:01:51 +0000 (22:01 +0100)] 
math: Add sinpi,cospi,tanpi sparc64 ulps

Linux catbus 6.1.112 #1 SMP Sun Oct 13 10:52:08 PDT 2024 sparc64 sun4v UltraSparc T5 (Niagara5) GNU/Linux

gcc (Gentoo 13.3.1_p20240614 p17) 13.3.1 20240614

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agomath: Add tanpi aarch64 ulps
Andreas K. Hüttel [Sun, 8 Dec 2024 17:25:05 +0000 (18:25 +0100)] 
math: Add tanpi aarch64 ulps

Linux dola 5.15.169-gentoo-dist #1 SMP Wed Oct 23 06:25:30 -00 2024 aarch64 GNU/Linux
Vendor ID:                ARM
  Model name:             Neoverse-N1

gcc (Gentoo Hardened 13.3.1_p20241025 p1) 13.3.1 20241024

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
7 months agomath: Exclude internal math symbols for tests [BZ #32414]
H.J. Lu [Thu, 5 Dec 2024 00:39:44 +0000 (08:39 +0800)] 
math: Exclude internal math symbols for tests [BZ #32414]

Since internal tests don't have access to internal symbols in libm,
exclude them for internal tests.  Also make tst-strtod5 and tst-strtod5i
depend on $(libm) to support older versions of GCC which can't inline
copysign family functions.  This fixes BZ #32414.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
7 months agoRemove AC_SUBST(libc_cv_mtls_descriptor)
H.J. Lu [Fri, 6 Dec 2024 05:42:25 +0000 (13:42 +0800)] 
Remove AC_SUBST(libc_cv_mtls_descriptor)

Remove

AC_SUBST(libc_cv_mtls_descriptor)

since there is no @libc_cv_mtls_descriptor@ and there is

LIBC_CONFIG_VAR([have-mtls-descriptor], [$libc_cv_mtls_descriptor])

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
7 months agoImplement C23 tanpi
Joseph Myers [Thu, 5 Dec 2024 21:42:10 +0000 (21:42 +0000)] 
Implement C23 tanpi

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the tanpi functions (tan(pi*x)).

Tested for x86_64 and x86, and with build-many-glibcs.py.

7 months agoFix typo in elf/Makefile:postclean-generated
Joseph Myers [Thu, 5 Dec 2024 21:40:57 +0000 (21:40 +0000)] 
Fix typo in elf/Makefile:postclean-generated

The postclean-generated setting in elf/Makefile lists
$(objpfx)/dso-sort-tests-2.generated-makefile twice and
$(objpfx)/dso-sort-tests-1.generated-makefile not at all, which looks
like a typo; fix it to list each once.

Tested for x86_64.

7 months agomath: xfail some sinpi tests for ibm128-libgcc
Adhemerval Zanella [Thu, 5 Dec 2024 16:44:18 +0000 (16:44 +0000)] 
math: xfail some sinpi tests for ibm128-libgcc

On powerpc math/test-ibm128-sinpi shows:

testing long double (without inline functions)
Failure: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
Failure: Test: sinpi_downward (0x3.fffffffffffffffcp+108)
Result:
 is:          2.97479253223185882765417834495004e-15   0x1.acb679186c7b49a36c9ec63e110p-49
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  2.97479253223185882765417834495004e-15   0x1.acb679186c7b49a36c9ec63e110p-49
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  4.0000
Failure: Test: sinpi_downward (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          2.63250110604328276654475674742669e-15   0x1.7b6225fa8503a5a8c514f5c0208p-49
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  2.63250110604328276654475674742669e-15   0x1.7b6225fa8503a5a8c514f5c0208p-49
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  4.0000
Failure: Test: sinpi_towardzero (-0x3.fffffffffffffffcp+108)
Result:
 is:         -1.71856472474338625450766636956702e-14  -0x1.3596cf230d8f69346d93d8c3100p-46
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.71856472474338625450766636956702e-14   0x1.3596cf230d8f69346d93d8c3100p-46
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  3.0000
Failure: Test: sinpi_towardzero (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:         -9.73792846364428462525599942305655e-15  -0x1.5ed8897ea140e96a31453d6e580p-47
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  9.73792846364428462525599942305655e-15   0x1.5ed8897ea140e96a31453d6e580p-47
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  3.0000
Failure: Test: sinpi_towardzero (0x3.fffffffffffffffcp+108)
Result:
 is:          1.71856472474338625450766636956702e-14   0x1.3596cf230d8f69346d93d8c3100p-46
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  1.71856472474338625450766636956702e-14   0x1.3596cf230d8f69346d93d8c3100p-46
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  3.0000
Failure: Test: sinpi_towardzero (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.73792846364428462525599942305655e-15   0x1.5ed8897ea140e96a31453d6e580p-47
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  9.73792846364428462525599942305655e-15   0x1.5ed8897ea140e96a31453d6e580p-47
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  3.0000
Failure: Test: sinpi_upward (-0x3.fffffffffffffffcp+108)
Result:
 is:         -1.71856472474338625450766636956709e-14  -0x1.3596cf230d8f69346d93d8c3110p-46
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.71856472474338625450766636956710e-14   0x1.3596cf230d8f69346d93d8c3110p-46
 ulp       :  inf
 max.ulp   :  4.0000
Failure: Test: sinpi_upward (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:         -9.73792846364428462525599942305708e-15  -0x1.5ed8897ea140e96a31453d6e598p-47
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  9.73792846364428462525599942305709e-15   0x1.5ed8897ea140e96a31453d6e598p-47
 ulp       :  inf
 max.ulp   :  4.0000
Failure: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0

7 months agomath: xfail some cospi tests for ibm128-libgcc
Adhemerval Zanella [Thu, 5 Dec 2024 16:36:21 +0000 (16:36 +0000)] 
math: xfail some cospi tests for ibm128-libgcc

On powerpc math/test-ibm128-cospi shows:

testing long double (without inline functions)
Failure: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
Failure: Test: cospi_downward (0x3.fffffffffffffffcp+108)
Result:
 is:          9.99999999999999999999999999995574e-01   0x1.ffffffffffffffffffffffff4c8p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  4.42501664022411309598141492088312e-30   0x1.670000000000000000000000000p-98
 ulp       :  179.5000
 max.ulp   :  4.0000
Failure: Test: cospi_downward (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.99999999999999999999999999996524e-01   0x1.ffffffffffffffffffffffff730p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  3.47591836363008326759542899077727e-30   0x1.1a0000000000000000000000000p-98
 ulp       :  141.0000
 max.ulp   :  4.0000
Failure: Test: cospi_towardzero (-0x3.fffffffffffffffcp+108)
Result:
 is:          9.99999999999999999999999999852310e-01   0x1.ffffffffffffffffffffffe8990p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.47689552599346303944427057331536e-28   0x1.767000000000000000000000000p-93
 ulp       :  5991.0000
 max.ulp   :  4.0000
Failure: Test: cospi_towardzero (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.99999999999999999999999999952569e-01   0x1.fffffffffffffffffffffff87c0p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  4.74302619264133348003801799876275e-29   0x1.e10000000000000000000000000p-95
 ulp       :  1924.0000
 max.ulp   :  4.0000
Failure: Test: cospi_towardzero (0x3.fffffffffffffffcp+108)
Result:
 is:          9.99999999999999999999999999852310e-01   0x1.ffffffffffffffffffffffe8990p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.47689552599346303944427057331536e-28   0x1.767000000000000000000000000p-93
 ulp       :  5991.0000
 max.ulp   :  4.0000
Failure: Test: cospi_towardzero (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.99999999999999999999999999952569e-01   0x1.fffffffffffffffffffffff87c0p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  4.74302619264133348003801799876275e-29   0x1.e10000000000000000000000000p-95
 ulp       :  1924.0000
 max.ulp   :  4.0000
Failure: Test: cospi_upward (-0x3.fffffffffffffffcp+108)
Result:
 is:          9.99999999999999999999999999852323e-01   0x1.ffffffffffffffffffffffe899bp-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.47673235656615530277812119019587e-28   0x1.766568e20369c00000000000000p-93
 ulp       :  5990.3382
 max.ulp   :  4.0000
Failure: Test: cospi_upward (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.99999999999999999999999999952583e-01   0x1.fffffffffffffffffffffff87cbp-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  4.74136253815267677203679334037676e-29   0x1.e0d4cf1e9076600000000000000p-95
 ulp       :  1923.3252
 max.ulp   :  4.0000
Failure: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0

7 months agopowerpc: Update ulps
Adhemerval Zanella [Thu, 5 Dec 2024 16:22:04 +0000 (13:22 -0300)] 
powerpc: Update ulps

From 'Implement C23 cospi' (0ae0af68d8fa3bf6cbe1e4f1de5929ff71de67b3)
and 'Implement C23 sinpi' (776938e8b8dcf2b59998979e91cc0f9db7d771a8).

7 months agoAArch64: Update libm-test-ulps
Wilco Dijkstra [Thu, 5 Dec 2024 16:18:02 +0000 (16:18 +0000)] 
AArch64: Update libm-test-ulps

Add sinpi/cospi.

7 months agoi686: Update libm-test-ulps
H.J. Lu [Thu, 5 Dec 2024 01:25:45 +0000 (09:25 +0800)] 
i686: Update libm-test-ulps

Update i686 libm-test-ulps to fix

FAIL: math/test-float64x-cospi
FAIL: math/test-float64x-sinpi
FAIL: math/test-ldouble-cospi
FAIL: math/test-ldouble-sinpi

when building glibc with GCC 7.4.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agox86-64: Update libm-test-ulps
H.J. Lu [Thu, 5 Dec 2024 00:57:53 +0000 (08:57 +0800)] 
x86-64: Update libm-test-ulps

Update x86-64 libm-test-ulps to fix

FAIL: math/test-float64x-cospi
FAIL: math/test-float64x-exp2m1
FAIL: math/test-float64x-sinpi
FAIL: math/test-ldouble-cospi
FAIL: math/test-ldouble-exp2m1
FAIL: math/test-ldouble-sinpi

when building glibc with GCC 7.4.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoUse M_LIT in place of M_MLIT for literals
Joseph Myers [Thu, 5 Dec 2024 10:12:09 +0000 (10:12 +0000)] 
Use M_LIT in place of M_MLIT for literals

This should fix the reported issue building cospi and sinpi with GCC 6.

Tested for x86_64 (not with GCC 6).

7 months agoAdd further test of TLS
Joseph Myers [Thu, 5 Dec 2024 09:53:47 +0000 (09:53 +0000)] 
Add further test of TLS

Add an additional test of TLS variables, with different alignment,
accessed from different modules.  The idea of the alignment test is
similar to tst-tlsalign and the same code is shared for setting up
test variables, but unlike the tst-tlsalign code, there are multiple
threads and variables are accessed from multiple objects to verify
that they get a consistent notion of the address of an object within a
thread.  Threads are repeatedly created and shut down to verify proper
initialization in each new thread.  The test is also repeated with TLS
descriptors when supported.  (However, only initial-exec TLS is
covered in this test.)

Tested for x86_64.

7 months agohurd: Protect against servers returning bogus read/write lengths
Sergey Bugaev [Wed, 4 Dec 2024 11:29:15 +0000 (14:29 +0300)] 
hurd: Protect against servers returning bogus read/write lengths

There already was a branch checking for this case in _hurd_fd_read ()
when the data is returned out-of-line. Do the same for inline data, as
well as for _hurd_fd_write (). It's also not possible for the length to
be negative, since it's stored in an unsigned integer.

Not verifying the returned length can confuse the callers who assume
the returned length is always reasonable. This manifested as libzstd
test suite failing on writes to /dev/zero, even though the write () call
appeared to succeed. In fact, the zero store backing /dev/zero was
returning a larger written length than the size actually submitted to
it, which is a separate bug to be fixed on the Hurd side. With this
patch, EGRATUITOUS is now propagated to the caller.

Reported-by: Diego Nieto Cid <dnietoc@gmail.com>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20241204112915.540032-1-bugaevc@gmail.com>

7 months agoFix and sort variables in Makefiles
H.J. Lu [Thu, 5 Dec 2024 07:16:43 +0000 (15:16 +0800)] 
Fix and sort variables in Makefiles

Fix variables in Makefiles:

1. There is a tab, not a space, between "variable" and =, +=, :=.
2. The last entry doesn't have a trailing \.

and sort them.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoImplement C23 sinpi
Joseph Myers [Wed, 4 Dec 2024 20:04:04 +0000 (20:04 +0000)] 
Implement C23 sinpi

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the sinpi functions (sin(pi*x)).

Tested for x86_64 and x86, and with build-many-glibcs.py.

7 months agoImplement C23 cospi
Joseph Myers [Wed, 4 Dec 2024 10:20:44 +0000 (10:20 +0000)] 
Implement C23 cospi

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the cospi functions (cos(pi*x)).

Tested for x86_64 and x86, and with build-many-glibcs.py.

7 months agomalloc: Optimize small memory clearing for calloc
H.J. Lu [Tue, 26 Nov 2024 08:15:25 +0000 (16:15 +0800)] 
malloc: Optimize small memory clearing for calloc

Add calloc-clear-memory.h to clear memory size up to 36 bytes (72 bytes
on 64-bit targets) for calloc.  Use repeated stores with 1 branch, instead
of up to 3 branches.  On x86-64, it is faster than memset since calling
memset needs 1 indirect branch, 1 broadcast, and up to 4 branches.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
7 months agoUse Linux 6.12 in build-many-glibcs.py
Joseph Myers [Tue, 3 Dec 2024 03:11:22 +0000 (03:11 +0000)] 
Use Linux 6.12 in build-many-glibcs.py

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

7 months agolocale: More strictly implement ISO 8601 for Esperanto locale
Carmen Bianca BAKKER [Wed, 30 Oct 2024 12:26:48 +0000 (13:26 +0100)] 
locale: More strictly implement ISO 8601 for Esperanto locale

Esperanto, as an international language and a bit of a non-locale,
usually defaults to international consensus. In this commit, I make the
Esperanto locale more in line with ISO 8601 by setting the first day as
Monday, and the first week as containing January 4.

Closes: BZ #32323
Signed-off-by: Carmen Bianca BAKKER <carmen@carmenbianca.eu>
Reviewed-by: Mike FABIAN <mfabian@redhat.com>
7 months agoelf: Consolidate stackinfo.h
Adhemerval Zanella [Thu, 28 Nov 2024 17:36:42 +0000 (14:36 -0300)] 
elf: Consolidate stackinfo.h

And use sane default the generic implementation.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 months agomanual: Describe struct link_map, support link maps with dlinfo
Florian Weimer [Mon, 5 Aug 2024 14:01:12 +0000 (16:01 +0200)] 
manual: Describe struct link_map, support link maps with dlinfo

This does not describe how to use RTLD_DI_ORIGIN and l_name
to reconstruct a full path for the an object. The reason
is that I think we should not recommend further use of
RTLD_DI_ORIGIN due to its buffer overflow potential (bug 24298).
This should be covered by another dlinfo extension.  It would
also obsolete the need for the dladdr approach to obtain
the file name for the main executable.

Obtaining the lowest address from load segments in program
headers is quite clumsy and should be provided directly
via dlinfo.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
8 months agoAdd threaded test of sem_trywait
Joseph Myers [Fri, 29 Nov 2024 20:25:04 +0000 (20:25 +0000)] 
Add threaded test of sem_trywait

All the existing glibc tests of sem_trywait are single-threaded.  Add
one that calls sem_trywait and sem_post in separate threads.

Tested for x86_64.

8 months agoAdd test of ELF hash collisions
Joseph Myers [Fri, 29 Nov 2024 16:43:56 +0000 (16:43 +0000)] 
Add test of ELF hash collisions

Add tests that the dynamic linker works correctly with symbol names
involving hash collisions, for both choices of hash style (and
--hash-style=both as well).  I note that there weren't actually any
previous tests using --hash-style (so tests would only cover the
default linker configuration in that regard).  Also test symbol
versions involving hash collisions.

Tested for x86_64.

8 months agonptl: Add new test for pthread_spin_trylock
Sergey Kolosov [Wed, 6 Nov 2024 14:24:06 +0000 (15:24 +0100)] 
nptl: Add new test for pthread_spin_trylock

Add a threaded test for pthread_spin_trylock attempting to lock already
acquired spin lock and checking for correct return code.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 months agomalloc: send freed small chunks to smallbin
k4lizen [Fri, 29 Nov 2024 13:25:29 +0000 (13:25 +0000)] 
malloc: send freed small chunks to smallbin

Large chunks get added to the unsorted bin since
sorting them takes time, for small chunks the
benefit of adding them to the unsorted bin is
non-existant, actually hurting performance.

Splitting and malloc_consolidate still add small
chunks to unsorted, but we can hint the compiler
that that is a relatively rare occurance.
Benchmarking shows this to be consistently good.

Authored-by: k4lizen <k4lizen@proton.me>
Signed-off-by: Aleksa Siriški <sir@tmina.org>
8 months agoAArch64: Remove zva_128 from memset
Wilco Dijkstra [Mon, 25 Nov 2024 18:43:08 +0000 (18:43 +0000)] 
AArch64: Remove zva_128 from memset

Remove ZVA 128 support from memset - the new memset no longer
guarantees count >= 256, which can result in underflow and a
crash if ZVA size is 128 ([1]).  Since only one CPU uses a ZVA
size of 128 and its memcpy implementation was removed in commit
e162ab2bf1b82c40f29e1925986582fa07568ce8, remove this special
case too.

[1] https://sourceware.org/pipermail/libc-alpha/2024-November/161626.html

Reviewed-by: Andrew Pinski <quic_apinski@quicinc.com>
8 months agobenchtests: Add calloc test
Wangyang Guo [Fri, 29 Nov 2024 08:05:35 +0000 (16:05 +0800)] 
benchtests: Add calloc test

Two new benchmarks related to calloc added:
- bench-calloc-simple
- bench-calloc-thread
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
8 months agopthread_getcpuclockid: Add descriptive comment to smoke test
Siddhesh Poyarekar [Thu, 28 Nov 2024 11:30:40 +0000 (06:30 -0500)] 
pthread_getcpuclockid: Add descriptive comment to smoke test

Add a descriptive comment to the tst-pthread-cpuclockid-invalid test and
also drop pthread_getcpuclockid from the TODO-testing list since it now
has full coverage.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
8 months agoRemove nios2-linux-gnu
Adhemerval Zanella [Tue, 26 Nov 2024 19:34:00 +0000 (16:34 -0300)] 
Remove nios2-linux-gnu

GCC 15 (e876acab6cdd84bb2b32c98fc69fb0ba29c81153) and binutils
(e7a16d9fd65098045ef5959bf98d990f12314111) both removed all Nios II
support, and the architecture has been EOL'ed by the vendor.  The
kernel still has support, but without a proper compiler there
is no much sense in keep it on glibc.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 months agolibio: make _IO_least_marker static
Siddhesh Poyarekar [Thu, 28 Nov 2024 13:27:24 +0000 (08:27 -0500)] 
libio: make _IO_least_marker static

Trivial cleanup to limit _IO_least_marker so that it's clear that it is
unused outside of genops.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
8 months agomalloc: Avoid func call for tcache quick path in free()
Wangyang Guo [Tue, 26 Nov 2024 07:33:38 +0000 (15:33 +0800)] 
malloc: Avoid func call for tcache quick path in free()

Tcache is an important optimzation to accelerate memory free(), things
within this code path should be kept as simple as possible. This commit
try to remove the function call when free() invokes tcache code path by
inlining _int_free().

Result of bench-malloc-thread benchmark

Test Platform: Xeon-8380
Ratio: New / Original time_per_iteration (Lower is Better)

Threads#   | Ratio
-----------|------
1 thread   | 0.879
4 threads  | 0.874

The performance data shows it can improve bench-malloc-thread benchmark
by ~12% in both single thread and multi-thread scenario.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>