]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
4 years agohtl: fix register-atfork ordering
Samuel Thibault [Sun, 7 Jun 2020 00:57:04 +0000 (02:57 +0200)] 
htl: fix register-atfork ordering

* htl/register-atfork.c (__register_atfork): Add new hooks at the end of
the list instead of the beginning.

4 years agohurd: Fix hang in _hurd_raise_signal from pthread_kill
Samuel Thibault [Sat, 6 Jun 2020 23:55:54 +0000 (01:55 +0200)] 
hurd: Fix hang in _hurd_raise_signal from pthread_kill

When ss is not NULL, it is assumed to be locked.

* hurd/hurd-raise.c (_hurd_raise_signal): Unlock before returning an
error if ss is not NULL.

4 years agohurd: Reject raising invalid signals
Samuel Thibault [Sat, 6 Jun 2020 23:35:18 +0000 (01:35 +0200)] 
hurd: Reject raising invalid signals

* hurd/hurd-raise.c (_hurd_raise_signal): Return  EINVAL if signo <= 0
or signo >= NSI.

4 years agohurd: fix clearing SS_ONSTACK when longjmp-ing from sighandler
Samuel Thibault [Sat, 6 Jun 2020 18:21:22 +0000 (20:21 +0200)] 
hurd: fix clearing SS_ONSTACK when longjmp-ing from sighandler

* sysdeps/i386/htl/Makefile: New file.
* sysdeps/i386/htl/tcb-offsets.sym: New file.
* sysdeps/mach/hurd/i386/Makefile [setjmp] (gen-as-const-headers): Add
signal-defines.sym.
* sysdeps/mach/hurd/i386/____longjmp_chk.S: Include tcb-offsets.h.
(____longjmp_chk): Harmonize with i386's __longjmp. Clear SS_ONSTACK
when jumping off the alternate stack.
* sysdeps/mach/hurd/i386/__longjmp.S: New file.

4 years agohurd: Add pointer guard support
Samuel Thibault [Sat, 6 Jun 2020 01:26:00 +0000 (01:26 +0000)] 
hurd: Add pointer guard support

* sysdeps/mach/hurd/i386/tls.h (THREAD_SET_POINTER_GUARD,
THREAD_COPY_POINTER_GUARD): New macros.

4 years agohurd: Add stack guard support
Samuel Thibault [Sat, 6 Jun 2020 00:00:19 +0000 (00:00 +0000)] 
hurd: Add stack guard support

* sysdeps/mach/hurd/i386/tls.h (THREAD_SET_STACK_GUARD,
THREAD_COPY_STACK_GUARD): New macros
* sysdeps/mach/hurd/i386/ld.abilist (__stack_chk_guard): Remove symbol.

4 years agodl-runtime: reloc_{offset,index} now functions arch overide'able
Vineet Gupta [Wed, 27 May 2020 19:54:21 +0000 (12:54 -0700)] 
dl-runtime: reloc_{offset,index} now functions arch overide'able

The existing macros are fragile and expect local variables with a
certain name. Fix this by defining them as functions with default
implementation in a new header dl-runtime.h which arches can override
if need be.

This came up during ARC port review, hence the need for argument pltgot
in reloc_index() which is not needed by existing ports.

This patch potentially only affects hppa/x86 ports,
build tested for both those configs and a few more.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agopowerpc64le: add optimized strlen for P9
Paul E. Murphy [Mon, 18 May 2020 16:16:06 +0000 (11:16 -0500)] 
powerpc64le: add optimized strlen for P9

This started as a trivial change to Anton's rawmemchr.  I got
carried away.  This is a hybrid between P8's asympotically
faster 64B checks with extremely efficient small string checks
e.g <64B (and sometimes a little bit more depending on alignment).

The second trick is to align to 64B by running a 48B checking loop
16B at a time until we naturally align to 64B (i.e checking 48/96/144
bytes/iteration based on the alignment after the first 5 comparisons).
This allieviates the need to check page boundaries.

Finally, explicly use the P7 strlen with the runtime loader when building
P9.  We need to be cautious about vector/vsx extensions here on P9 only
builds.

4 years agopowerpc64le: use common fmaf128 implementation
Paul E. Murphy [Wed, 3 Jun 2020 18:57:20 +0000 (13:57 -0500)] 
powerpc64le: use common fmaf128 implementation

This defines the macro such that it should behave best on all
supported powerpc targets.  Likewise, this allows us to remove the
ppc64le specific s_fmaf128.c.

I have verified powerpc64le multiarch and powerpc64le power9
no-multiarch builds continue to generate optimize fmaf128.

4 years agobenchtests: Restore the clock_gettime option
H.J. Lu [Fri, 5 Jun 2020 16:48:04 +0000 (09:48 -0700)] 
benchtests: Restore the clock_gettime option

commit 7621e38bf3c58b2d0359545f1f2898017fd89d05
Author: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Date:   Tue Jan 29 17:43:45 2019 +0000

    Add generic hp-timing support

removed the clock_gettime option.  Restore the clock_gettime option for
some x86 CPUs on which value from RDTSC may not be incremented at a fixed
rate.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoUpdate HP_TIMING_NOW for _ISOMAC in sysdeps/generic/hp-timing.h
H.J. Lu [Fri, 5 Jun 2020 16:43:13 +0000 (09:43 -0700)] 
Update HP_TIMING_NOW for _ISOMAC in sysdeps/generic/hp-timing.h

commit e9698175b0b60407db1e89bcf29437ab224bca0b
Author: Lukasz Majewski <lukma@denx.de>
Date:   Mon Mar 16 08:31:41 2020 +0100

    y2038: Replace __clock_gettime with __clock_gettime64

breaks benchtests with sysdeps/generic/hp-timing.h:

In file included from ./bench-timing.h:23,
                 from ./bench-skeleton.c:25,
                 from
/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
./bench-skeleton.c: In function ‘main’:
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~

Define HP_TIMING_NOW with clock_gettime in sysdeps/generic/hp-timing.h
if _ISOMAC is defined.  Don't define __clock_gettime in bench-timing.h
since it is no longer needed.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoReplace val with __val in TUNABLE_SET_VAL_IF_VALID_RANGE
H.J. Lu [Thu, 4 Jun 2020 19:53:28 +0000 (12:53 -0700)] 
Replace val with __val in TUNABLE_SET_VAL_IF_VALID_RANGE

There are:

 #define TUNABLE_SET_VAL_IF_VALID_RANGE(__cur, __val, __type)                 \
({                                                                            \
  __type min = (__cur)->type.min;                                             \
  __type max = (__cur)->type.max;                                             \
                                                                              \
  if ((__type) (__val) >= min && (__type) (val) <= max)                       \
                                           ^^^ Should be __val
    {                                                                         \
      (__cur)->val.numval = val;                                              \
                            ^^^ Should be __val
      (__cur)->initialized = true;                                            \
    }                                                                         \
})

Luckily since all TUNABLE_SET_VAL_IF_VALID_RANGE usages are

TUNABLE_SET_VAL_IF_VALID_RANGE (cur, val, int64_t);

this didn't cause any issues.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agosupport: Fix detecting hole support on >2KB-block filesystems
Samuel Thibault [Thu, 4 Jun 2020 18:52:19 +0000 (20:52 +0200)] 
support: Fix detecting hole support on >2KB-block filesystems

When detecting hole support, we write at 16MiB, and filesystems will
typically need two levels of data to record that. On filesystems with
8KB block, the two indirection blocks will require a total of 16KB
overhead, thus 32 512-byte sectors.

Spotted on GNU/Hurd with a 4KB blocks filesystem, but also happens on Linux
with 4KB or 8KB blocks filesystems.

* support/support_descriptor_supports_holes.c
(support_descriptor_supports_holes): Set block_headroom to 32.

4 years agopowerpc: Fix powerpc64le due a7a3435c9a
Adhemerval Zanella [Thu, 4 Jun 2020 11:54:08 +0000 (08:54 -0300)] 
powerpc: Fix powerpc64le due a7a3435c9a

The build uses an undefined macro evaluation for fmaf128 build.
For now set USE_FMAL_BUILTIN and USE_FMAF128_BUILTIN to 0.

Checked with a build for:

  powerpc64le-linux-gnu-power9-disable-multi-arch
  powerpc64le-linux-gnu-power9
  powerpc64le-linux-gnu
  powerpc64-linux-gnu-power8
  powerpc64-linux-gnu
  powerpc-linux-gnu-power4
  powerpc-linux-gnu

4 years agomanual/jobs.texi: remove unused var from example code
Aurélien Aptel [Sat, 23 May 2020 19:18:09 +0000 (21:18 +0200)] 
manual/jobs.texi: remove unused var from example code

The do_job_notification() function defines a variable without using
it. Remove it.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agopowerpc/fpu: use generic fma functions
Vineet Gupta [Fri, 29 May 2020 23:12:44 +0000 (16:12 -0700)] 
powerpc/fpu: use generic fma functions

Tested with build-many-glibcs for powerpc-linux-gnu

This is a non functional change and powerpc libm before/after was
byte invariant as compared below:

| cd /SCRATCH/vgupta/gnu/install-glibc-A-baseline
| for i in `find . -name libm-2.31.9000.so`; do
|   echo $i; diff $i /SCRATCH/vgupta/gnu/install-glibc-C-reduce-scope/$i ;
|   echo $?;
| done

| ./aarch64-linux-gnu/lib64/libm-2.31.9000.so
| 0
| ./arm-linux-gnueabi/lib/libm-2.31.9000.so
| 0
| ./x86_64-linux-gnu/lib64/libm-2.31.9000.so
| 0
| ./arm-linux-gnueabihf/lib/libm-2.31.9000.so
| 0
| ./riscv64-linux-gnu-rv64imac-lp64/lib64/lp64/libm-2.31.9000.so
| 0
| ./riscv64-linux-gnu-rv64imafdc-lp64/lib64/lp64/libm-2.31.9000.so
| 0
| ./powerpc-linux-gnu/lib/libm-2.31.9000.so
| 0
| ./microblaze-linux-gnu/lib/libm-2.31.9000.so
| 0
| ./nios2-linux-gnu/lib/libm-2.31.9000.so
| 0
| ./hppa-linux-gnu/lib/libm-2.31.9000.so
| 0
| ./s390x-linux-gnu/lib64/libm-2.31.9000.so
| 0

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch/fpu: use generic builtins based math functions
Vineet Gupta [Fri, 29 May 2020 23:06:59 +0000 (16:06 -0700)] 
aarch/fpu: use generic builtins based math functions

introduce sysdep header math-use-builtins.h to replace aarch64
implementations with corresponding generic ones.

 - newly inroduced generic sqrt{,f}, fma{,f}
 - existing floor{,f}, nearbyint{,f}, rint{,f}, round{,f}, trunc{,f}
 - Note that generic copysign was already enabled (via generic
   math-use-builtins.h) now thru sysdep header

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

This is a non functional change and aarch64 libm before/after was
byte invariant as compared below:

| cd /SCRATCH/vgupta/gnu/install-glibc-A-baseline
| for i in `find . -name libm-2.31.9000.so`; do
|   echo $i; diff $i /SCRATCH/vgupta/gnu/install-glibc-C-reduce-scope/$i ;
|   echo $?;
| done

| ./aarch64-linux-gnu/lib64/libm-2.31.9000.so
| 0
| ./arm-linux-gnueabi/lib/libm-2.31.9000.so
| 0
| ./x86_64-linux-gnu/lib64/libm-2.31.9000.so
| 0
| ./arm-linux-gnueabihf/lib/libm-2.31.9000.so
| 0
| ./riscv64-linux-gnu-rv64imac-lp64/lib64/lp64/libm-2.31.9000.so
| 0
| ./riscv64-linux-gnu-rv64imafdc-lp64/lib64/lp64/libm-2.31.9000.so
| 0
| ./powerpc-linux-gnu/lib/libm-2.31.9000.so
| 0
| ./microblaze-linux-gnu/lib/libm-2.31.9000.so
| 0
| ./nios2-linux-gnu/lib/libm-2.31.9000.so
| 0
| ./hppa-linux-gnu/lib/libm-2.31.9000.so
| 0
| ./s390x-linux-gnu/lib64/libm-2.31.9000.so
| 0

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoieee754: provide gcc builtins based generic fma functions
Vineet Gupta [Fri, 29 May 2020 22:58:33 +0000 (15:58 -0700)] 
ieee754: provide gcc builtins based generic fma functions

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoieee754: provide gcc builtins based generic sqrt functions
Vineet Gupta [Fri, 29 May 2020 22:21:39 +0000 (15:21 -0700)] 
ieee754: provide gcc builtins based generic sqrt functions

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: Use __pthread_attr_setsigmask_internal for timer helper thread
Florian Weimer [Tue, 19 May 2020 10:03:44 +0000 (12:03 +0200)] 
Linux: Use __pthread_attr_setsigmask_internal for timer helper thread

timer_create needs to create threads with all signals blocked,
including SIGTIMER (which happens to equal SIGCANCEL).

Fixes commit b3cae39dcbfa2432b3f3aa28854d8ac57f0de1b8 ("nptl: Start
new threads with all signals blocked [BZ #25098]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np
Florian Weimer [Tue, 2 Jun 2020 08:34:55 +0000 (10:34 +0200)] 
nptl: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Make pthread_attr_t dynamically extensible
Florian Weimer [Tue, 2 Jun 2020 08:33:30 +0000 (10:33 +0200)] 
nptl: Make pthread_attr_t dynamically extensible

This introduces the function __pthread_attr_extension to allocate the
extension space, which is freed by pthread_attr_destroy.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Destroy the default thread attribute as part of freeres
Florian Weimer [Tue, 19 May 2020 09:03:11 +0000 (11:03 +0200)] 
nptl: Destroy the default thread attribute as part of freeres

This avoids a spurious memory leak report by valgrind.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Change type of __default_pthread_attr
Florian Weimer [Mon, 18 May 2020 16:25:18 +0000 (18:25 +0200)] 
nptl: Change type of __default_pthread_attr

union pthread_attr_transparent has always the correct size, even if
pthread_attr_t has padding that is not present in struct pthread_attr.

This should not result in an observable behavioral change.  The
existing code appears to have been correct, but it was brittle because
it was not clear which functions were allowed to write to an entire
pthread_attr_t argument (e.g., by copying it).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Use __pthread_attr_setaffinity_np in pthread_getattr_np
Florian Weimer [Fri, 15 May 2020 15:38:57 +0000 (17:38 +0200)] 
nptl: Use __pthread_attr_setaffinity_np in pthread_getattr_np

This avoids duplicating the code for the affinity mask allocation
handling.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Use __pthread_getattr_default_np in pthread_create
Florian Weimer [Mon, 18 May 2020 15:58:30 +0000 (17:58 +0200)] 
nptl: Use __pthread_getattr_default_np in pthread_create

This removes another instance of custom attribute copying code.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Add internal alias __pthread_getattr_default_np
Florian Weimer [Fri, 15 May 2020 20:49:46 +0000 (22:49 +0200)] 
nptl: Add internal alias __pthread_getattr_default_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agohtl: Fix gsync_wait symbol exposition
Samuel Thibault [Mon, 1 Jun 2020 20:21:08 +0000 (22:21 +0200)] 
htl: Fix gsync_wait symbol exposition

* sysdeps/htl/pt-cond-destroy.c (__pthread_cond_destroy): Call
__gsync_wait instead of gsync_wait.

4 years agohtl: Make pthread_cond_destroy wait for threads to be woken
Samuel Thibault [Mon, 1 Jun 2020 17:27:48 +0000 (17:27 +0000)] 
htl: Make pthread_cond_destroy wait for threads to be woken

This allows to reuse the storage after calling pthread_cond_destroy.

* sysdeps/htl/bits/types/struct___pthread_cond.h (__pthread_cond):
Replace unused struct __pthread_condimpl *__impl field with unsigned int
__wrefs.
(__PTHREAD_COND_INITIALIZER): Update accordingly.
* sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal):
Register as waiter in __wrefs field. On unregistering, wake any pending
pthread_cond_destroy.
* sysdeps/htl/pt-cond-destroy.c (__pthread_cond_destroy): Register wake
request in __wrefs.
* nptl/Makefile (tests): Move tst-cond20 tst-cond21 to...
* sysdeps/pthread/Makefile (tests): ... here.
* nptl/tst-cond20.c nptl/tst-cond21.c: Move to...
* sysdeps/pthread/tst-cond20.c sysdeps/pthread/tst-cond21.c: ... here.

4 years agohtl: Enable more cond tests
Samuel Thibault [Mon, 1 Jun 2020 17:06:21 +0000 (17:06 +0000)] 
htl: Enable more cond tests

* nptl/Makefile (tests): Move tst-cond11 and tst-cond27 to...
* sysdeps/pthread/Makefile (tests): ... here.

4 years agotst-cond11: Fix build with _SC_MONOTONIC_CLOCK > 0
Samuel Thibault [Mon, 1 Jun 2020 17:04:02 +0000 (17:04 +0000)] 
tst-cond11: Fix build with _SC_MONOTONIC_CLOCK > 0

* sysdeps/pthread/tst-cond11.c (do_test): Fix misplaced brace.

4 years agombstowcs: Document, test, and fix null pointer dst semantics (Bug 25219)
Carlos O'Donell [Thu, 21 May 2020 21:50:53 +0000 (17:50 -0400)] 
mbstowcs: Document, test, and fix null pointer dst semantics (Bug 25219)

The function mbstowcs, by an XSI extension to POSIX, accepts a null
pointer for the destination wchar_t array.  This API behaviour allows
you to use the function to compute the length of the required wchar_t
array i.e. does the conversion without storing it and returns the
number of wide characters required.

We remove the __write_only__ markup for the first argument because it
is not true since the destination may be a null pointer, and so the
length argument may not apply.  We remove the markup otherwise the new
test case cannot be compiled with -Werror=nonnull.

We add a new test case for mbstowcs which exercises the destination is
a null pointer behaviour which we have now explicitly documented.

The mbsrtowcs and mbsnrtowcs behave similarly, and mbsrtowcs is
documented as doing this in C11, even if the standard doesn't come out
and call out this specific use case.  We add one note to each of
mbsrtowcs and mbsnrtowcs to call out that they support a null pointer
for the destination.

The wcsrtombs function behaves similarly but in the other way around
and allows you to use a null destination pointer to compute how many
bytes you would need to convert the wide character input.  We document
this particular case also, but leave wcsnrtombs as a references to
wcsrtombs, so the reader must still read the details of the semantics
for wcsrtombs.

4 years agobuild: Use FAIL_EXIT1 () on failure to exec child [BZ #23990]
Girish Joshi [Fri, 29 May 2020 13:11:24 +0000 (10:11 -0300)] 
build: Use FAIL_EXIT1 () on failure to exec child [BZ #23990]

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agomanual: Fix backtraces code example [BZ #10441]
Girish Joshi [Fri, 29 May 2020 13:06:53 +0000 (10:06 -0300)] 
manual: Fix backtraces code example [BZ #10441]

Validation for pointer returned by backtrace_symbols () added.
Type of variables size and i is changed from size_t to int.

Variable size is used to collect the result from backtrace ()
that is an int. i is the loop counter variable so it can be an int.

Since, size_t size is changed to int size, in printf %zd is changed to %d.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agohurd: Fix fexecve
Samuel Thibault [Thu, 28 May 2020 23:28:07 +0000 (23:28 +0000)] 
hurd: Fix fexecve

* sysdeps/mach/hurd/fexecve.c (fexecve): Re-lookup fd with O_EXEC before
calling _hurd_exec_paths.

4 years agoi386: Remove unused file sysdeps/unix/i386/sysdep.S
Florian Weimer [Thu, 28 May 2020 08:50:24 +0000 (10:50 +0200)] 
i386: Remove unused file sysdeps/unix/i386/sysdep.S

Linux overrides this file via sysdeps/unix/sysv/linux/i386/sysdep.c.
Hurd does not have sysdeps/unix/i386 on its search path, so it uses
csu/sysdep.c instead.

4 years agohurd: fix ptsname error when called on a non-tty
Samuel Thibault [Thu, 28 May 2020 10:22:36 +0000 (10:22 +0000)] 
hurd: fix ptsname error when called on a non-tty

* sysdeps/mach/hurd/ptsname.c (__ptsname_internal): Replace
not-supported errors from __term_get_peername with ENOTTY.

4 years agohurd: Fix fdopendir checking for directory type
Samuel Thibault [Thu, 28 May 2020 10:13:14 +0000 (10:13 +0000)] 
hurd: Fix fdopendir checking for directory type

* sysdeps/mach/hurd/fdopendir.c (__fdopendir): Lookup "./" instead of
"/" that would designate the root of the filesystem.

4 years agoi386: Remove NO_TLS_DIRECT_SEG_REFS handling
Florian Weimer [Thu, 28 May 2020 08:51:15 +0000 (10:51 +0200)] 
i386: Remove NO_TLS_DIRECT_SEG_REFS handling

This was needed for 32-bit PV Xen, which has been superseded by this
point according to Xen developers.

4 years agoHurd: Move <hurd/sigpreempt.h> internals into wrapper header
Florian Weimer [Thu, 28 May 2020 09:19:04 +0000 (11:19 +0200)] 
Hurd: Move <hurd/sigpreempt.h> internals into wrapper header

_hurdsig_preemptors and _hurdsig_preempted_set are not ABI symbols,
so do not declare them.  HURD_PREEMPT_SIGNAL_P is an implementation
detail, so move it as well.

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
4 years agoHurd: Use __sigmask in favor of deprecated sigmask
Florian Weimer [Thu, 28 May 2020 09:17:51 +0000 (11:17 +0200)] 
Hurd: Use __sigmask in favor of deprecated sigmask

This fixes various build errors due to deprecation warnings.

Fixes commit 02802fafcf6e11ea3f998f685035ffe568dfddeb
("signal: Deprecate additional legacy signal handling functions").

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
4 years agohurd: Fix pselect atomicity
Samuel Thibault [Wed, 27 May 2020 23:42:24 +0000 (23:42 +0000)] 
hurd: Fix pselect atomicity

In case the signal arrives before the __mach_msg call, we need to catch
between the sigprocmask call and the __mach_msg call.  Let's just reuse
the support for sigsuspend to make the signal send a message that
our __mach_msg call will just receive.

* hurd/hurdselect.c (_hurd_select): Add sigport and ss variables. When
sigmask is not NULL, create a sigport port and register as
ss->suspended.  Add it to the portset.  When we receive a message on it,
set error to EINTR.  Clean up sigport and portset appropriately.

* hurd/hurdsig.c (wake_sigsuspend): Note that pselect also uses it.

4 years agoelf: Remove extra hwcap mechanism from ldconfig
Florian Weimer [Thu, 28 May 2020 08:21:17 +0000 (10:21 +0200)] 
elf: Remove extra hwcap mechanism from ldconfig

Historically, this mechanism was used to process "nosegneg"
subdirectories, and it is still used to include the "tls"
subdirectories.  With nosegneg support gone from ld.so, this is part
no longer useful.

The entire mechanism is not well-designed because it causes the
meaning of hwcap bits in ld.so.cache to depend on the kernel version
that was used to generate the cache, which makes it difficult to use
this mechanism for anything else in the future.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoelf: Do not read hwcaps from the vDSO in ld.so
Florian Weimer [Thu, 28 May 2020 08:20:56 +0000 (10:20 +0200)] 
elf: Do not read hwcaps from the vDSO in ld.so

This was only ever used for the "nosegneg" flag.  This approach for
passing hardware capability information creates a subtle dependency
between the kernel and userspace, and ld.so.cache contents.  It seems
inappropriate for toady, where people expect to be able to run
system images which very different kernel versions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agolinux: Use internal DIR locks when accessing filepos on telldir
Adhemerval Zanella [Tue, 14 Apr 2020 20:41:56 +0000 (17:41 -0300)] 
linux: Use internal DIR locks when accessing filepos on telldir

Since it might change during a readdir call.

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

4 years agoUpdate i386 libm-test-ulps
Samuel Thibault [Tue, 26 May 2020 11:21:57 +0000 (13:21 +0200)] 
Update i386 libm-test-ulps

4 years agohtl: Add clock variants
Samuel Thibault [Tue, 26 May 2020 00:09:11 +0000 (00:09 +0000)] 
htl: Add clock variants

* htl/pt-join.c (__pthread_join): Move implementation to...
(__pthread_join_common): ... new function. Add try, timed and clock support.
(__pthread_join): Reimplement on top of __pthread_join_common.
(__pthread_tryjoin_np, __pthread_timedjoin_np, __pthread_clockjoin_np):
Implement on top of __pthread_join_common.
(pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np): New
aliases.

* hurd/hurdlock.c (__lll_abstimed_wait, __lll_abstimed_xwait,
__lll_abstimed_lock): Check for supported clock.

* sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal):
Add clockid parameter and support it.
(__pthread_cond_timedwait): Pass -1 as clockid.
(__pthread_cond_clockwait): New function.
(pthread_cond_clockwait): New alias.
* sysdeps/htl/pt-cond-wait.c (__pthread_cond_timedwait_internal): Update
prototype.
(__pthread_cond_wait): Pass -1 as clockid.

* sysdeps/htl/pt-rwlock-timedrdlock.c
(__pthread_rwlock_timedrdlock_internal): Add clockid parameter, and
support id.
(__pthread_rwlock_clockrdlock): New function.
(pthread_rwlock_clockrdlock): New alias.
* sysdeps/htl/pt-rwlock-rdlock.c (__pthread_rwlock_timedrdlock_internal): Update
prototype.
(__pthread_rwlock_rdlock): Pass -1 as clockid.

* sysdeps/htl/pt-rwlock-timedwrlock.c
(__pthread_rwlock_timedwrlock_internal): Add clockid parameter, and
support id.
(__pthread_rwlock_clockwrlock): New function.
(pthread_rwlock_clockwrlock): New alias.
* sysdeps/htl/pt-rwlock-wrlock.c (__pthread_rwlock_timedwrlock_internal): Update
prototype.
(__pthread_rwlock_wrlock): Pass -1 as clockid.

* sysdeps/mach/hurd/htl/pt-mutex-timedlock.c (__pthread_mutex_timedlock): Move implementation to
(__pthread_mutex_clocklock): New function with additional clockid
parameter and support it.
(pthread_mutex_clocklock): New alias.
(__pthread_mutex_timedlock): Reimplement on top of __pthread_mutex_clocklock.

* sysdeps/htl/pthread.h (pthread_tryjoin_np, pthread_timedjoin_np,
pthread_clockjoin_np, pthread_mutex_clocklock, pthread_cond_clockwait,
pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock): New prototypes.
* sysdeps/htl/pthreadP.h (__pthread_cond_clockwait): New prototype.

* htl/Versions (GLIBC_2.32): Add pthread_cond_clockwait,
pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock,
pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np.
* sysdeps/mach/hurd/i386/libpthread.abilist (pthread_clockjoin_np,
pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock,
pthread_rwlock_clockwrlock, pthread_timedjoin_np, pthread_tryjoin_np):
New functions.

* nptl/tst-abstime.c, nptl/tst-join10.c, nptl/tst-join11.c, nptl/tst-join12.c,
nptl/tst-join13.c, nptl/tst-join14.c, nptl/tst-join2.c, nptl/tst-join3.c,
nptl/tst-join8.c, nptl/tst-join9.c, nptl/tst-mutex-errorcheck.c,
nptl/tst-pthread-mutexattr.c, nptl/tst-mutex11.c, nptl/tst-mutex5.c,
nptl/tst-mutex7.c, nptl/tst-mutex7robus.c, nptl/tst-mutex9.c,
nptl/tst-rwlock12.c, nptl/tst-rwlock14.c: Move to sysdeps/pthread.
* sysdeps/pthread/tst-mutex8.c: Move back to nptl.
* nptl/Makefile (tests): Move tst-mutex5, tst-mutex7, tst-mutex7robust,
tst-mutex9, tst-mutex11, tst-rwlock12, tst-rwlock14, tst-join2, tst-join3,
tst-join8, tst-join9 tst-join10, tst-join11, tst-join12, tst-join13, tst-join14,
tst-abstime, tst-mutex-errorcheck, tst-pthread-mutexattr to ...
* sysdeps/pthread/Makefile (tests): ... here.

4 years agosignal: Deprecate additional legacy signal handling functions
Florian Weimer [Mon, 25 May 2020 16:32:28 +0000 (18:32 +0200)] 
signal: Deprecate additional legacy signal handling functions

This needs a few test adjustments: In some cases, sigignore was
used for convenience (replaced with xsignal with SIG_IGN).  Tests
for the deprecated functions need to disable
-Wdeprecated-declarations, and for the sigmask deprecation,
-Wno-error.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoelf: Turn _dl_printf, _dl_error_printf, _dl_fatal_printf into functions
Florian Weimer [Mon, 25 May 2020 16:17:27 +0000 (18:17 +0200)] 
elf: Turn _dl_printf, _dl_error_printf, _dl_fatal_printf into functions

This change makes it easier to set a breakpoint on these calls.

This also addresses the issue that including <ldsodefs.h> without
<unistd.h> does not result usable _dl_*printf macros because of the
use of the STD*_FILENO macros there.

(The private symbol for _dl_fatal_printf will go away again
once the exception handling implementation is unified between
libc and ld.so.)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agox86: Update Intel Atom processor family optimization
H.J. Lu [Thu, 21 May 2020 20:36:54 +0000 (13:36 -0700)] 
x86: Update Intel Atom processor family optimization

Enable Intel Silvermont optimization for Intel Goldmont Plus.  Detect more
Intel Airmont processors.  Optimize Intel Tremont like Intel Silvermont
with rep string instructions.

4 years agoelf.h: add aarch64 property definitions
Szabolcs Nagy [Wed, 1 Apr 2020 08:25:47 +0000 (09:25 +0100)] 
elf.h: add aarch64 property definitions

These property values are specified by the AArch64 ELF ABI and
binutils can create binaries marked with them.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoelf.h: Add PT_GNU_PROPERTY
Szabolcs Nagy [Thu, 26 Mar 2020 09:22:12 +0000 (09:22 +0000)] 
elf.h: Add PT_GNU_PROPERTY

This program header type is already used in binaries on x86 and
aarch64 targets.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years ago<libc-symbols.h>: Add libpthread hidden alias support
Florian Weimer [Fri, 15 May 2020 20:04:31 +0000 (22:04 +0200)] 
<libc-symbols.h>: Add libpthread hidden alias support

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Use __pthread_attr_copy in pthread_setattr_default_np
Florian Weimer [Mon, 18 May 2020 16:11:48 +0000 (18:11 +0200)] 
nptl: Use __pthread_attr_copy in pthread_setattr_default_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Use __pthread_attr_copy in pthread_getattr_default_np (bug 25999)
Florian Weimer [Fri, 15 May 2020 19:24:59 +0000 (21:24 +0200)] 
nptl: Use __pthread_attr_copy in pthread_getattr_default_np (bug 25999)

pthread_getattr_default_np needs to make a deep copy.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Add __pthread_attr_copy for copying pthread_attr_t objects
Florian Weimer [Tue, 19 May 2020 10:32:39 +0000 (12:32 +0200)] 
nptl: Add __pthread_attr_copy for copying pthread_attr_t objects

Also add the private type union pthread_attr_transparent, to reduce
the amount of casting that is required.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Make __pthread_attr_init, __pthread_attr_destroy available internally
Florian Weimer [Fri, 15 May 2020 20:48:42 +0000 (22:48 +0200)] 
nptl: Make __pthread_attr_init, __pthread_attr_destroy available internally

pthread_attr_destroy needs to be a weak alias to avoid future
linknamespace failures.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Move pthread_gettattr_np into libc
Florian Weimer [Fri, 15 May 2020 09:01:49 +0000 (11:01 +0200)] 
nptl: Move pthread_gettattr_np into libc

This is part of the libpthread removal project:

    <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Use __getline instead of __getdelim to avoid a localplt failure.
Likewise for __getrlimit/getrlimit.

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_getattr_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py --only-linux pthread_getattr_np

The private export of __pthread_getaffinity_np is no longer needed, but
the hidden alias still necessary so that the symbol can be exported with
versioned_symbol.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Move pthread_getaffinity_np into libc
Florian Weimer [Fri, 15 May 2020 09:09:05 +0000 (11:09 +0200)] 
nptl: Move pthread_getaffinity_np into libc

This is part of the libpthread removal project:

    <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_getaffinity_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py pthread_getaffinity_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Move pthread_attr_setaffinity_np into libc
Florian Weimer [Fri, 15 May 2020 15:51:57 +0000 (17:51 +0200)] 
nptl: Move pthread_attr_setaffinity_np into libc

This is part of the libpthread removal project:

    <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

The symbol did not previously exist in libc, so a new GLIBC_2.32
symbol is needed, to get correct dependency for binaries which
use the symbol but no longer link against libpthread.

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_attr_setaffinity_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py pthread_attr_setaffinity_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Replace some stubs with the Linux implementation
Florian Weimer [Fri, 15 May 2020 09:26:37 +0000 (11:26 +0200)] 
nptl: Replace some stubs with the Linux implementation

The stubs for pthread_getaffinity_np, pthread_getname_np,
pthread_setaffinity_np, pthread_setname_np are replaced, and corresponding
tests are moved.

After the removal of the NaCl port, nptl is Linux-specific, and the stubs
are no longer needed.  This effectively reverts commit
c76d1ff5149bd03210f2bb8cd64446c51618d016 ("NPTL: Add stubs for Linux-only
extension functions.").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoLinux: Add missing handling of tai field to __ntp_gettime64
Florian Weimer [Wed, 20 May 2020 15:15:45 +0000 (17:15 +0200)] 
Linux: Add missing handling of tai field to __ntp_gettime64

This fixes a build error:

../sysdeps/unix/sysv/linux/ntp_gettime.c: In function ‘__ntp_gettime’:
../sysdeps/unix/sysv/linux/ntp_gettime.c:56:10: error: ‘ntv64.tai’ is used uninitialized in this function [-Werror=uninitialized]
   56 |   *ntv = valid_ntptimeval64_to_ntptimeval (ntv64);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

4 years agoMention GCC 10 attribute access.
Martin Sebor [Wed, 20 May 2020 15:40:34 +0000 (09:40 -0600)] 
Mention GCC 10 attribute access.

Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
4 years agoy2038: Replace __clock_gettime with __clock_gettime64
Lukasz Majewski [Mon, 16 Mar 2020 07:31:41 +0000 (08:31 +0100)] 
y2038: Replace __clock_gettime with __clock_gettime64

The __clock_gettime internal function is not supporting 64 bit time on
architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like e.g. ARM 32
bit).

The __clock_gettime64 function shall be used instead in the glibc itself as
it supports 64 bit time on those systems.
This patch does not bring any changes to systems with __WORDSIZE == 64 as
for them the __clock_gettime64 is aliased to __clock_gettime (in
./include/time.h).

4 years agomanual: Add missing section and node for clockid_t wait functions
Florian Weimer [Mon, 18 May 2020 16:43:16 +0000 (18:43 +0200)] 
manual: Add missing section and node for clockid_t wait functions

Without this, these functions appear under the node Default Thread
Attributes, which is confusing.

Eventually, the documentation should be merged with the (yet to be
documented) standardized functions.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoy2038: linux: Provide __ntp_gettimex64 implementation
Lukasz Majewski [Wed, 22 Apr 2020 08:49:39 +0000 (10:49 +0200)] 
y2038: linux: Provide __ntp_gettimex64 implementation

This patch provides new __ntp_gettimex64 explicit 64 bit function for getting
time parameters via NTP interface.

The call to __adjtimex in __ntp_gettime64 function has been replaced with
direct call to __clock_adjtime64 syscall, to simplify the code.

Moreover, a 32 bit version - __ntp_gettimex has been refactored to internally
use __ntp_gettimex64.

The __ntp_gettimex is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
ntptimeval and 64 bit struct __ntptimeval64.

Build tests:
./src/scripts/build-many-glibcs.py glibcs

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

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both __ntp_gettimex64 and __ntp_gettimex.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide __ntp_gettime64 implementation
Lukasz Majewski [Wed, 22 Apr 2020 08:54:01 +0000 (10:54 +0200)] 
y2038: linux: Provide __ntp_gettime64 implementation

This patch provides new __ntp_gettime64 explicit 64 bit function for getting
time parameters via NTP interface.

Internally, the __clock_adjtime64 syscall is used instead of __adjtimex. This
patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe.

Moreover, a 32 bit version - __ntp_gettime has been refactored to internally
use __ntp_gettime64.

The __ntp_gettime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
ntptimeval and 64 bit struct __ntptimeval64.

Build tests:
./src/scripts/build-many-glibcs.py glibcs

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

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both __ntp_gettime64 and __ntp_gettime.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: Provide conversion helpers for struct __ntptimeval64
Lukasz Majewski [Wed, 22 Apr 2020 22:20:51 +0000 (00:20 +0200)] 
y2038: Provide conversion helpers for struct __ntptimeval64

Those functions allow easy conversion between Y2038 safe, glibc internal
struct __ntptimeval64 and struct ntptimeval.

The reserved fields (i.e. __glibc_reserved{1234}) during conversion are
zeroed as well, to provide behavior similar to one in ntp_gettimex function
(where those are cleared before the struct ntptimeval is returned).

Those functions are put in Linux specific sys/timex.h file, as putting
them into glibc's local include/time.h would cause build break on HURD as
it doesn't support struct timex related syscalls.

Build tests:
./src/scripts/build-many-glibcs.py glibcs

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: Introduce struct __ntptimeval64 - new internal glibc type
Lukasz Majewski [Tue, 21 Apr 2020 23:01:21 +0000 (01:01 +0200)] 
y2038: Introduce struct __ntptimeval64 - new internal glibc type

This type is a glibc's "internal" type to get time parameters data from
Linux kernel (NTP daemon interface). It stores time in struct __timeval64
rather than struct timeval, which makes it Y2038-proof.

Build tests:
./src/scripts/build-many-glibcs.py glibcs

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide __adjtime64 implementation
Lukasz Majewski [Tue, 21 Apr 2020 18:56:24 +0000 (20:56 +0200)] 
y2038: linux: Provide __adjtime64 implementation

This patch provides new __adjtime64 explicit 64 bit function for adjusting
Linux kernel clock.

Internally, the __clock_adjtime64 syscall is used instead of __adjtimex. This
patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe.

Moreover, a 32 bit version - __adjtime has been refactored to internally use
__adjtime64.

The __adjtime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
timeval and 64 bit struct __timeval64.

Build tests:
./src/scripts/build-many-glibcs.py glibcs

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

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both __adjtime64 and __adjtime.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide ___adjtimex64 implementation
Lukasz Majewski [Tue, 21 Apr 2020 17:29:31 +0000 (19:29 +0200)] 
y2038: linux: Provide ___adjtimex64 implementation

This patch provides new ___adjtimex64 explicit 64 bit function for adjusting
Linux kernel clock.

Internally, the __clock_adjtime64 syscall is used. This patch is necessary
for having architectures with __WORDSIZE == 32 Y2038 safe.

Moreover, a 32 bit version - ___adjtimex has been refactored to internally
use ___adjtimex64.

The ___adjtimex is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
timex and 64 bit struct __timex64.

Last but not least, in ___adjtimex64 function the __clock_adjtime syscall has
been replaced with __clock_adjtime64 to support 64 bit time on architectures
with __WORDSIZE == 32 and __TIMESIZE != 64.

Build tests:
./src/scripts/build-many-glibcs.py glibcs

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

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both ___adjtimex64 and ___adjtimex.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide __clock_adjtime64 implementation
Lukasz Majewski [Tue, 21 Apr 2020 17:14:18 +0000 (19:14 +0200)] 
y2038: linux: Provide __clock_adjtime64 implementation

This patch replaces auto generated wrapper (as described in
sysdeps/unix/sysv/linux/syscalls.list) for clock_adjtime with one which adds
extra support for reading 64 bit time values on machines with __TIMESIZE != 64.

To achieve this goal new __clock_adjtime64 explicit 64 bit function for
adjusting Linux clock has been added.
Moreover, a 32 bit version - __clock_adjtime has been refactored to internally
use __clock_adjtime64.

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

The new __clock_adjtime64 syscall available from Linux 5.1+ has been used, when
applicable.
Up till v5.4 in the Linux kernel there was a bug preventing this call from
obtaining correct struct's timex time.tv_sec time after time_t overflow
(i.e. not being Y2038 safe).

Build tests:
- ./src/scripts/build-many-glibcs.py glibcs

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

Linux kernel, headers and minimal kernel version for glibc build test matrix:
- Linux v5.1 (with clock_adjtime64) 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 clock_adjtime64
  syscall.

- Linux v4.19 (no clock_adjtime64 support) with default minimal kernel version
  for contemporary glibc (3.2.0)
  This kernel doesn't support clock_adjtime64 syscall, so the fallback to
  clock_adjtime 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 agoldconfig: Default to the new format for ld.so.cache
Josh Triplett [Tue, 19 May 2020 12:41:48 +0000 (14:41 +0200)] 
ldconfig: Default to the new format for ld.so.cache

glibc has supported this format for close to 20 years.

4 years agonss_compat: internal_end*ent may clobber errno, hiding ERANGE [BZ #25976]
Florian Weimer [Tue, 19 May 2020 12:09:38 +0000 (14:09 +0200)] 
nss_compat: internal_end*ent may clobber errno, hiding ERANGE [BZ #25976]

During cleanup, before returning from get*_r functions, the end*ent
calls must not change errno.  Otherwise, an ERANGE error from the
underlying implementation can be hidden, causing unexpected lookup
failures.  This commit introduces an internal_end*ent_noerror
function which saves and restore errno, and marks the original
internal_end*ent function as warn_unused_result, so that it is used
only in contexts were errors from it can be handled explicitly.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agopowerpc: Optimized rawmemchr for POWER9
Anton Blanchard [Thu, 14 May 2020 11:49:16 +0000 (21:49 +1000)] 
powerpc: Optimized rawmemchr for POWER9

This version uses vector instructions and is up to 60% faster on medium
matches and up to 90% faster on long matches, compared to the POWER7
version. A few examples:

                            __rawmemchr_power9  __rawmemchr_power7
Length   32, alignment  0:   2.27566             3.77765
Length   64, alignment  2:   2.46231             3.51064
Length 1024, alignment  0:  17.3059             32.6678

4 years agox86: Add --enable-cet=permissive
H.J. Lu [Mon, 27 Apr 2020 22:44:07 +0000 (15:44 -0700)] 
x86: Add --enable-cet=permissive

When CET is enabled, it is an error to dlopen a non CET enabled shared
library in CET enabled application.  It may be desirable to make CET
permissive, that is disable CET when dlopening a non CET enabled shared
library.  With the new --enable-cet=permissive configure option, CET is
disabled when dlopening a non CET enabled shared library.

Add DEFAULT_DL_X86_CET_CONTROL to config.h.in:

 /* The default value of x86 CET control.  */
 #define DEFAULT_DL_X86_CET_CONTROL cet_elf_property

which enables CET features based on ELF property note.

--enable-cet=permissive it to

 /* The default value of x86 CET control.  */
 #define DEFAULT_DL_X86_CET_CONTROL cet_permissive

which enables CET features permissively.

Update tst-cet-legacy-5a, tst-cet-legacy-5b, tst-cet-legacy-6a and
tst-cet-legacy-6b to check --enable-cet and --enable-cet=permissive.

4 years agoRemove NO_CTORS_DTORS_SECTIONS macro
Florian Weimer [Mon, 18 May 2020 12:56:26 +0000 (14:56 +0200)] 
Remove NO_CTORS_DTORS_SECTIONS macro

This was originally added to support binutils older than version
2.22:

  <https://sourceware.org/ml/libc-alpha/2010-12/msg00051.html>

Since 2.22 is older than the minimum required binutils version
for building glibc, we no longer need this.  (The changes do
not impact the statically linked startup code.)

4 years agoelf: Assert that objects are relocated before their constructors run
Florian Weimer [Mon, 18 May 2020 13:21:04 +0000 (15:21 +0200)] 
elf: Assert that objects are relocated before their constructors run

If we try to run constructors before relocation, this is always
a dynamic linker bug.  An assert is easier to notice than a call
via an invalid function pointer (which may not even produce a valid
call stack).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agopowerpc: Optimized stpcpy for POWER9
Anton Blanchard via Libc-alpha [Wed, 13 May 2020 23:08:35 +0000 (09:08 +1000)] 
powerpc: Optimized stpcpy for POWER9

Add stpcpy support to the POWER9 strcpy. This is up to 40% faster on
small strings and up to 90% faster on long relatively unaligned strings,
compared to the POWER8 version. A few examples:

                                        __stpcpy_power9  __stpcpy_power8
Length   20, alignments in bytes  4/ 4:  2.58246          4.8788
Length 1024, alignments in bytes  1/ 6: 24.8186          47.8528

4 years agopowerpc: Optimized strcpy for POWER9
Anton Blanchard via Libc-alpha [Wed, 13 May 2020 23:00:26 +0000 (09:00 +1000)] 
powerpc: Optimized strcpy for POWER9

This version uses VSX store vector with length instructions and is
significantly faster on small strings and relatively unaligned large
strings, compared to the POWER8 version. A few examples:

                                        __strcpy_power9  __strcpy_power8
Length   16, alignments in bytes  0/ 0: 2.52454          4.62695
Length  412, alignments in bytes  4/ 0: 11.6             22.9185

4 years agox86: Move CET control to _dl_x86_feature_control [BZ #25887]
H.J. Lu [Tue, 28 Apr 2020 17:05:25 +0000 (10:05 -0700)] 
x86: Move CET control to _dl_x86_feature_control [BZ #25887]

1. Include <dl-procruntime.c> to get architecture specific initializer in
rtld_global.
2. Change _dl_x86_feature_1[2] to _dl_x86_feature_1.
3. Add _dl_x86_feature_control after _dl_x86_feature_1, which is a
struct of 2 bitfields for IBT and SHSTK control

This fixes [BZ #25887].

4 years agosunrpc/tst-udp-*: Fix timeout value
Samuel Thibault [Sat, 16 May 2020 17:29:50 +0000 (19:29 +0200)] 
sunrpc/tst-udp-*: Fix timeout value

Following on 00c3da43a ('sunrpc/tst-udp-timeout: Fix timeout value').

While e.g. 2.5 timeout can be represented exactly with doubles, time stamps
may not be represented that exactly, and thus with coarse-grain clocks (e.g.
10ms) we may end up with 2.499-ish values due to rounding errors.

* sunrpc/tst-udp-timeout.c (test_udp_server): Add more timeout slack.
* sunrpc/tst-udp-nonblocking.c (do_test): Likewise.

4 years agoLinux: Remove remnants of the getcpu cache
Florian Weimer [Fri, 15 May 2020 09:32:30 +0000 (11:32 +0200)] 
Linux: Remove remnants of the getcpu cache

The getcpu cache was removed from the kernel in Linux 2.6.24.  glibc
support from the sched_getcpu implementation was removed in commit
dd26c44403582fdf10d663170f947dfe4b3207a0 ("Consolidate sched_getcpu").

4 years agoUpdate timezone code from tzcode 2020a
Paul Eggert [Fri, 15 May 2020 15:52:25 +0000 (08:52 -0700)] 
Update timezone code from tzcode 2020a

This patch updates files coming from tzcode to tzcode 2020a.
This is mostly for better support for Internet RFC 8536, by adding
support to zic for the Expires line (new to tzcode 2020a), the -b
option (new to 2019b) and the -r option (new to 2019a).
One trivial change to other glibc was needed.
* time/tzfile.c (__tzfile_read): Adjust to tzcode private.h renaming.
* timezone/private.h, timezone/tzfile.h, timezone/version:
* timezone/zdump.c, timezone/zic.c: Update from tzcode 2020a.

4 years agoaarch64: fix strcpy and strnlen for big-endian [BZ #25824]
Lexi Shao [Fri, 15 May 2020 10:48:59 +0000 (18:48 +0800)] 
aarch64: fix strcpy and strnlen for big-endian [BZ #25824]

This patch fixes the optimized implementation of strcpy and strnlen
on a big-endian arm64 machine.

The optimized method uses neon, which can process 128bit with one
instruction. On a big-endian machine, the bit order should be reversed
for the whole 128-bits double word. But with instuction
rev64 datav.16b, datav.16b
it reverses 64bits in the two halves rather than reversing 128bits.
There is no such instruction as rev128 to reverse the 128bits, but we
can fix this by loading the data registers accordingly.

Fixes 0237b61526e7("aarch64: Optimized implementation of strcpy") and
2911cb68ed3d("aarch64: Optimized implementation of strnlen").

Signed-off-by: Lexi Shao <shaolexi@huawei.com>
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
4 years agolocale: Add transliteration for Geresh, Gershayim (U+05F3, U+05F4)
Florian Weimer [Fri, 15 May 2020 08:38:10 +0000 (10:38 +0200)] 
locale: Add transliteration for Geresh, Gershayim (U+05F3, U+05F4)

ISO-8859-8-based locales will need this transliteration if the locale
files contain these Unicode characters.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agostring: Fix string/tst-memmove-overflow to compile with GCC 7
Florian Weimer [Thu, 14 May 2020 10:12:29 +0000 (12:12 +0200)] 
string: Fix string/tst-memmove-overflow to compile with GCC 7

GCC 8 relaxed what kind of expressions can be used in initializers,
and the previous use of static const variables relied on that.  Switch
to wide (non-int) enum constants instead, which is another GCC
extension that is more widely implemented.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAdd arch-syscall.h dependency for generating sysd-syscalls file
guojinhui [Thu, 14 May 2020 16:09:46 +0000 (18:09 +0200)] 
Add arch-syscall.h dependency for generating sysd-syscalls file

After using "make update-syscall-lists" to update arch-syscall.h for
new kernel versions, sysd-syscalls will not be not be regenerated.
This will cause a compile error because the new data is not being
picked up.

Fixes commit a1bd5f86739926469bbe0054b93305ff5905b070
("Linux: Use system call tables during build").

Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 years agoarm: XFAIL string/tst-memmove-overflow due to bug 25620
Florian Weimer [Wed, 13 May 2020 14:45:29 +0000 (16:45 +0200)] 
arm: XFAIL string/tst-memmove-overflow due to bug 25620

Also reduce the amount of output in case of a large-scale mismatch in
the copied data.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoelf: Remove redundant add_to_global_resize_failure call from dl_open_args
Florian Weimer [Tue, 12 May 2020 17:06:18 +0000 (19:06 +0200)] 
elf: Remove redundant add_to_global_resize_failure  call from dl_open_args

The second call does not do anything because the data structures have
already been resized by the call that comes before the demarcation
point.  Fixes commit a509eb117fac1d764b15eba64993f4bdb63d7f3c
("Avoid late dlopen failure due to scope, TLS slotinfo updates
[BZ #25112]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agostring: Add string/tst-memmove-overflow, a test case for bug 25620
Florian Weimer [Tue, 12 May 2020 17:02:08 +0000 (19:02 +0200)] 
string: Add string/tst-memmove-overflow, a test case for bug 25620

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agosupport: Add support_blob_repeat_allocate_shared
Florian Weimer [Tue, 12 May 2020 17:01:49 +0000 (19:01 +0200)] 
support: Add support_blob_repeat_allocate_shared

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: wait for pending setxid request also in detached thread (bug 25942)
Andreas Schwab [Thu, 7 May 2020 13:50:09 +0000 (15:50 +0200)] 
nptl: wait for pending setxid request also in detached thread (bug 25942)

There is a race between __nptl_setxid and exiting detached thread, which
causes a deadlock on stack_cache_lock.  The deadlock happens in this
state:

T1: setgroups -> __nptl_setxid (holding stack_cache_lock, waiting on cmdp->cntr == 0)
T2 (detached, exiting): start_thread -> __deallocate_stack (waiting on stack_cache_lock)
more threads waiting on stack_cache_lock in pthread_create

For non-detached threads, start_thread waits for its own setxid handler to
finish before exiting.  Do this for detached threads as well.

4 years agoaarch64: Accept PLT calls to __getauxval within libc.so
Florian Weimer [Tue, 12 May 2020 09:30:30 +0000 (11:30 +0200)] 
aarch64: Accept PLT calls to __getauxval within libc.so

When using outline atomics (-moutline-atomics, the default for ARMv8-A
starting with GCC 10), libgcc contains an ELF constructor which calls
__getauxval.  This code is built outside of glibc, so none of its
internal PLT avoidance schemes can be applied to it.  This change
suppresses the elf/check-localplt failure.

4 years agoUse unsigned constants for ICMP6 filters [BZ #22489]
Sergey [Fri, 24 Apr 2020 21:18:41 +0000 (17:18 -0400)] 
Use unsigned constants for ICMP6 filters [BZ #22489]

The core problem here is that the filter array elements are unsigned
but the computed constants are signed.  This both causes a
signededness conversion at the &= step and may cause undefined
behavior if the MSB is being modified.  This patch uses unsigned
constants to avoid both cases. - DJ

4 years agoLinux: Enhance glibcsyscalls.py to support listing system calls
Florian Weimer [Mon, 11 May 2020 20:23:34 +0000 (22:23 +0200)] 
Linux: Enhance glibcsyscalls.py to support listing system calls

The script can now be called to query the definition status of
system call numbers across all architectures, like this:

$ python3 sysdeps/unix/sysv/linux/glibcsyscalls.py query-syscall sync_file_range sync_file_range2
sync_file_range:
  defined: aarch64 alpha csky hppa i386 ia64 m68k microblaze mips/mips32 mips/mips64/n32 mips/mips64/n64 nios2 riscv/rv64 s390/s390-32 s390/s390-64 sh sparc/sparc32 sparc/sparc64 x86_64/64 x86_64/x32
  undefined: arm powerpc/powerpc32 powerpc/powerpc64
sync_file_range2:
  defined: arm powerpc/powerpc32 powerpc/powerpc64
  undefined: aarch64 alpha csky hppa i386 ia64 m68k microblaze mips/mips32 mips/mips64/n32 mips/mips64/n64 nios2 riscv/rv64 s390/s390-32 s390/s390-64 sh sparc/sparc32 sparc/sparc64 x86_64/64 x86_64/x32

This command lists the headers containing the system call numbers:

$ python3 sysdeps/unix/sysv/linux/glibcsyscalls.py list-headers

The argument parser code is based on a suggestion from Adhemerval Zanella.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoSuppress GCC 10 true positive warnings [BZ #25967]
Martin Sebor [Mon, 11 May 2020 17:29:39 +0000 (11:29 -0600)] 
Suppress GCC 10 true positive warnings [BZ #25967]

Suppress or avoid warnings in tests that exercise failure modes by making
calls with invalid arguments.

Reviewed-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Joseph Myers <joseph@codesourcery.com>
4 years agoPOWER: Add context-synchronizing instructions to pkey_write [BZ #25954]
Florian Weimer [Mon, 11 May 2020 09:20:02 +0000 (11:20 +0200)] 
POWER: Add context-synchronizing instructions to pkey_write [BZ #25954]

Sandipan Das reported that,

"The Power ISA mandates that all writes to the Authority
Mask Register (AMR) must always be preceded as well as
succeeded by a context-synchronizing instruction. This
applies to both the privileged and unprivileged variants
of the Move To AMR instruction.

This [requirement] is from Table 6 of Chapter 11 in page 1134 of Power
ISA 3.0B. The document can be found here:
<https://ibm.ent.box.com/s/1hzcwkwf8rbju5h9iyf44wm94amnlcrv>
"

See this kernel patch submission:

<https://lore.kernel.org/linuxppc-dev/5f65cf37be993760de8112a88da194e3ccbb2bf8.1588959697.git.sandipan@linux.ibm.com/>

4 years agohurd: Add missing sigstate members initialization
Samuel Thibault [Sun, 10 May 2020 23:30:29 +0000 (01:30 +0200)] 
hurd: Add missing sigstate members initialization

* hurd/hurdsig.c (_hurd_thread_sigstate): Initialize
  critical_section_lock, active_resources, cancel, and cancel_hook fields.

4 years agox86-64: Use RDX_LP on __x86_shared_non_temporal_threshold [BZ #25966]
H.J. Lu [Sat, 9 May 2020 19:04:23 +0000 (12:04 -0700)] 
x86-64: Use RDX_LP on __x86_shared_non_temporal_threshold [BZ #25966]

Since __x86_shared_non_temporal_threshold is defined as

long int __x86_shared_non_temporal_threshold;

and long int is 4 bytes for x32, use RDX_LP to compare against
__x86_shared_non_temporal_threshold in assembly code.