]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
4 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.

4 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.

4 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".

4 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.

4 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.

4 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

4 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.

4 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.

4 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

4 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>
4 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>
4 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>
4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

4 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".

4 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>
4 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>
4 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>
4 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>
4 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.

4 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>
4 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>
4 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>
4 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>
4 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>
4 years agoaarch64: Optimized implementation of strcpy
Xuelei Zhang [Thu, 19 Dec 2019 13:08:11 +0000 (13:08 +0000)] 
aarch64: Optimized implementation of strcpy

Optimize the strcpy implementation by using vector loads and operations
in main loop.Compared to aarch64/strcpy.S, it reduces latency of cases
in bench-strlen by 5%~18% 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>
4 years agoaarch64: Optimized implementation of memcmp
Xuelei Zhang [Thu, 19 Dec 2019 12:31:59 +0000 (12:31 +0000)] 
aarch64: Optimized implementation of memcmp

The loop body is expanded from a 16-byte comparison to a 64-byte
comparison, and the usage of ldp is replaced by the Post-index
mode to the Base plus offset mode. Hence, compare can faster 18%
around > 128 bytes in all.

Checked on aarch64-linux-gnu.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
4 years agoConsolidate wait3 implementations
Adhemerval Zanella [Thu, 14 Nov 2019 14:37:10 +0000 (11:37 -0300)] 
Consolidate wait3 implementations

The generic one calls wait4.

Checked on x86_64-linux-gnu.

4 years agoImplement waitpid in terms of wait4
Adhemerval Zanella [Wed, 13 Nov 2019 20:57:00 +0000 (17:57 -0300)] 
Implement waitpid in terms of wait4

This also consolidate all waitpid implementations.

Checked on x86_64-linux-gnu.

4 years agolinux: Use waitid on wait4 if __NR_wait4 is not defined
Adhemerval Zanella [Wed, 13 Nov 2019 20:45:13 +0000 (17:45 -0300)] 
linux: Use waitid on wait4 if __NR_wait4 is not defined

If the wait4 syscall is not available (such as y2038 safe 32-bit
systems) waitid should be used instead.  However prior Linux 5.4
waitid is not a full superset of other wait syscalls, since it
does not include support for waiting for the current process group.

It is possible to emulate wait4 by issuing an extra syscall to get
the current process group, but it is inherent racy: after the current
process group is received and before it is passed to waitid a signal
could arrive causing the current process group to change.

So waitid is used if wait4 is not defined iff the build is
enabled with a minimum kernel if 5.4+.  The new assume
__ASSUME_WAITID_PID0_P_PGID is added and an error is issued if waitid
can not be implemented by either __NR_wait4 or
__NR_waitid && __ASSUME_WAITID_PID0_P_PGID.

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

Co-authored-by: Alistair Francis <alistair.francis@wdc.com>
4 years agoImplement wait in terms of waitpid
Adhemerval Zanella [Wed, 13 Nov 2019 16:30:46 +0000 (13:30 -0300)] 
Implement wait in terms of waitpid

The POSIX implementation is used as default and both BSD and Linux
version are removed.  It simplifies the implementation for
architectures that do not provide either __NR_waitpid or
__NR_wait4.

Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.

4 years agonptl: Move waitpid implementation to libc
Adhemerval Zanella [Wed, 13 Nov 2019 14:05:02 +0000 (11:05 -0300)] 
nptl: Move waitpid implementation to libc

Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.

4 years agonptl: Move wait implementation to libc
Adhemerval Zanella [Wed, 13 Nov 2019 14:02:13 +0000 (11:02 -0300)] 
nptl: Move wait implementation to libc

Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.

4 years agoRemove __waitpid_nocancel
Adhemerval Zanella [Wed, 13 Nov 2019 13:42:05 +0000 (10:42 -0300)] 
Remove __waitpid_nocancel

It enables and disables cancellation with pthread_setcancelstate
before calling the waitpid.  It simplifies the waitpid implementation
for architectures that do not provide either __NR_waitpid or
__NR_wait4.

Checked on x86_64-linux-gnu.

4 years agoFix test isolation for elf/tst-ifunc-fault-lazy, elf/tst-ifunc-fault-bindnow
Florian Weimer [Thu, 19 Dec 2019 13:45:50 +0000 (14:45 +0100)] 
Fix test isolation for elf/tst-ifunc-fault-lazy, elf/tst-ifunc-fault-bindnow

Previously, ld.so was invoked only with the elf subdirectory on the
library search path.  Since the soname link for libc.so only exists in
the top-level build directory, this leaked the system libc into the
test.

4 years agoFix __libc_signal_block_all on sparc64
Adhemerval Zanella [Mon, 9 Dec 2019 18:50:29 +0000 (15:50 -0300)] 
Fix __libc_signal_block_all on sparc64

The posix_spawn on sparc issues invalid sigprocmask calls:

  rt_sigprocmask(0xffe5e15c /* SIG_??? */, ~[], 0xffe5e1dc, 8) = -1 EINVAL (Invalid argument)

Which make support/tst-support_capture_subprocess fails with random
output (due the child signal being wrongly captured by the parent).

Tracking the culprit it seems to be a wrong code generation in the
INTERNAL_SYSCALL due the automatic sigset_t used on
__libc_signal_block_all:

  return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &SIGALL_SET,
                          set, _NSIG / 8);

Where SIGALL_SET is defined as:

  ((__sigset_t) { .__val = {[0 ...  _SIGSET_NWORDS-1 ] =  -1 } })

Building the expanded __libc_signal_block_all on sparc64 with recent
compiler (gcc 8.3.1 and 9.1.1):

  #include <signal>

  int
  _libc_signal_block_all (sigset_t *set)
  {
    INTERNAL_SYSCALL_DECL (err);
    return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &SIGALL_SET,
     set, _NSIG / 8);
  }

The first argument (SIG_BLOCK) is not correctly set on 'o0' register:

  __libc_signal_block_all:
save    %sp, -304, %sp
add     %fp, 1919, %o0
mov     128, %o2
sethi   %hi(.LC0), %o1
call    memcpy, 0
 or     %o1, %lo(.LC0), %o1
add     %fp, 1919, %o1
mov     %i0, %o2
mov     8, %o3
mov     103, %g1
ta      0x6d;
bcc,pt  %xcc, 1f
mov     0, %g1
sub     %g0, %o0, %o0
mov     1, %g1
     1: sra     %o0, 0, %i0
return  %i7+8
 nop

Where if SIGALL_SET is defined a const object, gcc correctly sets the
expected kernel argument in correct register:

        sethi   %hi(.LC0), %o1
        call    memcpy, 0
         or     %o1, %lo(.LC0), %o1
   ->   mov     1, %o0
add     %fp, 1919, %o1

Another possible fix is use a static const object.  Although there
should not be a difference between a const compound literal and a static
const object, the gcc C99 status page [1] has a note stating that this
optimization is not implemented:

  "const-qualified compound literals could share storage with each
   other and with string literals, but currently don't.".

This patch fixes it by moving both sigset_t that represent the
signal sets to static const data object.  It generates slight better
code where the object reference is used directly instead of a stack
allocation plus the content materialization.

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

[1] https://gcc.gnu.org/c99status.html

4 years agopowerpc: Do not run IFUNC resolvers for LD_DEBUG=unused [BZ #24214]
Adhemerval Zanella [Tue, 17 Dec 2019 18:55:59 +0000 (15:55 -0300)] 
powerpc: Do not run IFUNC resolvers for LD_DEBUG=unused [BZ #24214]

This patch adds the missing bits for powerpc and fixes both
tst-ifunc-fault-lazy and tst-ifunc-fault-bindnow failures on
powerpc-linux-gnu.

Checked on powerpc-linux-gnu and powerpc-linux-gnu-power4.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agohurd: Do not make sigprocmask available in ld.so
Florian Weimer [Wed, 18 Dec 2019 09:27:10 +0000 (10:27 +0100)] 
hurd: Do not make sigprocmask available in ld.so

After commit f7649d5780aa4682393b9daedd653e4d9c12784c ("dlopen: Do not
block signals"), the dynamic linker no longer uses sigprocmask, which
means that it does not have to be made available explicitly on hurd.

This reverts commit 892badc9bbcd4a6f8c2eb6c8a99be3aa22517532
("hurd: Make __sigprocmask GLIBC_PRIVATE") and commit
d5ed9ba29a3c818b3433a1784862494968abda45 ("hurd: Fix ld.so link"),
but keeps the comment changes from the second commit.

4 years agobuild-many-glibcs.py: Do not build C++ PCHs by default
Florian Weimer [Tue, 17 Dec 2019 15:23:08 +0000 (16:23 +0100)] 
build-many-glibcs.py: Do not build C++ PCHs by default

They are not used during the subsequent glibc build, so creating them
merely wastes time.

4 years agohurd: Make getrandom honour GRND_NONBLOCK
James Clarke [Tue, 17 Dec 2019 18:29:29 +0000 (18:29 +0000)] 
hurd: Make getrandom honour GRND_NONBLOCK

* sysdeps/mach/hurd/getrandom.c (__getrandom): Open the random source
with O_NONBLOCK when the GRND_NONBLOCK flag is provided.
Message-Id: <20191217182929.90989-1-jrtc27@jrtc27.com>

4 years agotunables: report sbrk() failure
DJ Delorie [Fri, 13 Dec 2019 18:36:58 +0000 (13:36 -0500)] 
tunables: report sbrk() failure

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agobuild-many-glibcs.py: Add mipsisa64r6el-linux-gnu target
Dragan Mladjenovic [Wed, 11 Dec 2019 10:23:04 +0000 (11:23 +0100)] 
build-many-glibcs.py: Add mipsisa64r6el-linux-gnu target

This patch enables building mips/r6 isa/little-endian/hard-float configuration in
o32, n32, and n64 variants.

4 years agomips: Do not include hi and lo in __SYSCALL_CLOBBERS for R6
Dragan Mladjenovic [Tue, 19 Nov 2019 14:06:20 +0000 (15:06 +0100)] 
mips: Do not include hi and lo in __SYSCALL_CLOBBERS for R6

GCC 10 (PR 91233) won't silently allow registers that are not architecturally
available to be present in the clobber list anymore, resulting in build failure
for mips*r6 targets in form of:
...
.../sysdep.h:146:2: error: the register ‘lo’ cannot be clobbered in ‘asm’ for the current target
  146 |  __asm__ volatile (      \
      |  ^~~~~~~

This is because base R6 ISA doesn't define hi and lo registers w/o DSP extension.
This patch provides the alternative definitions of __SYSCALL_CLOBBERS for r6
targets that won't include those registers.

* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h (__SYSCALL_CLOBBERS): Exclude
hi and lo from the clobber list for __mips_isa_rev >= 6.
* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h (__SYSCALL_CLOBBERS): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h (__SYSCALL_CLOBBERS): Likewise.

4 years agoldbl-128ibm-compat: Add ISO C99 versions of scanf functions
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:47:43 +0000 (11:47 -0300)] 
ldbl-128ibm-compat: Add ISO C99 versions of scanf functions

In the format string for *scanf functions, the '%as', '%aS', and '%a[]'
modifiers behave differently depending on ISO C99 compatibility.  When
_GNU_SOURCE is defined and -std=c89 is passed to the compiler, these
functions behave like ascanf, and the modifiers allocate memory for the
output.  Otherwise, the ISO C99 compliant version of these functions is
used, and the modifiers consume a floating-point argument.  This patch
adds the IEEE binary128 variant of ISO C99 compliant functions for the
third long double format on powerpc64le.

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
Gabriel F. T. Gomes [Wed, 27 Nov 2019 16:06:50 +0000 (10:06 -0600)] 
ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf

Since commit

commit 03992356e6fedc5a5e9d32df96c1a2c79ea28a8f
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Feb 10 11:58:35 2018 -0500

    Use C99-compliant scanf under _GNU_SOURCE with modern compilers.

the selection of the GNU versions of scanf functions requires both
_GNU_SOURCE and -std=c89.  This patch changes the tests in
ldbl-128ibm-compat so that they actually test the GNU versions (without
this change, the redirection to the ISO C99 version always happens, so
GNU versions of the new implementation (e.g. __scanfieee128) were left
untested).

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agohurd: Fix local PLT
Samuel Thibault [Fri, 13 Dec 2019 09:10:59 +0000 (10:10 +0100)] 
hurd: Fix local PLT

* include/sys/random.h (__getrandom): Add hidden prototype.
* stdlib/getrandom.c (getrandom): Rename to hidden definition __getrandom.
Add weak alias.
* sysdeps/mach/hurd/getrandom.c (getrandom): Likewise.
* sysdeps/unix/sysv/linux/getrandom.c (getrandom): Likewise.
* sysdeps/mach/hurd/getentropy.c (getentropy): Use __getrandom instead of
getrandom.

4 years agodlopen: Do not block signals
Florian Weimer [Fri, 13 Dec 2019 09:23:10 +0000 (10:23 +0100)] 
dlopen: Do not block signals

Blocking signals causes issues with certain anti-malware solutions
which rely on an unblocked SIGSYS signal for system calls they
intercept.

This reverts commit a2e8aa0d9ea648068d8be52dd7b15f1b6a008e23
("Block signals during the initial part of dlopen") and adds
comments related to async signal safety to active_nodelete and
its caller.

Note that this does not make lazy binding async-signal-safe with regards
to dlopen.  It merely avoids introducing new async-signal-safety hazards
as part of the NODELETE changes.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agodlopen: Rework handling of pending NODELETE status
Florian Weimer [Fri, 13 Dec 2019 09:18:46 +0000 (10:18 +0100)] 
dlopen: Rework handling of pending NODELETE status

Commit a2e8aa0d9ea648068d8be52dd7b15f1b6a008e23 ("Block signals during
the initial part of dlopen") was deemed necessary because of
read-modify-write operations like the one in  add_dependency in
elf/dl-lookup.c.  In the old code, we check for any kind of NODELETE
status and bail out:

      /* Redo the NODELETE check, as when dl_load_lock wasn't held
 yet this could have changed.  */
      if (map->l_nodelete != link_map_nodelete_inactive)
goto out;

And then set pending status (during relocation):

  if (flags & DL_LOOKUP_FOR_RELOCATE)
    map->l_nodelete = link_map_nodelete_pending;
  else
    map->l_nodelete = link_map_nodelete_active;

If a signal arrives during relocation and the signal handler, through
lazy binding, adds a global scope dependency on the same map, it will
set map->l_nodelete to link_map_nodelete_active.  This will be
overwritten with link_map_nodelete_pending by the dlopen relocation
code.

To avoid such problems in relation to the l_nodelete member, this
commit introduces two flags for active NODELETE status (irrevocable)
and pending NODELETE status (revocable until activate_nodelete is
invoked).  As a result, NODELETE processing in dlopen does not
introduce further reasons why lazy binding from signal handlers
is unsafe during dlopen, and a subsequent commit can remove signal
blocking from dlopen.

This does not address pre-existing issues (unrelated to the NODELETE
changes) which make lazy binding in a signal handler during dlopen
unsafe, such as the use of malloc in both cases.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agodlopen: Fix issues related to NODELETE handling and relocations
Florian Weimer [Fri, 13 Dec 2019 09:18:24 +0000 (10:18 +0100)] 
dlopen: Fix issues related to NODELETE handling and relocations

The assumption behind the assert in activate_nodelete was wrong:

Inconsistency detected by ld.so: dl-open.c: 459: activate_nodelete:
Assertion `!imap->l_init_called || imap->l_type != lt_loaded' failed! (edit)

It can happen that an already-loaded object that is in the local
scope is promoted to NODELETE status, via binding to a unique
symbol.

Similarly, it is possible that such NODELETE promotion occurs to
an already-loaded object from the global scope.  This is why the
loop in activate_nodelete has to cover all objects in the namespace
of the new object.

In do_lookup_unique, it could happen that the NODELETE status of
an already-loaded object was overwritten with a pending NODELETE
status.  As a result, if dlopen fails, this could cause a loss of
the NODELETE status of the affected object, eventually resulting
in an incorrect unload.

Fixes commit f63b73814f74032c0e5d0a83300e3d864ef905e5 ("Remove all
loaded objects if dlopen fails, ignoring NODELETE [BZ #20839]").

4 years agohurd: Fix __close_nocancel_nostatus availability
Samuel Thibault [Fri, 13 Dec 2019 02:32:21 +0000 (03:32 +0100)] 
hurd: Fix __close_nocancel_nostatus availability

Not only libc/rtld use __close_nocancel_nostatus.

* sysdeps/mach/hurd/Makefile [$(subdir) == io] (sysdep_routines): Add
close_nocancel_nostatus.
* sysdeps/mach/hurd/Versions (libc): Add __close_nocancel_nostatus to
GLIBC_PRIVATE.
* sysdeps/mach/hurd/not-cancel.h (__close_nocancel_nostatus): Declare
function instead of defining inline.
[IS_IN (libc) || IS_IN (rtld)] (__close_nocancel_nostatus): Make
function hidden.
* sysdeps/mach/hurd/close_nocancel_nostatus.c: New file.

4 years agohurd: add getrandom and getentropy implementations
Andrew Eggenberger [Wed, 30 Oct 2019 04:19:32 +0000 (23:19 -0500)] 
hurd: add getrandom and getentropy implementations

* sysdeps/mach/hurd/getentropy.c: New file.
* sysdeps/mach/hurd/getrandom.c: Likewise.

4 years agohurd: Implement __close_nocancel_nostatus
Samuel Thibault [Fri, 13 Dec 2019 02:23:14 +0000 (03:23 +0100)] 
hurd: Implement __close_nocancel_nostatus

* sysdeps/mach/hurd/not-cancel.h: New file.

4 years agomanual: clarify fopen with the x flag
Paul Eggert [Wed, 11 Dec 2019 17:34:06 +0000 (09:34 -0800)] 
manual: clarify fopen with the x flag

* manual/stdio.texi (Opening Streams): Say how glibc's
implementation of fopen with "x" follows ISO C11.

4 years agoS390: Use sysdeps/ieee754/dbl-64/wordsize-64 on s390x.
Stefan Liebler [Wed, 11 Dec 2019 14:09:34 +0000 (15:09 +0100)] 
S390: Use sysdeps/ieee754/dbl-64/wordsize-64 on s390x.

This patch enables the usage of implementations in
sysdeps/ieee754/dbl-64/wordsize-64 on 64bit s390x.

4 years agoS390: Implement roundtoint and converttoint and define TOINT_INTRINSICS.
Stefan Liebler [Wed, 11 Dec 2019 14:09:33 +0000 (15:09 +0100)] 
S390: Implement roundtoint and converttoint and define TOINT_INTRINSICS.

This patch implements roundtoint and convertoint for s390
by using the load-fp-integer and convert-to-fixed instructions.
Both functions are using "round to nearest with ties away from zero"
rounding mode and do not raise inexact exceptions.

4 years agoS390: Implement math-barriers math_opt_barrier and math_force_eval.
Stefan Liebler [Wed, 11 Dec 2019 14:09:32 +0000 (15:09 +0100)] 
S390: Implement math-barriers math_opt_barrier and math_force_eval.

This patch implements the s390 specific math barriers in order
to omit the store and load from stack if possible.

4 years agoS390: Use libc_fe* macros in fe* functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:32 +0000 (15:09 +0100)] 
S390: Use libc_fe* macros in fe* functions.

This patch updates the s390 specific functions fegetround,
fesetround, feholdexcept, fesetenv, feupdateenv, fegetexceptflag,
fetestexcept, fesetexceptflag, fetestexceptflag.
Now those functions are using the libc_fe* macros if possible.

Furthermore fegetexceptflag is now returning the exception from
dxc field shifted to the usual exception-flags.
Thus a special fetestexceptflag implementation is not needed anymore.

4 years agoS390: Implement libc_fe* macros.
Stefan Liebler [Wed, 11 Dec 2019 14:09:31 +0000 (15:09 +0100)] 
S390: Implement libc_fe* macros.

This patch provides the s390 specific implementation for
libc_feholdexcept, libc_fesetround, libc_feholdexcept_setround,
libc_fetestexcept, libc_fesetenv, libc_feupdateenv_test,
libc_feupdateenv, libc_feholdsetround_ctx, libc_feresetround_ctx,
libc_feholdsetround_noex_ctx and libc_feresetround_noex_ctx.

4 years agoS390: Use convert-to-fixed instruction for llround functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:31 +0000 (15:09 +0100)] 
S390: Use convert-to-fixed instruction for llround functions.

If compiled with z196 zarch support, the convert-to-fixed instruction
is used to implement llround, llroundf, llroundl.
Otherwise the common-code implementation is used.

4 years agoS390: Use convert-to-fixed instruction for lround functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:30 +0000 (15:09 +0100)] 
S390: Use convert-to-fixed instruction for lround functions.

If compiled with z196 zarch support, the convert-to-fixed instruction
is used to implement lround, lroundf, lroundl.
Otherwise the common-code implementation is used.

4 years agoS390: Use convert-to-fixed instruction for llrint functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:29 +0000 (15:09 +0100)] 
S390: Use convert-to-fixed instruction for llrint functions.

If compiled with z196 zarch support, the convert-to-fixed instruction
is used to implement llrint, llrintf, llrintl.
Otherwise the common-code implementation is used.

4 years agoS390: Use convert-to-fixed instruction for lrint functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:29 +0000 (15:09 +0100)] 
S390: Use convert-to-fixed instruction for lrint functions.

If compiled with z196 zarch support, the convert-to-fixed instruction
is used to implement lrint, lrintf, lrintl.
Otherwise the common-code implementation is used.

4 years agoS390: Use load-fp-integer instruction for roundeven functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:28 +0000 (15:09 +0100)] 
S390: Use load-fp-integer instruction for roundeven functions.

If compiled with z196 zarch support, the load-fp-integer instruction
is used to implement roundeven, roundevenf, roundevenl.
Otherwise the common-code implementation is used.

4 years agoAdjust s_copysignl.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:28 +0000 (15:09 +0100)] 
Adjust s_copysignl.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAdjust s_ceilf.c and s_ceill.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:27 +0000 (15:09 +0100)] 
Adjust s_ceilf.c and s_ceill.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAdjust s_floorf.c and s_floorl.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:26 +0000 (15:09 +0100)] 
Adjust s_floorf.c and s_floorl.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAdjust s_rintf.c and s_rintl.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:26 +0000 (15:09 +0100)] 
Adjust s_rintf.c and s_rintl.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAdjust s_nearbyintf.c and s_nearbyintl.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:25 +0000 (15:09 +0100)] 
Adjust s_nearbyintf.c and s_nearbyintl.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for copysign functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:24 +0000 (15:09 +0100)] 
Use GCC builtins for copysign functions if desired.

This patch is always using the corresponding GCC builtin for copysignf, copysign,
and is using the builtin for copysignl, copysignf128 if the USE_FUNCTION_BUILTIN
macros are defined to one in math-use-builtins.h.

Altough the long double version is enabled by default we still need
the macro and the alternative implementation as the _Float128 version
of the builtin is not available with all supported GCC versions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for round functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:24 +0000 (15:09 +0100)] 
Use GCC builtins for round functions if desired.

This patch is using the corresponding GCC builtin for roundf, round,
roundl and roundf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for trunc functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:22 +0000 (15:09 +0100)] 
Use GCC builtins for trunc functions if desired.

This patch is using the corresponding GCC builtin for truncf, trunc,
truncl and truncf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for ceil functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:21 +0000 (15:09 +0100)] 
Use GCC builtins for ceil functions if desired.

This patch is using the corresponding GCC builtin for ceilf, ceil,
ceill and ceilf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for floor functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:20 +0000 (15:09 +0100)] 
Use GCC builtins for floor functions if desired.

This patch is using the corresponding GCC builtin for floorf, floor,
floorl and floorf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for rint functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:20 +0000 (15:09 +0100)] 
Use GCC builtins for rint functions if desired.

This patch is using the corresponding GCC builtin for rintf, rint,
rintl and rintf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for nearbyint functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:18 +0000 (15:09 +0100)] 
Use GCC builtins for nearbyint functions if desired.

This patch is using the corresponding GCC builtin for nearbyintf, nearbyint,
nearbintl and nearbyintf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_round.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:17 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_round.c.

This patch replaces s_round.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_trunc.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:17 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_trunc.c.

This patch replaces s_trunc.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 and sparc64 files.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_ceil.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:16 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_ceil.c.

This patch replaces s_ceil.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 and sparc64 files.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_floor.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:15 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_floor.c.

This patch replaces s_floor.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 and sparc64 files.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_rint.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:14 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_rint.c.

This patch replaces s_rint.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_nearbyint.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:14 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_nearbyint.c.

This patch replaces s_nearbyint.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoldconfig: Do not print a warning for a missing ld.so.conf file
Florian Weimer [Wed, 11 Dec 2019 08:19:39 +0000 (09:19 +0100)] 
ldconfig: Do not print a warning for a missing ld.so.conf file

The configuration file is not needed for working system, so printing a
warning is not helpful.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agohurd: Fix using altstack while in an RPC call to be aborted
Samuel Thibault [Tue, 10 Dec 2019 23:23:00 +0000 (00:23 +0100)] 
hurd: Fix using altstack while in an RPC call to be aborted

* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Always check
for interrupted code being with esp pointing at mach_msg arguments, even
when using an altstack. If we need to abort the RPC we will need
this.

4 years agoFix failure when CFLAGS contains -DNDEBUG (Bug 25251)
Carlos O'Donell [Tue, 3 Dec 2019 20:42:24 +0000 (15:42 -0500)] 
Fix failure when CFLAGS contains -DNDEBUG (Bug 25251)

Building tests with -DNDEBUG in CFLAGS, gcc 9.2.1 issues the following error:
tst-assert-c++.cc: In function ‘int do_test()’:
tst-assert-c++.cc:66:12: error: unused variable ‘value’ [-Werror=unused-variable]
   66 |     no_int value;
      |            ^~~~~
tst-assert-c++.cc:71:18: error: unused variable ‘value’ [-Werror=unused-variable]
   71 |     bool_and_int value;
      |                  ^~~~~

The assert has been disabled by building glibc with CFLAGS, CXXFLAGS,
and CPPFLAGS with -DNDEBUG which removes the assert and leaves the
value unused.

We never want the assert disabled because that's the point of the
test, so we undefine NDEBUG before including assert.h to ensure that
we get assert correctly defined.

4 years agonptl: Add more missing placeholder abi symbol from nanosleep move
Adhemerval Zanella [Tue, 3 Dec 2019 20:32:49 +0000 (20:32 +0000)] 
nptl: Add more missing placeholder abi symbol from nanosleep move

This patch adds the missing __libpthread_version_placeholder for
GLIBC_2.2.6 version from the nanosleep implementation move from
libpthread to libc (79a547b162).

It also fixes the wrong compat symbol definitions added by changing
back the version used on vfork check and remove the
__libpthread_version_placeholder added on some ABI (4f4bb489e0dd).

The __libpthread_version_placeholder is also refactored to make it
simpler to add new compat_symbols by adding a new macro
compat_symbol_unique which uses the compiler extension __COUNTER__
to generate unique strong alias to be used with compat_symbol.

Checked with a updated-abi on the all affected abis of the nanosleep
move.

Change-Id: I347a4dbdc931bb42b359456932dd1e17aa4d4078

4 years agosysdeps/riscv/start.S: rename .Lload_gp to load_gp (bug 24376)
Andreas Schwab [Mon, 12 Aug 2019 09:29:29 +0000 (11:29 +0200)] 
sysdeps/riscv/start.S: rename .Lload_gp to load_gp (bug 24376)

Renaming the symbol keeps the label in the symbol table as a normal local
label, so that `objdump -d' can pick it up as an anchor.

4 years agoy2038: linux: Provide __timer_settime64 implementation
Lukasz Majewski [Fri, 8 Nov 2019 12:15:27 +0000 (13:15 +0100)] 
y2038: linux: Provide __timer_settime64 implementation

This patch provides new __timer_settime64 explicit 64 bit function for setting
flags, interval and value of specified timer.
Moreover, a 32 bit version - __timer_settime has been refactored to internally
use __timer_settime64.

The __timer_settime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct
__timespec64 from struct timespec (and opposite when old_value pointer is
provided).

The new __timer_settime64 syscall available from Linux 5.1+ has been used, when
applicable.

The original INLINE_SYSCALL() macro has been replaced with
INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments.

Build tests:
- The code has been tested on x86_64/x86 (native compilation):
make PARALLELMFLAGS="-j8" && make check PARALLELMFLAGS="-j8" && \\
make xcheck PARALLELMFLAGS="-j8"

- The glibc has been build tested (make PARALLELMFLAGS="-j8") for
x86 (i386), x86_64-x32, and armv7

Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
  https://github.com/lmajewski/meta-y2038 and run tests:
  https://github.com/lmajewski/y2038-tests/commits/master

- Use of cross-test-ssh.sh for ARM (armv7):
  make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck

Linux kernel, headers and minimal kernel version for glibc build test
matrix:
- Linux v5.1 (with timer_settime64) and glibc build with v5.1 as
  minimal kernel version (--enable-kernel="5.1.0")
  The __ASSUME_TIME64_SYSCALLS flag defined.

- Linux v5.1 and default minimal kernel version
  The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports timer_settime64
  syscall.

- Linux v4.19 (no timer_settime64 support) with default minimal kernel version
  for contemporary glibc (3.2.0)
  This kernel doesn't support timer_settime64 syscall, so the fallback to
  timer_settime is tested.

Above tests were performed with Y2038 redirection applied as well as without
(so the __TIMESIZE != 64 execution path is checked as well).

No regressions were observed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide __timer_gettime64 implementation
Lukasz Majewski [Tue, 5 Nov 2019 16:04:24 +0000 (17:04 +0100)] 
y2038: linux: Provide __timer_gettime64 implementation

This patch provides new __timer_gettime64 explicit 64 bit function for reading
status of specified timer. To be more precise - the remaining time and interval
set with timer_settime.
Moreover, a 32 bit version - __timer_gettime has been refactored to internally
use __timer_gettime64.

The __timer_gettime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversion from 64 bit struct
__timespec64 to struct timespec.

The new __timer_gettime64 syscall available from Linux 5.1+ has been used, when
applicable.

The original INLINE_SYSCALL() macro has been replaced with
INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments.

Build tests:
- The code has been tested on x86_64/x86 (native compilation):
make PARALLELMFLAGS="-j8" && make check PARALLELMFLAGS="-j8" && \\
make xcheck PARALLELMFLAGS="-j8"

- The glibc has been build tested (make PARALLELMFLAGS="-j8") for
x86 (i386), x86_64-x32, and armv7

Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
  https://github.com/lmajewski/meta-y2038 and run tests:
  https://github.com/lmajewski/y2038-tests/commits/master

- Use of cross-test-ssh.sh for ARM (armv7):
  make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck

Linux kernel, headers and minimal kernel version for glibc build test
matrix:
- Linux v5.1 (with timer_gettime64) and glibc build with v5.1 as
  minimal kernel version (--enable-kernel="5.1.0")
  The __ASSUME_TIME64_SYSCALLS flag defined.

- Linux v5.1 and default minimal kernel version
  The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports timer_gettime64
  syscall.

- Linux v4.19 (no timer_gettime64 support) with default minimal kernel version
  for contemporary glibc (3.2.0)
  This kernel doesn't support timer_gettime64 syscall, so the fallback to
  timer_gettime is tested.

Above tests were performed with Y2038 redirection applied as well as without
(so the __TIMESIZE != 64 execution path is checked as well).

No regressions were observed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agotimer: Decouple x86_64 specific timer_settime from generic Linux implementation
Lukasz Majewski [Fri, 8 Nov 2019 10:13:56 +0000 (11:13 +0100)] 
timer: Decouple x86_64 specific timer_settime from generic Linux implementation

The x86_64 specific timer_settime implementation (from
./linux/x86_64/timer_settime.c) reused the Linux generic one (from
./linux/timer_settime.c) to implement handling some compatible timers
(previously defined in librt, now in libc).

As the generic implementation now is going to also support new (available
from Linux 5.1+) timer_settime64 syscall, those two implementations have
been decoupled for easier conversion.

The original INLINE_SYSCALL() macro has been replaced with
INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agotimer: Decouple x86_64 specific timer_gettime from generic Linux implementation
Lukasz Majewski [Tue, 5 Nov 2019 11:18:24 +0000 (12:18 +0100)] 
timer: Decouple x86_64 specific timer_gettime from generic Linux implementation

The x86_64 specific timer_gettime implementation (from
./linux/x86_64/timer_gettime.c) reused the Linux generic one (from
./linux/timer_gettime.c) to implement handling some compatible timers
(previously defined in librt, now in libc).

As the generic implementation now is going to also support new (available
from Linux 5.1+) timer_gettime64 syscall, those two implementations have
been decoupled for easier conversion.

The original INLINE_SYSCALL() macro has been replaced with
INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agotime: Introduce glibc's internal struct __itimerspec64
Lukasz Majewski [Tue, 5 Nov 2019 11:44:26 +0000 (12:44 +0100)] 
time: Introduce glibc's internal struct __itimerspec64

This change provides the glibc's internal struct itimerspec representation,
which is explicitly supporting 64 bit time (by using struct __timespec64).

Such representation is necessary to provide correct time after Y2038
(time_t overflow) on devices with __TIMESIZE == 32.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoCorrect range checking in mallopt/mxfast/tcache [BZ #25194]
DJ Delorie [Tue, 3 Dec 2019 22:44:36 +0000 (17:44 -0500)] 
Correct range checking in mallopt/mxfast/tcache [BZ #25194]

do_set_tcache_max, do_set_mxfast:
Fix two instances of comparing "size_t < 0"
Both cases have upper limit, so the "negative value" case
is already handled via overflow semantics.

do_set_tcache_max, do_set_tcache_count:
Fix return value on error.  Note: currently not used.

mallopt:
pass return value of helper functions to user.  Behavior should
only be actually changed for mxfast, where we restore the old
(pre-tunables) behavior.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agomisc/test-errno-linux: Handle EINVAL from quotactl
Florian Weimer [Thu, 5 Dec 2019 16:29:42 +0000 (17:29 +0100)] 
misc/test-errno-linux: Handle EINVAL from quotactl

In commit 3dd4d40b420846dd35869ccc8f8627feef2cff32 ("xfs: Sanity check
flags of Q_XQUOTARM call"), Linux 5.4 added checking for the flags
argument, causing the test to fail due to too restrictive test
expectations.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years ago<string.h>: Define __CORRECT_ISO_CPP_STRING_H_PROTO for Clang [BZ #25232]
Kamlesh Kumar [Thu, 5 Dec 2019 15:49:00 +0000 (16:49 +0100)] 
<string.h>: Define __CORRECT_ISO_CPP_STRING_H_PROTO for Clang [BZ #25232]

Without the asm redirects, strchr et al. are not const-correct.

libc++ has a wrapper header that works with and without
__CORRECT_ISO_CPP_STRING_H_PROTO (using a Clang extension).  But when
Clang is used with libstdc++ or just C headers, the overloaded functions
with the correct types are not declared.

This change does not impact current GCC (with libstdc++ or libc++).

4 years agobuild-many-glibcs.py: Move sparcv8 to extra_glibcs
Adhemerval Zanella [Tue, 3 Dec 2019 12:18:49 +0000 (09:18 -0300)] 
build-many-glibcs.py: Move sparcv8 to extra_glibcs

It also fixes the sparcv9-linux-gnu-disable-multi-arch configuration.
The resulting sparc possible build permutations are:

  - sparc64-linux-gnu
  - sparcv9-linux-gnu
  - sparcv8-linux-gnu-leon3 (from extra_glibcs)
  - sparc64-linux-gnu-disable-multi-arch (from extra_glibcs)
  - sparcv9-linux-gnu-disable-multi-arch (from extra_glibcs)

4 years agosysdeps/clock_gettime: Use clock_gettime64 if avaliable
Alistair Francis [Mon, 15 Jul 2019 23:30:59 +0000 (16:30 -0700)] 
sysdeps/clock_gettime: Use clock_gettime64 if avaliable

With the clock_gettime64 call we prefer to use vDSO. There is no call
to clock_gettime64 on glibc with older headers and kernel 5.1+ if it
doesn't support vDSO.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>