]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
5 years agoWIP alistair/rv32.wip
Alistair Francis [Fri, 17 Jan 2020 05:49:34 +0000 (21:49 -0800)] 
WIP

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
5 years agoCOVER: RISC-V glibc port for the 32-bit
Alistair Francis [Mon, 30 Dec 2019 21:33:07 +0000 (13:33 -0800)] 
COVER: RISC-V glibc port for the 32-bit

This patch set contains the glibc port for 32-bit RISC-V.

This is based on the original work from Zong Li [1] and has been
updated to use a 64-bit time_t.

This requires a 5.4+ kernel and all of the testing has been done using
the 5.4 stable kernel.

This is a list of the tests that are currently failing when running make
check:

FAIL: elf/tst-ldconfig-ld_so_conf-update
FAIL: iconvdata/tst-tables
FAIL: io/tst-lockf
FAIL: math/atest-exp
FAIL: math/atest-exp2
FAIL: math/atest-sincos
FAIL: math/test-float64-cacos
FAIL: math/test-ifloat32x-atan2
FAIL: misc/test-errno-linux
FAIL: nss/tst-nss-files-hosts-long
FAIL: resolv/tst-resolv-res_init-thread
FAIL: stdio-common/bug22
FAIL: stdlib/tst-strfrom
FAIL: stdlib/tst-strfrom-locale
FAIL: sunrpc/tst-udp-nonblocking
FAIL: sunrpc/tst-udp-timeout
FAIL: sysvipc/test-sysvmsg
FAIL: sysvipc/test-sysvsem

---Links---
1: https://sourceware.org/ml/libc-alpha/2018-07/msg00892.html

The latest version of my work can be found here: https://github.com/alistair23/glibc/tree/alistair/rv32.next

This specific version can be found here: https://github.com/alistair23/glibc/tree/alistair/rv32.rfc6

---Changelog---
RFC v6:
 - Rebase on top of accetpted patches
 - Fix issues so that the tests actually run
RFC v5:
 - Hopefully finally get the correct layout for the *64 syscalls
 - Sort out the Changelog
RFC v4:
 - Continue to fix things that weren't working
 - Update the coding style to match glibc
 - Update the __ASSUME_TIME64_SYSCALLS work to better match Lukasz's
 work
RFC v3:
 - Remove all "Hack" patches
 - Incorporate upstream comments
 - Ensure we don't break RV64
 - Lot's more testing and fixes
RFC v2:
 - Add Lukasz's patches
 - Update the non HACK syscalls after feedback
 - define __ASSUME_TIME64_SYSCALLS and __ASSUME_RLIM64_SYSCALLS
 - Remove lockf64.c
 - Other smaller changes from RFC v1

5 years agoAdd RISC-V 32-bit target to build-many-glibcs.py
Zong Li [Fri, 30 Nov 2018 09:18:40 +0000 (17:18 +0800)] 
Add RISC-V 32-bit target to build-many-glibcs.py

Support building three variant of 32 bit RISC-V glibc as follows:
- riscv32-linux-gnu-rv32imac-ilp32
- riscv32-linux-gnu-rv32imafdc-ilp32
- riscv32-linux-gnu-rv32imafdc-ilp32d

5 years agoDocumentation for the RISC-V 32-bit port
Zong Li [Fri, 30 Nov 2018 09:13:12 +0000 (17:13 +0800)] 
Documentation for the RISC-V 32-bit port

There is already RISC-V 64-bit port information in the documentation.
Let's add some documentation entries for the RISC-V 32-bit as well.

5 years agoRISC-V: Add rv32 path to RTLDLIST in ldd
Zong Li [Tue, 10 Sep 2019 04:35:50 +0000 (21:35 -0700)] 
RISC-V: Add rv32 path to RTLDLIST in ldd

5 years agoriscv32: Specify the arch_minimum_kernel as 5.4
Alistair Francis [Sat, 21 Dec 2019 02:29:42 +0000 (18:29 -0800)] 
riscv32: Specify the arch_minimum_kernel as 5.4

5 years agoRISC-V: Build Infastructure for 32-bit
Zong Li [Fri, 30 Nov 2018 09:18:00 +0000 (17:18 +0800)] 
RISC-V: Build Infastructure for 32-bit

This patch lays out the top-level orginazition of the RISC-V 32-bit port. It
contains all the Implies files as well as various other fragments of
build infastructure for the RISC-V 32-bit port.

5 years agoRISC-V: Fix llrint and llround missing exceptions on RV32
Zong Li [Fri, 30 Nov 2018 09:18:20 +0000 (17:18 +0800)] 
RISC-V: Fix llrint and llround missing exceptions on RV32

Similar to the fix for MIPS, ARM and S/390, RV32 is missing
correct exception on overflow from llrint and llround functions because
cast from floating-point types to long long do not result in correct
exceptions on overflow.

5 years agoRISC-V: Add the RV32 libm-test-ulps
Alistair Francis [Sat, 4 Jan 2020 01:56:50 +0000 (17:56 -0800)] 
RISC-V: Add the RV32 libm-test-ulps

Add a libm-test-ulps for RV32, generated by running `make regen-ulps`.
This is different to the RV64 one.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
5 years agoRISC-V: Add ABI lists
Alistair Francis [Fri, 15 Nov 2019 15:34:37 +0000 (07:34 -0800)] 
RISC-V: Add ABI lists

Use the check-api and update-abi to generate the abilist for rv32.

5 years agoRISC-V: Hard float support for 32-bit
Zong Li [Fri, 30 Nov 2018 09:16:38 +0000 (17:16 +0800)] 
RISC-V: Hard float support for 32-bit

This patch contains hardware floating-point support for the RV32IF and
RV32IFD

5 years agoRISC-V: The ABI implementation for the 32-bit
Zong Li [Fri, 30 Nov 2018 09:16:18 +0000 (17:16 +0800)] 
RISC-V: The ABI implementation for the 32-bit

This patch adds the ABI implementation about 32 bit version. It contains
the Linux-specific and RISC-V architecture code, I've collected here.

5 years agoRISC-V: Add arch-syscall.h for RV32
Alistair Francis [Thu, 2 Jan 2020 19:38:27 +0000 (11:38 -0800)] 
RISC-V: Add arch-syscall.h for RV32

5 years agoRISC-V: Add path of library directories for the 32-bit
Zong Li [Fri, 30 Nov 2018 09:15:44 +0000 (17:15 +0800)] 
RISC-V: Add path of library directories for the 32-bit

For the recommand of 64 bit version, we add the libraries path of 32 bit
in this patch.

The status of RV32 binaries under RV64 kernels is that the ISA
optionally supports having different XLEN for user and supervisor modes,
but AFAIK there's no silicon that implements this feature, and the Linux
kernel doesn't support it yet.

For the recommand of 64 bit version, we add the libraries path of 32 bit
in this patch. This includes a fix to avoid an out of bound array check
when building with GCC 8.2.

5 years agoRISC-V: Support dynamic loader for the 32-bit
Zong Li [Fri, 30 Nov 2018 09:14:35 +0000 (17:14 +0800)] 
RISC-V: Support dynamic loader for the 32-bit

Add the LD_SO_ABI definition for RISC-V 32-bit.

5 years agoRISC-V: Add socket-constants.h for RV32
Alistair Francis [Mon, 11 Nov 2019 23:11:04 +0000 (15:11 -0800)] 
RISC-V: Add socket-constants.h for RV32

Add the latest versionf of the socket-constants.h based on new Linux

5 years agoRISC-V: Add support for 32-bit vDSO calls
Alistair Francis [Wed, 18 Sep 2019 15:41:59 +0000 (08:41 -0700)] 
RISC-V: Add support for 32-bit vDSO calls

5 years agoRISC-V: Define __NR_* as __NR_*_time64/64 for 32-bit
Alistair Francis [Tue, 25 Jun 2019 23:32:38 +0000 (16:32 -0700)] 
RISC-V: Define __NR_* as __NR_*_time64/64 for 32-bit

5 years agoRISC-V: Use 64-bit time_t and off_t for RV32 and RV64
Alistair Francis [Fri, 21 Jun 2019 18:31:56 +0000 (11:31 -0700)] 
RISC-V: Use 64-bit time_t and off_t for RV32 and RV64

Using the original glibc headers under bits/ let's make small
modifications to use 64-bit time_t and off_t for both RV32 and RV64.

For the typesizes.h, here are justifications for the changes from the
generic version (based on Arnd's very helpful feedback):
-  All the !__USE_FILE_OFFSET64  types (__off_t, __ino_t, __rlim_t, ...) are
  changed to match the 64-bit replacements.

- __time_t is defined to 64 bit, but no __time64_t is added. This makes sense
  as we don't have the time64 support for other 32-bit architectures yet, and
  it will be easy to change when that happens.

- __suseconds_t is 64-bit. This matches what we use the kernel ABI for the
  few drivers that are relying on 'struct timeval' input arguments in
  ioctl, as well as the adjtimex system call. It means that timeval has to
  be defined without the   padding, unlike timespec, which needs padding.

5 years agolinux: Use 32-bit time_t for rusage
Alistair Francis [Mon, 23 Dec 2019 21:26:50 +0000 (13:26 -0800)] 
linux: Use 32-bit time_t for rusage

The Linux kernel expects rusage to use a 32-bit time_t, even on archs
with a 64-bit time_t (like RV32). To address this let's convert
rusage to/from 32-bit and 64-bit to ensure the kernel always gets
a 32-bit time_t.

This means that all 32-bit architectures with a 64-bit time_t will be
able to use this generic implementation.

This code is based on similar code in alpha, but adjusted to pass the
32-bit time_t to the kernel.

We can't directly call __wait4 as it expects a struct rusage but we have
to pass in and use a struct rusage32. The same appies to __getrusage.

5 years agolinux: Use 32-bit time_t for itimerval
Alistair Francis [Mon, 23 Dec 2019 19:45:01 +0000 (11:45 -0800)] 
linux: Use 32-bit time_t for itimerval

The Linux kernel expects itimerval to use a 32-bit time_t, even on archs
with a 64-bit time_t (like RV32). To address this let's convert
itimerval to/from 32-bit and 64-bit to ensure the kernel always gets
a 32-bit time_t.

This means that all 32-bit architectures with a 64-bit time_t will be
able to use this generic implementation.

This code is based on similar code in alpha, but adjusted to pass the
32-bit time_t to the kernel.

We can't directly call the __getitimer/__setitimer functions as they
expect a struct itimerval but we need to pass in a struct itimerval32.

5 years agotime: Add a timeval with a long tv_sec and tv_usec
Alistair Francis [Fri, 27 Dec 2019 17:07:40 +0000 (09:07 -0800)] 
time: Add a timeval with a long tv_sec and tv_usec

On y2038 safe 32-bit systems the Linux kernel expects itimerval to
use a 32-bit time_t, even though the other time_t's are 64-bit. To
address this let's add a timeval_long struct to be used internally.

5 years agotst-clone3: Use __NR_futex_time64 if we don't have __NR_futex
Alistair Francis [Mon, 11 Nov 2019 23:07:19 +0000 (15:07 -0800)] 
tst-clone3: Use __NR_futex_time64 if we don't have __NR_futex

We can't include sysdep.h in the test case (it introduces lots of
strange failures) so __NR_futex isn't redifined to __NR_futex_time64 by
64-bit time_t 32-bit archs (y2038 safe).

To allow the test to pass let's just do the __NR_futex_time64 syscall if
we don't have __NR_futex defined.

5 years agoConvert all Python scripts to Python 3
Alistair Francis [Sat, 4 Jan 2020 18:03:17 +0000 (10:03 -0800)] 
Convert all Python scripts to Python 3

Convert all of the Python scripts in tree to explicity use Python 3.

I have not explicity tested all of the scripts. Makefiles generally
explicitly use $(PYTHON) so the scripts should already support Python3.

5 years agohtl: Add internal version of __pthread_mutex_timedlock
Samuel Thibault [Mon, 13 Jan 2020 19:41:07 +0000 (20:41 +0100)] 
htl: Add internal version of __pthread_mutex_timedlock

The C11 threads implementation will need it.

5 years agohtl: Avoid crashing when passed invalid pthread_t values
Samuel Thibault [Mon, 13 Jan 2020 18:41:57 +0000 (19:41 +0100)] 
htl: Avoid crashing when passed invalid pthread_t values

5 years agoUpdate build-many-glibcs.py for GCC move to git.
Joseph Myers [Mon, 13 Jan 2020 16:32:57 +0000 (16:32 +0000)] 
Update build-many-glibcs.py for GCC move to git.

This patch updates build-many-glibcs.py for the move of GCC to git,
teaching it to do the initial checkout from git, to replace an SVN
checkout with a git one if --replace-sources is used, and to get the
commit identifier from a git checkout after updating it.

5 years agoFix "elf: Add tst-ldconfig-ld_so_conf-update test" on 32bit.
Stefan Liebler [Mon, 13 Jan 2020 10:06:41 +0000 (11:06 +0100)] 
Fix "elf: Add tst-ldconfig-ld_so_conf-update test" on 32bit.

This new test was introduced with recent commit
591236f1a33f11cc65ccf009d997071ba853e186.
If run on 32bit, it fails while renaming tst-ldconfig-ld-mod.so as there is no
/usr/lib64 directory. This patch is constructing the file name with help of
support_libdir_prefix.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agohtl: Avoid exposing unixoid functions
Samuel Thibault [Mon, 13 Jan 2020 00:33:21 +0000 (01:33 +0100)] 
htl: Avoid exposing unixoid functions

C11 threads should not expose them.

5 years agohtl: Add type sizes in bits/pthreadtypes-arch.h and check them
Samuel Thibault [Mon, 13 Jan 2020 00:17:07 +0000 (01:17 +0100)] 
htl: Add type sizes in bits/pthreadtypes-arch.h and check them

5 years agohtl: Add internal versions of functions used by C11 threads
Samuel Thibault [Sun, 12 Jan 2020 23:47:19 +0000 (00:47 +0100)] 
htl: Add internal versions of functions used by C11 threads

The C11 threads implementation needs to call pthread_join and
pthread_key_delete without exposing them.

5 years agoUpdate timezone/README
Paul Eggert [Fri, 10 Jan 2020 07:00:25 +0000 (23:00 -0800)] 
Update timezone/README

* timezone/version: New file, also taken from tzcode2018i.
* timezone/README: Reword so that people needn't paw through
old ChangeLog files to see which version we're using, a process
that is error-prone.  Update an obsolescent URL.

5 years ago elf: Add tst-ldconfig-ld_so_conf-update test
Alexandra Hájková [Thu, 9 Jan 2020 19:44:34 +0000 (20:44 +0100)] 
 elf: Add tst-ldconfig-ld_so_conf-update test

 Test ldconfig after /etc/ld.so.conf update and verify a running process
 observes changes to /etc/ld.so.cache.
 The test uses the test-in-container framework.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
5 years agoRevise NEWS description of changes to gettimeofday etc.
Zack Weinberg [Wed, 8 Jan 2020 20:23:12 +0000 (15:23 -0500)] 
Revise NEWS description of changes to gettimeofday etc.

Mostly English grammar and style improvements.  The bullet list is
reorganized a little for clarity.  The details of exactly which
Linux-based ports still report system-wide time zone information
from gettimeofday has been removed, as this is not intended to be
something people should rely on.

Also clarify the deprecation of older SPARC ISAs, based on the fact
that “SPARC version 7” is actually the very first version of the SPARC
ISA (Sun Microsystems was very fond of letting the marketing
department pick version numbers).

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoDrop dependency of dist target on ChangeLog
Siddhesh Poyarekar [Wed, 8 Jan 2020 08:48:49 +0000 (14:18 +0530)] 
Drop dependency of dist target on ChangeLog

We no longer write manual ChangeLog entries since they are
auto-generated at release time.  Drop dependency of the `make dist`
target on the file and document the fact that the latest ChangeLog
entries can be read in the highest numbered ChangeLog.N file in
ChangeLog.old.

The ChangeLog.old/ChangeLog.20 file for 2.31 will thus be generated
just before tagging a release.

Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
5 years agoMIPS: Fix circular definition of __LDBL_MANT_DIG__ in ieee754.h
Zack Weinberg [Wed, 8 Jan 2020 19:28:23 +0000 (14:28 -0500)] 
MIPS: Fix circular definition of __LDBL_MANT_DIG__ in ieee754.h

In commit aa706e13f4bfdf32a27c498902edf4f6006e433e,
sysdeps/mips/ieee754/ieee754.h was changed to use GCC’s predefined
macro __LDBL_MANT_DIG__, instead of including <float.h> and using
LDBL_MANT_DIG (and therefore polluting the user namespace with all of
the macros defined in float.h).  In order to support compilers that
don’t provide __LDBL_MANT_DIG__, there is a fallback #if block which
was supposed to include <float.h> and then define __LDBL_MANT_DIG__ to
LDBL_MANT_DIG.  However, at some point during the development of the
patch, a typo was introduced, causing the fallback block to define
__LDBL_MANT_DIG__ to expand to __LDBL_MANT_DIG__.

Correct this typo.

5 years agosl_SI locale: Use "." as the thousands separator (bug 25233)
Rafał Lużyński [Fri, 3 Jan 2020 11:11:20 +0000 (12:11 +0100)] 
sl_SI locale: Use "." as the thousands separator (bug 25233)

This is correct according to CLDR [1] and Florian Weimer's quick
research. [2]

[1] https://st.unicode.org/cldr-apps/v#/sl/Symbols/
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=25233#c0

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoFix formatting of ChangeLog ouput
Siddhesh Poyarekar [Tue, 7 Jan 2020 04:25:03 +0000 (09:55 +0530)] 
Fix formatting of ChangeLog ouput

Add another newline when the number of files differing is too large.
This is typical for across-the-board changes such as the copyright
year update that happened recently.

5 years agohurd: Fix message reception for timer_thread
Samuel Thibault [Sun, 5 Jan 2020 17:09:13 +0000 (18:09 +0100)] 
hurd: Fix message reception for timer_thread

Without a proper size, we get MACH_RCV_TOO_LARGE instead of MACH_MSG_SUCCESS.

* sysdeps/mach/hurd/setitimer.c (timer_thread): Add return_code_type
field to received message, and set the receive size in __mach_msg call.

5 years agohtl: Add __errno_location and __h_errno_location
Samuel Thibault [Sat, 4 Jan 2020 18:37:53 +0000 (19:37 +0100)] 
htl: Add __errno_location and __h_errno_location

As explained on
https://sourceware.org/ml/libc-alpha/2020-01/msg00049.html
the presence of __errno_location in libpthread.so on GNU/Linux makes
libpthread getting linked in for libstdc++. This aligns on that behavior, to
avoid issues that only GNU/Hurd would get.

5 years agohtl: Move pthread_atfork to libc_nonshared.a
Samuel Thibault [Sat, 4 Jan 2020 17:53:23 +0000 (18:53 +0100)] 
htl: Move pthread_atfork to libc_nonshared.a

This follows bd60ce86520b ('nptl: Move pthread_atfork to libc_nonshared.a')
with the same rationale: there is no non-libpthread equivalent to be used
for making linking against libpthread optional.

libpthread_nonshared.a is unused after this, so remove it from the
build.

There is no ABI impact because pthread_atfork was implemented using
__register_atfork in libc even before this change.

pthread_atfork has to be a weak alias because pthread_* names are not
reserved in libc.

5 years agohtl: Drop common tcbhead_t definition
Samuel Thibault [Sat, 4 Jan 2020 17:52:00 +0000 (18:52 +0100)] 
htl: Drop common tcbhead_t definition

This would conflict when including pt-internal.h outside libpthread, while
we can actually just include <tls.h>

5 years agohtl: Use dso_handle.h
Samuel Thibault [Sat, 4 Jan 2020 16:21:22 +0000 (17:21 +0100)] 
htl: Use dso_handle.h

5 years agolinux: Optimize fallback 32-bit clock_getres
Adhemerval Zanella [Mon, 16 Dec 2019 16:50:57 +0000 (13:50 -0300)] 
linux: Optimize fallback 32-bit clock_getres

This patch avoid probing the __NR_clock_getttime64 syscall each time
__clock_gettime64 is issued on a kernel without 64 bit time support.
Once ENOSYS is obtained, only 32-bit clock_gettime are used.

The following snippet:

  clock_getres (CLOCK_REALTIME, &(struct timespec) { 0 });
  clock_getres (CLOCK_MONOTONIC, &(struct timespec) { 0 });
  clock_getres (CLOCK_BOOTTIME, &(struct timespec) { 0 });
  clock_getres (20, &(struct timespec) { 0 });

On a kernel without 64 bit time support issues the syscalls:

  syscall_0x196(0, 0xffb83330, [...]) = -1 ENOSYS (Function not implemented)
  clock_getres(CLOCK_REALTIME, {tv_sec=0, tv_nsec=1}) = 0
  clock_getres(CLOCK_MONOTONIC, {tv_sec=0, tv_nsec=1}) = 0
  clock_getres(CLOCK_BOOTTIME, {tv_sec=0, tv_nsec=1}) = 0

Checked on i686-linux-gnu on 4.15 kernel.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Add support for clock_getres64 vDSO
Adhemerval Zanella [Wed, 11 Dec 2019 19:39:01 +0000 (16:39 -0300)] 
linux: Add support for clock_getres64 vDSO

No architecture currently defines the vDSO symbol.  On archictures
with 64-bit time_t the HAVE_CLOCK_GETRES_VSYSCALL is renamed to
HAVE_CLOCK_GETRES64_VSYSCALL, it simplifies clock_gettime code.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Enable vDSO clock_gettime64 for mips
Adhemerval Zanella [Wed, 11 Dec 2019 14:19:41 +0000 (11:19 -0300)] 
linux: Enable vDSO clock_gettime64 for mips

It was added on Linux 5.4 (commit 1f66c45db3302).

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Enable vDSO clock_gettime64 for arm
Adhemerval Zanella [Wed, 11 Dec 2019 14:17:12 +0000 (11:17 -0300)] 
linux: Enable vDSO clock_gettime64 for arm

It was added on Linux 5.5 (commit 74d06efb9c2f9).

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Enable vDSO clock_gettime64 for i386
Adhemerval Zanella [Wed, 11 Dec 2019 14:15:21 +0000 (11:15 -0300)] 
linux: Enable vDSO clock_gettime64 for i386

It was added on Linux 5.3 (commit 22ca962288c0a).

Checked on i686-linux-gnu with 5.3.0 kernel.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Optimize fallback 32-bit clock_gettime
Adhemerval Zanella [Sat, 14 Dec 2019 13:05:44 +0000 (10:05 -0300)] 
linux: Optimize fallback 32-bit clock_gettime

This patch avoid probing the __NR_clock_getttime64 syscall each time
__clock_gettime64 is issued on a kernel without 64 bit time support.
Once ENOSYS is obtained, only 32-bit clock_gettime are used.

The following snippet:

  clock_gettime (CLOCK_REALTIME, &(struct timespec) { 0 });
  clock_gettime (CLOCK_MONOTONIC, &(struct timespec) { 0 });
  clock_gettime (CLOCK_BOOTTIME, &(struct timespec) { 0 });
  clock_gettime (20, &(struct timespec) { 0 });

On a kernel without 64 bit time support and with vDSO support results
on the following syscalls:

  syscall_0x193(0, 0xff87ba30, [...]) = -1 ENOSYS (Function not implemented)
  clock_gettime(CLOCK_BOOTTIME, {tv_sec=927082, tv_nsec=474382032}) = 0
  clock_gettime(0x14 /* CLOCK_??? */, 0xff87b9f8) = -1 EINVAL (Invalid argument)

While on a kernel without vDSO support:

  syscall_0x193(0, 0xbec95550, 0xb6ed2000, 0x1, 0xbec95550, 0) = -1 (errno 38)
  clock_gettime(CLOCK_REALTIME, {tv_sec=1576615930, tv_nsec=638250162}) = 0
  clock_gettime(CLOCK_MONOTONIC, {tv_sec=1665478, tv_nsec=638779620}) = 0
  clock_gettime(CLOCK_BOOTTIME, {tv_sec=1675418, tv_nsec=292932704}) = 0
  clock_gettime(0x14 /* CLOCK_??? */, 0xbec95530) = -1 EINVAL (Invalid argument)

Checked on i686-linux-gnu on 4.15 kernel and on a 5.3 kernel.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Add support for clock_gettime64 vDSO
Adhemerval Zanella [Wed, 11 Dec 2019 14:13:50 +0000 (11:13 -0300)] 
linux: Add support for clock_gettime64 vDSO

No architecture currently defines the vDSO symbol.  On architectures
with 64-bit time_t the HAVE_CLOCK_GETTIME_VSYSCALL is renamed to
HAVE_CLOCK_GETTIME64_VSYSCALL, it simplifies clock_gettime code.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoelf: Move vDSO setup to rtld (BZ#24967)
Adhemerval Zanella [Fri, 29 Nov 2019 13:44:59 +0000 (10:44 -0300)] 
elf: Move vDSO setup to rtld (BZ#24967)

This patch moves the vDSO setup from libc to loader code, just after
the vDSO link_map setup.  For static case the initialization
is moved to _dl_non_dynamic_init instead.

Instead of using the mangled pointer, the vDSO data is set as
attribute_relro (on _rtld_global_ro for shared or _dl_vdso_* for
static).  It is read-only even with partial relro.

It fixes BZ#24967 now that the vDSO pointer is setup earlier than
malloc interposition is called.

Also, vDSO calls should not be a problem for static dlopen as
indicated by BZ#20802.  The vDSO pointer would be zero-initialized
and the syscall will be issued instead.

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu, powerpc64-linux-gnu,
powerpc-linux-gnu, s390x-linux-gnu, sparc64-linux-gnu, and
sparcv9-linux-gnu.  I also run some tests on mips.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoelf: Enable relro for static build
Adhemerval Zanella [Fri, 29 Nov 2019 13:26:30 +0000 (10:26 -0300)] 
elf: Enable relro for static build

The code is similar to the one at elf/dl-reloc.c, where it checks for
the l_relro_size from the link_map (obtained from PT_GNU_RELRO header
from program headers) and calls_dl_protected_relro.

For testing I will use the ones proposed by Florian's patch
'elf: Add tests for working RELRO protection' [1].

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
aarch64-linux-gnu, s390x-linux-gnu, and sparc64-linux-gnu.  I also
check with --enable-static pie on x86_64-linux-gnu, i686-linux-gnu,
and aarch64-linux-gnu which seems the only architectures where
static PIE is actually working (as per 9d7a3741c9e, on
arm-linux-gnueabihf, powerpc64{le}-linux-gnu, and s390x-linux-gnu
I am seeing runtime issues not related to my patch).

[1] https://sourceware.org/ml/libc-alpha/2019-10/msg00059.html

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Consolidate time implementation
Adhemerval Zanella [Mon, 16 Dec 2019 12:58:32 +0000 (09:58 -0300)] 
linux: Consolidate time implementation

The IFUNC bypass to vDSO is used when USE_IFUNC_TIME is set.
Currently powerpc and x86 defines it.  Otherwise the generic
implementation is used, which calls clock_gettime.

Checked on powerpc64le-linux-gnu, powerpc64-linux-gnu,
powerpc-linux-gnu-power4, x86_64-linux-gnu, and i686-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Consolidate Linux gettimeofday
Adhemerval Zanella [Mon, 16 Dec 2019 12:45:55 +0000 (09:45 -0300)] 
linux: Consolidate Linux gettimeofday

The IFUNC bypass to vDSO is used when USE_IFUNC_GETTIMEOFDAY is set.
Currently aarch64, powerpc*, and x86 defines it.  Otherwise the
generic implementation is used, which calls clock_gettime.

Checked on aarch64-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu-power4, x86_64-linux-gnu,
and i686-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Update mips vDSO symbols
Adhemerval Zanella [Fri, 29 Nov 2019 12:22:50 +0000 (09:22 -0300)] 
linux: Update mips vDSO symbols

The clock_getres is a new implementation added on Linux 5.4
(abed3d826f2f).

Checked with a build against mips-linux-gnu and mips64-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Update x86 vDSO symbols
Adhemerval Zanella [Fri, 29 Nov 2019 12:14:08 +0000 (09:14 -0300)] 
linux: Update x86 vDSO symbols

Add the missing time and clock_getres vDSO symbol names on x86.
For time, the iFUNC already uses expected name so it affects only
the static build.

The clock_getres is a new implementation added on Linux 5.3
(f66501dc53e72).

Checked on x86-linux-gnu and i686-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoRemove vDSO support from make-syscall.sh
Adhemerval Zanella [Fri, 29 Nov 2019 19:28:46 +0000 (16:28 -0300)] 
Remove vDSO support from make-syscall.sh

The auto-generated vDSO call shows some issues:

  - It requires sync the auto-generated C file with current glibc
    implementation;
  - It still uses symbol redirections hacks where libc-symbols.h
    provide macros that uses compiler builtins
    (libc_ifunc_redirected for instance);
  - It does not handle all required compiler handling
    (inhibit_stack_protector on iFUNC resolver).
  - No architecure uses it.

Checked with a build against all major ABIs.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agox86: Make x32 use x86 time implementation
Adhemerval Zanella [Fri, 29 Nov 2019 14:44:30 +0000 (11:44 -0300)] 
x86: Make x32 use x86 time implementation

This is the only use of auto-generation syscall which uses a vDSO
plus IFUNC and the current x86 generic implementation already covers
the expected semantic.

Checked on x86_64-linux-gnu-x32.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agolinux: Fix vDSO macros build with time64 interfaces
Adhemerval Zanella [Fri, 13 Dec 2019 20:30:15 +0000 (17:30 -0300)] 
linux: Fix vDSO macros build with time64 interfaces

As indicated on libc-help [1] the ec138c67cb commit broke 32-bit
builds when configured with --enable-kernel=5.1 or higher.  The
scenario 10 from [2] might also occur in this configuration and
INLINE_VSYSCALL will try to use the vDSO symbol and
HAVE_CLOCK_GETTIME64_VSYSCALL does not set HAVE_VSYSCALL prior its
usage.

Also, there is no easy way to just enable the code to use one
vDSO symbol since the macro INLINE_VSYSCALL is redefined if
HAVE_VSYSCALL is set.

Instead of adding more pre-processor handling and making the code
even more convoluted, this patch removes the requirement of defining
HAVE_VSYSCALL before including sysdep-vdso.h to enable vDSO usage.

The INLINE_VSYSCALL is now expected to be issued inside a
HAVE_*_VSYSCALL check, since it will try to use the internal vDSO
pointers.

Both clock_getres and clock_gettime vDSO code for time64_t were
removed since there is no vDSO setup code for the symbol (an
architecture can not set HAVE_CLOCK_GETTIME64_VSYSCALL).

Checked on i686-linux-gnu (default and with --enable-kernel=5.1),
x86_64-linux-gnu, aarch64-linux-gnu, and powerpc64le-linux-gnu.
I also checked against a build to mips64-linux-gnu and
sparc64-linux-gnu.

[1] https://sourceware.org/ml/libc-help/2019-12/msg00014.html
[2] https://sourceware.org/ml/libc-alpha/2019-12/msg00142.html

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoLinux: Fix clock_nanosleep time64 check
Adhemerval Zanella [Thu, 2 Jan 2020 18:39:12 +0000 (15:39 -0300)] 
Linux: Fix clock_nanosleep time64 check

The result of INTERNAL_SYSCALL_CANCEL should be checked with
macros INTERNAL_SYSCALL_ERROR_P and INTERNAL_SYSCALL_ERRNO instead
of comparing the result directly.

Checked on powerpc-linux-gnu.

5 years agoAdd libm_alias_finite for _finite symbols
Wilco Dijkstra [Tue, 16 Jul 2019 15:17:22 +0000 (12:17 -0300)] 
Add libm_alias_finite for _finite symbols

This patch adds a new macro, libm_alias_finite, to define all _finite
symbol.  It sets all _finite symbol as compat symbol based on its first
version (obtained from the definition at built generated first-versions.h).

The <fn>f128_finite symbols were introduced in GLIBC 2.26 and so need
special treatment in code that is shared between long double and float128.
It is done by adding a list, similar to internal symbol redifinition,
on sysdeps/ieee754/float128/float128_private.h.

Alpha also needs some tricky changes to ensure we still emit 2 compat
symbols for sqrt(f).

Passes buildmanyglibc.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoUpdate libc.pot for 2.31 release
Siddhesh Poyarekar [Thu, 2 Jan 2020 14:41:36 +0000 (20:11 +0530)] 
Update libc.pot for 2.31 release

5 years agoMultiple locales: Add date_fmt (bug 24054)
Rafał Lużyński [Mon, 30 Dec 2019 10:58:18 +0000 (11:58 +0100)] 
Multiple locales: Add date_fmt (bug 24054)

It is not specified what should be the content of d_t_fmt and date_fmt
but in the built-in C locale those fields have only one difference:
date_fmt contains "%Z" (the current time zone) while d_t_fmt does not.

For most of the locales this commit does the following operation:
copy d_t_fmt to date_fmt, and then remove "%Z" from d_t_fmt.
If "%Z" was originally missing from d_t_fmt add it to date_fmt.
It also corrects comments where necessary.

Exceptions:

* In bo_CN, dz_BT, and km_KH "%Z" has not been added to date_fmt because
  it was too difficult.  In these locales date_fmt has been set to the
  copy of d_t_fmt.
* In en_DK "%Z" has not been removed from d_t_fmt in order to preserve
  the conformance with the standard mentioned in the comment.

The command to identify and initially edit the locales that need the
update was:

    for i in `grep -lw d_t_fmt *`
    do
        if ! grep -qw date_fmt $i ; then
            awk '/d_t_fmt/ { print $0; gsub("d_t_fmt", "date_fmt"); } //{ print $0 }' < $i > $i.next
            mv $i.next $i
        fi
    done

and then each file was further edited manually.

5 years agobuild-many-glibcs.py: Fix “glibcs i686-gnu --strip”
Florian Weimer [Thu, 2 Jan 2020 09:18:42 +0000 (10:18 +0100)] 
build-many-glibcs.py: Fix “glibcs i686-gnu --strip”

Hurd uses an empty prefix, so the linker scripts end up in /lib, the
find command picked them up, and stripping them failed because they
are not ELF files.

5 years agoLinux: Remove pread/pread64, pwrite/pwrite64 kludges from <sysdep.h>
Florian Weimer [Thu, 2 Jan 2020 09:18:37 +0000 (10:18 +0100)] 
Linux: Remove pread/pread64, pwrite/pwrite64 kludges from <sysdep.h>

Since the switch away from auto-generated wrappers for these system
calls, the kludge is already included in the C source file of the
system call wrapper.

5 years agobuild-many-glibcs.py: Implement update-syscalls command
Florian Weimer [Thu, 2 Jan 2020 09:18:34 +0000 (10:18 +0100)] 
build-many-glibcs.py: Implement update-syscalls command

This command uses pre-built compilers to re-install the Linux headers
from the current sources into a temporary location and runs glibc's
“make update-syscalls-lists” against that.  This updates the glibc
source tree with the current system call numbers.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agobuild-many-glibcs.py: Introduce glibc build policy classes
Florian Weimer [Thu, 2 Jan 2020 09:18:31 +0000 (10:18 +0100)] 
build-many-glibcs.py: Introduce glibc build policy classes

The new classes GlibcPolicyForCompiler and GlibcPolicyForBuild allow
customization of the Glibc.build_glibc method, replacing the existing
for_compiler flag.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agobuild-many-glibcs.py: Introduce LinuxHeadersPolicyForBuild
Florian Weimer [Thu, 2 Jan 2020 09:18:26 +0000 (10:18 +0100)] 
build-many-glibcs.py: Introduce LinuxHeadersPolicyForBuild

And move install_linux_headers to the top level.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoLinux: Use system call tables during build
Florian Weimer [Thu, 2 Jan 2020 09:18:22 +0000 (10:18 +0100)] 
Linux: Use system call tables during build

Use <arch-syscall.h> instead of <asm/unistd.h> to obtain the system
call numbers.  A few direct includes of <asm/unistd.h> need to be
removed (if the system call numbers are already provided indirectly
by <sysdep.h>) or replaced with <sys/syscall.h>.

Current Linux headers for alpha define the required system call names,
so most of the _NR_* hacks are no longer needed.  For the 32-bit arm
architecture, eliminate the INTERNAL_SYSCALL_ARM macro, now that we
have regular system call names for cacheflush and set_tls.  There are
more such cleanup opportunities for other architectures, but these
cleanups are required to avoid macro redefinition errors during the
build.

For ia64, it is desirable to use <asm/break.h> directly to obtain
the break number for system calls (which is not a system call number
itself).  This requires replacing __BREAK_SYSCALL with
__IA64_BREAK_SYSCALL because the former is defined as an alias in
<asm/unistd.h>, but not in <asm/break.h>.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoLinux: Add tables with system call numbers
Florian Weimer [Thu, 2 Jan 2020 09:18:10 +0000 (10:18 +0100)] 
Linux: Add tables with system call numbers

The new tables are currently only used for consistency checks
with the installed kernel headers and the architecture-independent
system call names table.  They are based on Linux 5.4.

The goal is to use these architecture-specific tables to ensure
that system call wrappers are available irrespective of the version
of the installed kernel headers.

The tables are formatted in the form of C header files so that they
can be used directly in an #include directive, without external
preprocessing.  (External preprocessing of a plain table file
would introduce cross-subdirectory dependency issues.)  However,
the intent is that they can still be treated as tables and can be
processed by simple tools.

The irregular system call names on 32-bit arm add a complication.
The <fixup-asm-unistd.h> header is introduced to work around that,
and the system calls are listed under regular names in the
<arch-syscall.h> file.

A make target, update-syscalls-list, is added to patch the glibc
sources with data from the current kernel headers.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 years agoUpdate copyright dates not handled by scripts/update-copyrights.
Joseph Myers [Wed, 1 Jan 2020 00:21:22 +0000 (00:21 +0000)] 
Update copyright dates not handled by scripts/update-copyrights.

I've updated copyright dates in glibc for 2020.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.  As well as the usual annual
updates, mainly dates in --version output (minus libc.texinfo which
previously had to be handled manually but is now successfully updated
by update-copyrights), there is a fix to
sysdeps/unix/sysv/linux/powerpc/bits/termios-c_lflag.h where a typo in
the copyright notice meant it failed to be updated automatically.

Please remember to include 2020 in the dates for any new files added
in future (which means updating any existing uncommitted patches you
have that add new files to use the new copyright dates in them).

5 years agoUpdate copyright dates with scripts/update-copyrights.
Joseph Myers [Wed, 1 Jan 2020 00:14:33 +0000 (00:14 +0000)] 
Update copyright dates with scripts/update-copyrights.

5 years agoalpha: Set wait4 as cancellation entrypoint
Adhemerval Zanella [Fri, 27 Dec 2019 20:21:56 +0000 (17:21 -0300)] 
alpha: Set wait4 as cancellation entrypoint

Since both wait and waitpid are implemented on top of wait4.  It fixes
nptl/tst-cancel{x}{4,5,7}.

Checked on alpha-linux-gnu.

5 years agolv_LV locale: Correct the time part of d_t_fmt (bug 25324)
Rafał Lużyński [Mon, 30 Dec 2019 10:42:46 +0000 (11:42 +0100)] 
lv_LV locale: Correct the time part of d_t_fmt (bug 25324)

Currently d_t_fmt formats time as "plkst. %H un %M".  A quick Google
search says that "plkst." means "o’clock" and "un" means "and".
Also this format does not display seconds.

CLDR does not mention anything like that.  We have no reason to use
anything different than "%H:%M:%S".

5 years agokm_KH locale: Use "%M" instead of "m" in d_t_fmt (bug 25323)
Rafał Lużyński [Mon, 30 Dec 2019 10:28:37 +0000 (11:28 +0100)] 
km_KH locale: Use "%M" instead of "m" in d_t_fmt (bug 25323)

A quick analysis suggests that the original author meant "%M" (minutes
format specifier) instead of "m" which is just a literal "m" letter.

5 years agohurd: Global signal disposition
Jeremie Koenig [Sun, 29 Dec 2019 16:59:55 +0000 (17:59 +0100)] 
hurd: Global signal disposition

This adds _hurd_sigstate_set_global_rcv used by libpthread to enable
POSIX-confirming behavior of signals on a per-thread basis.

This also provides a sigstate destructor _hurd_sigstate_delete, and a
global process signal state, which needs to be locked and check when
global disposition is enabled, thus the addition of _hurd_sigstate_lock
_hurd_sigstate_actions _hurd_sigstate_pending _hurd_sigstate_unlock helpers.

This also updates all the glibc code accordingly.

This also drops support for get_int(INIT_SIGMASK), which did not make sense
any more since we do not have a single signal thread any more.

During fork/spawn, this also reinitializes the child global sigstate's
lock. That cures an issue that would very rarely cause a deadlock in the
child in fork, tries to unlock ss' critical section lock at the end of
fork.  This will typically (always?) be observed in /bin/sh, which is not
surprising as that is the foremost caller of fork.

To reproduce an intermediate state, add an endless loop if
_hurd_global_sigstate is locked after __proc_dostop (cast through
volatile); that is, while still being in the fork's parent process.

When that triggers (use the libtool testsuite), the signal thread has
already locked ss (which is _hurd_global_sigstate), and is stuck at
hurdsig.c:685 in post_signal, trying to lock _hurd_siglock (which the
main thread already has locked and keeps locked until after
__task_create).  This is the case that ss->thread == MACH_PORT_NULL, that
is, a global signal.  In the main thread, between __proc_dostop and
__task_create is the __thread_abort call on the signal thread which would
abort any current kernel operation (but leave ss locked).  Later in fork,
in the parent, when _hurd_siglock is unlocked in fork, the parent's
signal thread can proceed and will unlock eventually the global sigstate.
In the client, _hurd_siglock will likewise be unlocked, but the global
sigstate never will be, as the client's signal thread has been configured
to restart execution from _hurd_msgport_receive.  Thus, when the child
tries to unlock ss' critical section lock at the end of fork, it will
first lock the global sigstate, will spin trying to lock it, which can
never be successful, and we get our deadlock.

Options seem to be:

  * Move the locking of _hurd_siglock earlier in post_signal -- but that
    may generally impact performance, if this locking isn't generally
    needed anyway?

    On the other hand, would it actually make sense to wait here until we
    are not any longer in a critical section (which is meant to disable
    signal delivery anyway (but not for preempted signals?))?

  * Clear the global sigstate in the fork's child with the rationale that
    we're anyway restarting the signal thread from a clean state.  This
    has now been implemented.

Why has this problem not been observed before Jérémie's patches?  (Or has
it?  Perhaps even more rarely?)  In _S_msg_sig_post, the signal is now
posted to a *global receiver thread*, whereas previously it was posted to
the *designated signal-receiving thread*.  The latter one was in a
critical section in fork, so didn't try to handle the signal until after
leaving the critical section?  (Not completely analyzed and verified.)

Another question is what the signal is that is being received
during/around the time __proc_dostop executes.

5 years agohurd sendmsg: Fix warning on calling CMSG_*HDR
Samuel Thibault [Sun, 29 Dec 2019 16:47:52 +0000 (17:47 +0100)] 
hurd sendmsg: Fix warning on calling CMSG_*HDR

5 years agohurd: Signal code refactoring
Jeremie Koenig [Sun, 29 Dec 2019 16:18:04 +0000 (17:18 +0100)] 
hurd: Signal code refactoring

This should not change the current behavior, although this fixes a few
minor bugs which were made apparent in the process of global signal
disposition work:

- Split into more functions
- Scope variables more restrictively
- Split out inner functions
- refactor check_pending_signals
- make sigsuspend POSIX-conformant.
- fix uninitialized act value.

5 years agohurd: Add getcontext, makecontext, setcontext, swapcontext
Thomas Schwinge [Sun, 29 Dec 2019 15:04:51 +0000 (16:04 +0100)] 
hurd: Add getcontext, makecontext, setcontext, swapcontext

Adapted from the Linux x86 functions.

Not thoroughly tested, but manual testing as well as glibc tests look fine, and
manual -lpthread testing also looks fine (within the given bounds for a new
stack to be used with makecontext).

This has also been in use in Debian since 2013.

5 years agohurd: Support sending file descriptors over Unix sockets
Emilio Pozuelo Monfort [Sun, 29 Dec 2019 15:34:20 +0000 (16:34 +0100)] 
hurd: Support sending file descriptors over Unix sockets

5 years agoldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128
Gabriel F. T. Gomes [Tue, 10 Sep 2019 13:05:03 +0000 (08:05 -0500)] 
ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128

Some compiler versions, e.g. GCC 7, complain when -mlong-double-128 is
used together with -mabi=ibmlongdouble or -mabi=ieeelongdouble,
producing the following error message:

  cc1: error: ‘-mabi=ibmlongdouble’ requires ‘-mlong-double-128’

This patch removes -mlong-double-128 from the compilation lines that
explicitly request -mabi=*longdouble.

Tested for powerpc64le.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
5 years agoldbl-128ibm-compat: Compiler flags for stdio functions
Tulio Magno Quites Machado Filho [Mon, 30 Jul 2018 15:04:40 +0000 (12:04 -0300)] 
ldbl-128ibm-compat: Compiler flags for stdio functions

Some of the files that provide stdio.h and wchar.h functions have a
filename prefixed with 'io', such as 'iovsprintf.c'.  On platforms that
imply ldbl-128ibm-compat, these files must be compiled with the flag
-mabi=ibmlongdouble.  This patch adds this flag to their compilation.

Notice that this is not required for the other files that provide
similar functions, because filenames that are not prefixed with 'io'
have ldbl-128ibm-compat counterparts in the Makefile, which already adds
-mabi=ibmlongdouble to them.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
5 years agoDo not redirect calls to __GI_* symbols, when redirecting to *ieee128
Tulio Magno Quites Machado Filho [Sun, 20 Oct 2019 21:00:30 +0000 (16:00 -0500)] 
Do not redirect calls to __GI_* symbols, when redirecting to *ieee128

On platforms where long double has IEEE binary128 format as a third
option (initially, only powerpc64le), many exported functions are
redirected to their __*ieee128 equivalents.  This redirection is
provided by installed headers such as stdio-ldbl.h, and is supposed to
work correctly with user code.

However, during the build of glibc, similar redirections are employed,
in internal headers, such as include/stdio.h, in order to avoid extra
PLT entries.  These redirections conflict with the redirections to
__*ieee128, and must be avoided during the build.  This patch protects
the second redirections with a test for __LONG_DOUBLE_USES_FLOAT128, a
new macro that is defined to 1 when functions that deal with long double
typed values reuses the _Float128 implementation (this is currently only
true for powerpc64le).

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

Co-authored-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
5 years agoaarch64: add default memcpy version for kunpeng920
Xuelei Zhang [Fri, 27 Dec 2019 14:59:12 +0000 (11:59 -0300)] 
aarch64: add default memcpy version for kunpeng920

Checked on aarch64-linux-gnu.

5 years agoaarch64: ifunc rename for kunpeng
Xuelei Zhang [Fri, 27 Dec 2019 14:58:19 +0000 (11:58 -0300)] 
aarch64: ifunc rename for kunpeng

Rename ifunc for kunpeng to kunpeng920, and modify the corresponding
function files including IS_KUNPENG920 judgement.

Checked on aarch64-linux-gnu.

5 years agoaarch64: Modify error-shown comments for strcpy
Xuelei Zhang [Fri, 27 Dec 2019 14:57:24 +0000 (11:57 -0300)] 
aarch64: Modify error-shown comments for strcpy

Checked on aarch64-linux-gnu.

5 years agolinux: Consolidate sigprocmask
Adhemerval Zanella [Thu, 5 Dec 2019 11:03:21 +0000 (08:03 -0300)] 
linux: Consolidate sigprocmask

All architectures now uses the Linux generic implementation which
uses __NR_rt_sigprocmask.

Checked on x86_64-linux-gnu, sparc64-linux-gnu, ia64-linux-gnu,
s390x-linux-gnu, and alpha-linux-gnu.

5 years agoFix return code for __libc_signal_* functions
Adhemerval Zanella [Thu, 5 Dec 2019 17:56:06 +0000 (14:56 -0300)] 
Fix return code for __libc_signal_* functions

The functions do not fail regardless of the argument value.  Also, for
Linux the return value is not correct on some platforms due the missing
usage of INTERNAL_SYSCALL_ERROR_P / INTERNAL_SYSCALL_ERRNO macros.

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

5 years agonptl: Remove duplicate internal __SIZEOF_PTHREAD_MUTEX_T (BZ#25241)
Adhemerval Zanella [Thu, 26 Dec 2019 20:03:13 +0000 (17:03 -0300)] 
nptl: Remove duplicate internal __SIZEOF_PTHREAD_MUTEX_T (BZ#25241)

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

5 years agomnw_MM, my_MM, and shn_MM locales: Do not use %Op
Rafał Lużyński [Thu, 19 Dec 2019 20:57:55 +0000 (21:57 +0100)] 
mnw_MM, my_MM, and shn_MM locales: Do not use %Op

The "O" modifier does nothing when used with "%p" so let's better not
use it at all and replace "%Op" with "%p".

5 years agoAvoid compat symbols for totalorder in powerpc64le IEEE long double
Gabriel F. T. Gomes [Mon, 9 Sep 2019 17:59:46 +0000 (12:59 -0500)] 
Avoid compat symbols for totalorder in powerpc64le IEEE long double

On powerpc64le, the libm_alias_float128_other_r_ldbl macro is
used to create an alias between totalorderf128 and __totalorderlieee128,
as well as between the totalordermagf128 and __totalordermaglieee128.

However, the totalorder* and totalordermag* functions changed their
parameter type since commit ID 42760d764649 and got compat symbols for
their old versions.  With this change, the aforementioned macro would
create two conflicting aliases for __totalorderlieee128 and
__totalordermaglieee128.

This patch avoids the creation of the alias between the IEEE long double
symbols (__totalorderl*ieee128) and the compat symbols, because the IEEE
long double functions have never been exported thus don't need such
compat symbol.

Tested for powerpc64le.

Reviewed-by: Joseph Myers <joseph@codesourcery.com>
5 years agoldbl-128ibm-compat: Add *cvt functions
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:48:24 +0000 (11:48 -0300)] 
ldbl-128ibm-compat: Add *cvt functions

This patch adds IEEE long double versions of q*cvt* functions for
powerpc64le.  Unlike all other long double to/from string conversion
functions, these do not rely on internal functions that can take
floating-point numbers with different formats and act on them
accordingly, instead, the related files are rebuilt with the
-mabi=ieeelongdouble compiler flag set.

Having -mabi=ieeelongdouble passed to the compiler causes the object
files to be marked with a .gnu_attribute that is incompatible with the
.gnu_attribute in files built with -mabi=ibmlongdouble (the default).
The difference causes error messages similar to the following:

  ld: libc_pic.a(s_isinfl.os) uses IBM long double,
      libc_pic.a(ieee128-qefgcvt_r.os) uses IEEE long double.
  collect2: error: ld returned 1 exit status
  make[2]: *** [../Makerules:649: libc_pic.os] Error 1

Although this warning is useful in other situations, the library
actually needs to have functions with different long double formats, so
.gnu_attribute generation is explicitly disabled for these files with
the use of -mno-gnu-attribute.

Tested for powerpc64le on the branch that actually enables the
sysdeps/ieee754/ldbl-128ibm-compat for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
5 years agoRefactor *cvt functions implementation (2/2)
Gabriel F. T. Gomes [Tue, 26 Nov 2019 17:48:49 +0000 (14:48 -0300)] 
Refactor *cvt functions implementation (2/2)

This patch refactors the *cvt functions implementation in a way that
makes it easier to re-use them for implementing the IEEE long double on
powerpc64le.  By removing the macros that generate the function names
(APPEND combined with FUNC_PREFIX), the new code makes it easier to
define new function names, such as __qecvtieee128.

Tested that installed stripped binaries for all build-many-glibcs
targets remain identical before and after this patch.  Also tested for
powerpc64le and x86_64.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
5 years agoRefactor *cvt functions implementation (1/2)
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:48:08 +0000 (11:48 -0300)] 
Refactor *cvt functions implementation (1/2)

This patch refactors the *cvt functions implementation in a way that
makes it easier to re-use them for implementing the IEEE long double on
powerpc64le.  By splitting the implementation per se in one file
(efgcvt-template.c) and the alias definitions in others (e.g. efgcvt.c),
the new code makes it easier to define new function names, such as
__qecvtieee128.

Tested that installed stripped binaries for all build-many-glibcs
targets remain identical before and after this patch.  Also tested for
powerpc64le and x86_64.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
5 years agoAdd exception-based flags for wait4
Adhemerval Zanella [Fri, 20 Dec 2019 12:59:11 +0000 (09:59 -0300)] 
Add exception-based flags for wait4

It fixes the tst-cancelx4 and tst-cancelx5 on sparc{64,v9}.

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.

5 years agoaarch64: Optimized memset for Kunpeng processor.
Xuelei Zhang [Thu, 19 Dec 2019 15:26:33 +0000 (15:26 +0000)] 
aarch64: Optimized memset for Kunpeng processor.

Due to the branch prediction issue of Kunpeng processor, we found
memset_generic has poor performance on middle sizes setting, and so
we reconstructed the logic, expanded the loop by 4 times in set_long
to solve the problem, even when setting below 1K sizes have benefit.

Another change is that DZ_ZVA seems no work when setting zero, so we
discarded it and used set_long to set zero instead. Fewer branches and
predictions also make the zero case have slightly improvement.

Checked on aarch64-linux-gnu.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
5 years agoaarch64: Optimized strlen for strlen_asimd
Xuelei Zhang [Thu, 19 Dec 2019 13:41:40 +0000 (13:41 +0000)] 
aarch64: Optimized strlen for strlen_asimd

Optimize the strlen implementation by using vector operations and
loop unrolling in main loop.Compared to __strlen_generic,it reduces
latency of cases in bench-strlen by 7%~18% when the length of src
is greater than 128 bytes, with gains throughout the benchmark.

Checked on aarch64-linux-gnu.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
5 years agoaarch64: Add Huawei Kunpeng to tunable cpu list
Xuelei Zhang [Thu, 19 Dec 2019 14:55:06 +0000 (14:55 +0000)] 
aarch64: Add Huawei Kunpeng to tunable cpu list

Kunpeng processer is a 64-bit Arm-compatible CPU released by Huawei,
and we have already signed a copyright assignement with the FSF.

This patch adds its to cpu list, and related macro for IFUNC.

Checked on aarch64-linux-gnu.

Reviewed-by: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
5 years agoaarch64: Optimized implementation of memrchr
Xuelei Zhang [Thu, 19 Dec 2019 14:53:29 +0000 (14:53 +0000)] 
aarch64: Optimized implementation of memrchr

Considering the excellent performance of memchr.S on glibc 2.30, the
same algorithm is used to find chrin. Compared to memrchr.c, this
method with memrchr.S achieves an average performance improvement
of 58% based on benchtest and its extension cases.

Checked on aarch64-linux-gnu.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
5 years agoaarch64: Optimized implementation of strnlen
Xuelei Zhang [Thu, 19 Dec 2019 13:49:46 +0000 (13:49 +0000)] 
aarch64: Optimized implementation of strnlen

Optimize the strlen implementation by using vector operations and
loop unrooling in main loop. Compared to aarch64/strnlen.S, it
reduces latency of cases in bench-strnlen by 11%~24% when the length
of src is greater than 64 bytes, with gains throughout the benchmark.

Checked on aarch64-linux-gnu.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>