]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
4 years agoelf: Use nocancel pread64() instead of lseek()+read()
Leandro Pereira [Wed, 2 Oct 2019 16:48:17 +0000 (12:48 -0400)] 
elf: Use nocancel pread64() instead of lseek()+read()

Transforms this, when linking in a shared object:

  openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  read(3, "\177ELF\2\1\1\3"..., 832) = 832
  lseek(3, 792, SEEK_SET)           = 792
  read(3, "\4\0\0\0\24\0\0\0"..., 68) = 68
  fstat(3, {st_mode=S_IFREG|0755, st_size=6699224, ...}) = 0
  lseek(3, 792, SEEK_SET)           = 792
  read(3, "\4\0\0\0\24\0\0\0"..., 68) = 68
  lseek(3, 864, SEEK_SET)           = 864
  read(3, "\4\0\0\0\20\0\0\0"..., 32) = 32

Into this:

  openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  read(3, "\177ELF\2\1\1\3"..., 832) = 832
  pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) = 68
  fstat(3, {st_mode=S_IFREG|0755, st_size=6699224, ...}) = 0
  pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) = 68
  pread(3, "\4\0\0\0\20\0\0\0"..., 32, 864) = 32

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAdd nocancel version of pread64()
Leandro Pereira [Wed, 2 Oct 2019 16:42:28 +0000 (12:42 -0400)] 
Add nocancel version of pread64()

This is in preparation for changes in the dynamic linker so that
pread() is used instead of lseek()+read().

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAdd run-one-test convenience target and makefile help text
DJ Delorie [Mon, 30 Sep 2019 20:04:52 +0000 (16:04 -0400)] 
Add run-one-test convenience target and makefile help text

Adds "make test" for re-running just one test.  Also adds
"make help" for help with our Makefile targets, and adds a
mini-help when you just run "make".

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoUpdate sysvipc kernel-features.h files for Linux 5.1
Adhemerval Zanella [Mon, 20 May 2019 15:17:46 +0000 (12:17 -0300)] 
Update sysvipc kernel-features.h files for Linux 5.1

Linux 5.1 adds missing SySV IPC syscalls to the syscall table for
remanining one that still uses the ipc syscall on glibc (m68k, mips-o32,
powerpc, s390, sh, and sparc32).  However the newly added direct ipc
syscall are different than the old ones:

  1. They do not expect IPC_64, meaning __IPC_64 should be set to zero
     when new syscalls are used.  And new syscalls can not be used
     for compat functions like __old_semctl (to emulated old sysvipc it
     requires to use the old __NR_ipc syscall without __IPC_64).
     Thus IPC_64 is redefined for newer kernels on affected ABIs.

  2. semtimedop and semop does not exist on 32-bit ABIs (only
     semtimedop_time64 is supplied).  The provided syscall wrappers only
     uses the wire-up syscall if __NR_semtimedop and __NR_semop are
     also defined.

Checked on x86_64-linux-gnu and i686-linux-gnu on both a 4.15 kernel
configure with default options and sysvipc tests on a 5.3.0 kernel with
--enable-kernel=5.1.

Tested-by: Paul A. Clarke <pc@us.ibm.com>
4 years agoS390: Add new s390 platform z15.
Stefan Liebler [Fri, 18 Oct 2019 12:57:14 +0000 (14:57 +0200)] 
S390: Add new s390 platform z15.

The new IBM z15 is added to platform string array.
The macro _DL_PLATFORMS_COUNT is incremented.

4 years agonptl: SIGCANCEL, SIGTIMER, SIGSETXID are always defined
Florian Weimer [Fri, 18 Oct 2019 12:29:04 +0000 (14:29 +0200)] 
nptl: SIGCANCEL, SIGTIMER, SIGSETXID are always defined

All nptl targets have these signal definitions nowadays.  This
changes also replaces the nptl-generic version of pthread_sigmask
with the Linux version.

Tested on x86_64-linux-gnu and i686-linux-gnu.  Built with
build-many-glibcs.py.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl/tst-cancel25 needs to be an internal test
Florian Weimer [Fri, 18 Oct 2019 12:28:49 +0000 (14:28 +0200)] 
nptl/tst-cancel25 needs to be an internal test

Otherwise the definition of SIGCANCEL is not visible.

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

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoRemove libc_hidden_def from __semtimedop stub
Florian Weimer [Thu, 17 Oct 2019 19:36:34 +0000 (21:36 +0200)] 
Remove libc_hidden_def from __semtimedop stub

This breaks the Hurd build after commit 765cdd0bffd77960ae852104f
("sysvipc: Implement semop based on semtimedop") added it to the stub.

4 years agosysvipc: Implement semop based on semtimedop
Adhemerval Zanella [Fri, 11 Oct 2019 14:39:04 +0000 (11:39 -0300)] 
sysvipc: Implement semop based on semtimedop

Besides semop being a subset of semtimedop, new 32-bit architectures
on Linux are not expected to provide the syscall (only the 64-bit time
semtimedop).

Also, Linux 5.1 only wired-up semtimedop for the 64-bit architectures
that missed it (powerpc, s390, and sparc).  This simplifies the code
to support it.

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

Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 years agoipc: Refactor sysvipc internal definitions
Adhemerval Zanella [Wed, 15 May 2019 18:20:58 +0000 (15:20 -0300)] 
ipc: Refactor sysvipc internal definitions

This patch refactor the internal sysvipc in two main points:

  1. Add a new __ASSUME_SYSVIPC_DEFAULT_IPC_64 to infer the __IPC_64
     value to be used along either the multiplexed __NR_ipc or wired-up
     syscall.  The defaut value assumed for __IPC_64 is also changed
     from 0x100 to 0x0, aligning with Linux generic UAPI.  The idea
     is to simplify the Linux 5.1 wire-up for sysvipc syscalls for
     some 32-bit ABIs (which expectes __IPC_64 being 0x0) and simplify
     new ports (which will no longer need to add ipc_priv.h).

  2. It also removes some duplicated internal definition used on compat
     sysvipc symbols defined at ipc_priv.h (more specifically the
     __old_ipc_perm, SEMCTL_ARG_ADDRESS, MSGRCV_ARGS, and
     SEMTIMEDOP_IPC_ARGS).  The idea is also to make it simpler to enable
     the new wire-up sysvipc syscall provided by Linux v5.1.

There is no semantic change expected on any port.  Checked with a build
against all affected ABIs.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 years agoRename and split elf/tst-dlopen-aout collection of tests
Florian Weimer [Thu, 17 Oct 2019 06:51:21 +0000 (08:51 +0200)] 
Rename and split elf/tst-dlopen-aout collection of tests

From the beginning, elf/tst-dlopen-aout has exercised two different
bugs: (a) failure to report errors for a dlopen of the executable
itself in some cases (bug 24900) and (b) incorrect rollback of the
TLS modid allocation in case of a dlopen failure (bug 16634).

This commit replaces the test with elf/tst-dlopen-self for (a) and
elf/tst-dlopen-tlsmodid for (b).  The latter tests use the
elf/tst-dlopen-self binaries (or iconv) with dlopen, so they are
no longer self-dlopen tests.

Tested on x86_64-linux-gnu and i686-linux-gnu, with a toolchain that
does not default to PIE.

4 years agodlfcn: Remove remnants of caller sensitivity from dlinfo
Florian Weimer [Wed, 16 Oct 2019 16:19:51 +0000 (18:19 +0200)] 
dlfcn: Remove remnants of caller sensitivity from dlinfo

dlinfo operates on a specific handle, which means that there is no
caller sensivity involved.

4 years agoldconfig: handle .dynstr located in separate segment (bug 25087)
Andreas Schwab [Wed, 9 Oct 2019 15:46:47 +0000 (17:46 +0200)] 
ldconfig: handle .dynstr located in separate segment (bug 25087)

To determine the load offset of the DT_STRTAB section search for the
segment containing it, instead of using the load offset of the first
segment.

4 years agoldd: Print "not a dynamic executable" on standard error [BZ #24150]
Florian Weimer [Tue, 15 Oct 2019 14:41:51 +0000 (16:41 +0200)] 
ldd: Print "not a dynamic executable" on standard error [BZ #24150]

Tested with the testsuite on x86_64-linux-gnu, and manually.

Reviewed-By: Richard W.M. Jones <rjones@redhat.com>
4 years agoAdd PTRACE_GET_SYSCALL_INFO from Linux 5.3 to sys/ptrace.h.
Joseph Myers [Mon, 14 Oct 2019 23:43:52 +0000 (23:43 +0000)] 
Add PTRACE_GET_SYSCALL_INFO from Linux 5.3 to sys/ptrace.h.

Linux 5.3 adds a PTRACE_GET_SYSCALL_INFO constant, with an associated
structure and PTRACE_SYSCALL_INFO_* constants.

This patch adds these to sys/ptrace.h in glibc
(PTRACE_GET_SYSCALL_INFO in each architecture version, the rest in
bits/ptrace-shared.h).  As with previous such constants and associated
structures, the glibc version of the structure is named struct
__ptrace_syscall_info.

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

4 years agoMove ChangeLog to ChangeLog.old/ChangeLog.19 changelog-ends-here
Florian Weimer [Fri, 11 Oct 2019 20:42:32 +0000 (22:42 +0200)] 
Move ChangeLog to ChangeLog.old/ChangeLog.19

We no longer maintain a manually-written ChangeLog file:

  <https://sourceware.org/ml/libc-alpha/2019-09/msg00333.html>
  <https://sourceware.org/ml/libc-alpha/2019-10/msg00131.html>

Instead the release manager is expected to generate a ChangeLog-like
file using scripts/gitlog_to_changelog.py.  For further details,
see commit f2144b7874b23be7c7eb184ec601633ec6fa8fac ("Script to
generate ChangeLog-like output from git log").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agomanual: Remove warning in the documentation of the abort function
Florian Weimer [Fri, 11 Oct 2019 18:15:24 +0000 (20:15 +0200)] 
manual: Remove warning in the documentation of the abort function

The warning is confusing to those who do not understand the context,
and the warning is easy to misunderstand:

A reader needs to know that it was written by someone who is generally
skeptical of government influence and control, otherwise it reads as
an affirmation of the U.S. government's role as the ultimate editor of
the manual.  This is precisely the opposite of what the warning
intends to convey.  (Reportedly, it criticizes that several
U.S. administrations have tried to restrict the medical advice that
U.S.-funded health care workers can provide abroad, considering that
censorship.)

The warning is also misleading on a technical level.  A reader who
makes the connection to pregnancy termination will get the wrong
impression that calling the abort function will terminate subprocesses
of the current process, but this is not what generally happens.

Finally, for both GNU and the FSF, it is inappropriate to use female
reproductive health as mere joke material, since these organizations
do not concern themselves with such issues otherwise, and the warning
is purportedly about something else entirely.

This reinstates commit 340d9652b9d0e1d4136588f18b726662d195777c
("manual/startup.texi (Aborting a Program): Remove inappropriate
joke."), effectively reverting the revert in commit
ffa81c22a3ac0fb75ad9bf2b1c3cdbf9eafa0bc9 ("Revert:").

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agosysvipc: Set ipc_perm mode as mode_t (BZ#18231)
Adhemerval Zanella [Thu, 10 Oct 2019 18:13:11 +0000 (18:13 +0000)] 
sysvipc: Set ipc_perm mode as mode_t (BZ#18231)

This patch sets the mode field in ipc_perm as mode_t for all architectures,
as POSIX specification [1].  The changes required are as follow:

  1. It moves the ipc_perm definition out of ipc.h to its own header
     ipc_perm.h.  It also allows consolidate the IPC_* definition on
     only one header.

  2. The generic implementation follow the kernel ipc64_perm size so the
     syscall can be made directly without temporary buffer copy.  However,
     since glibc defines the MODE field as mode_t, it omits the __PAD1 field
     (since glibc does not export mode_t as 16-bit for any architecture).

     It is a two-fold improvement:

     2.1. New implementation which follow Linux UAPI will not need to
  provide an arch-specific ipc-perm.h header neither wrongly
          use the wrong 16-bit definition from previous default ipc.h
  (as csky did).

     2.1. It allows consolidate ipc_perm definition for architectures that
          already provide mode_t as 32-bit.

  3. All kernel ABIs for the supported architectures already provides the
     expected padding for mode type extension to 32-bit.  However, some
     architectures the padding has the wrong placement, so it requires
     the ipc control routines (msgctl, semctl, and shmctl) to adjust the
     mode field accordingly.  Currently they are armeb, microblaze, m68k,
     s390, and sheb.

     A new assume is added, __ASSUME_SYSVIPC_BROKEN_MODE_T, which the
     required ABIs define.

  4. For the ABIs that define __ASSUME_SYSVIPC_BROKEN_MODE_T, it also
     require compat symbols that do not adjust the mode field.

Checked on arm-linux-gnueabihf, aarch64-linux-gnu, powerpc64le-linux-gnu,
and x86_64-linux-gnu. I also checked the sysvipc tests on hppa-linux-gnu,
sh4-linux-gnu, s390x-linux-gnu, and s390-linux-gnu.

I also did a sanity test against armeb qemu usermode for the sysvipc
tests.

[BZ #18231]
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
bits/ipc-perm.h.
* sysdeps/unix/sysv/linux/aarch64/bits/ipc.h: Remove file.
* sysdeps/unix/sysv/linux/alpha/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/arm/kernel-features.h
[__BYTE_ORDER == __BIG_ENDIAN] (__ASSUME_SYSVIPC_BROKEN_MODE_T):
Define.
* sysdeps/sysv/linux/microblaze/kernel-features.h: Likewise.
* sysdeps/unix/sysv/linux/s390/kernel-features.h
[!__s390x__] (__ASSUME_SYSVIPC_BROKEN_MODE_T): Define.
* sysdeps/unix/sysv/linux/sh/kernel-features.h
(__ASSUME_SYSVIPC_BROKEN_MODE_T): Define.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h: Likewise.
* sysdeps/unix/sysv/linux/bits/ipc-perm.h: New file.
* sysdeps/unix/sysv/linux/powerpc/bits/ipc-perm.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/ipc-perm.h: Likewise.
* sysdeps/unix/sysv/linux/bits/ipc.h (ipc_perm): Move to
bits/ipc-perm.h.
* sysdeps/unix/sysv/linux/hppa/bits/ipc-perm.h: New file.
* sysdeps/unix/sysv/linux/kernel-features.h: Add comment about
__ASSUME_SYSVIPC_BROKEN_MODE_T semantic.
* sysdeps/unix/sysv/linux/msgctl.c (DEFAULT_VERSION): Define as
2.31 if __ASSUME_SYSVIPC_BROKEN_MODE_T is defined.
(msgctl_syscall, __msgctl_mode16): New symbol.
(__new_msgctl): Add bits for __ASSUME_SYSVIPC_BROKEN_MODE_T.
* sysdeps/unix/sysv/linux/semctl.c: Likewise.
* sysdeps/unix/sysv/linux/shmctl.c: Likewise.
* sysdeps/unix/sysv/linux/arm/be/libc.abilist (GLIBC_2.31): Add
msgctl, semctl, and shmctl.
* sysdeps/sysv/linux/microblaze/be/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/be/libc.abilist: Likewise.
* conform/data/sys/ipc.h-data: Only xfail {struct ipc_perm} mode_t
mode for Hurd.
* sysdeps/unix/sysv/linux/m68k/Versions (libc) [GLIBC_2.31]: Add
msgctl, semctl, and shmctl.
* sysdeps/unix/sysv/linux/arm/be/Versions: New file.
* sysdeps/unix/sysv/linux/microblaze/be/Versions: Likewise.
* sysdeps/unix/sysv/linux/sh/be/Versions: Likewise.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_ipc.h.html

4 years agoSimplify note processing
Andreas Schwab [Thu, 10 Oct 2019 08:45:31 +0000 (10:45 +0200)] 
Simplify note processing

This removes dead code during note processing.

4 years agosyscall-names.list: fix typos in comment
Dmitry V. Levin [Thu, 10 Oct 2019 00:38:28 +0000 (00:38 +0000)] 
syscall-names.list: fix typos in comment

* sysdeps/unix/sysv/linux/syscall-names.list: Fix typos in comment,
reformat the affected paragraph.

4 years agoy2038: linux: Provide __clock_settime64 implementation
Lukasz Majewski [Tue, 24 Sep 2019 12:22:42 +0000 (14:22 +0200)] 
y2038: linux: Provide __clock_settime64 implementation

This patch provides new __clock_settime64 explicit 64 bit function for
setting the time. Moreover, a 32 bit version - __clock_settime - has been
refactored to internally use __clock_settime64.

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

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

In this patch the internal padding (tv_pad) of struct __timespec64 is
left untouched (on systems with __WORDSIZE == 32) as Linux kernel ignores
upper 32 bits of tv_nsec.

Build tests:
- The code has been tested on x86_64/x86 (native compilation):
make 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 clock_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
  __clock_settime64 syscalls.

- Linux v4.19 (no clock_settime64 support) with default minimal kernel
  version for contemporary glibc

  This kernel doesn't support __clock_settime64 syscalls, so the fallback
  to clock_settime is tested.

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

* include/time.h (__clock_settime64):
  Add __clock_settime alias according to __TIMESIZE define
* sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime):
  Refactor this function to be used only on 32 bit machines as a wrapper
  on __clock_settime64.
* sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime64): Add
* sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime64):
  Use clock_settime64 kernel syscall (available from 5.1+ Linux)

4 years agoposix: Use posix_spawn for wordexp
Adhemerval Zanella [Thu, 25 Apr 2019 17:54:03 +0000 (17:54 +0000)] 
posix: Use posix_spawn for wordexp

This patch replaces the fork+exec by posix_spawn on wordexp, which
allows a better scability on Linux and simplifies the thread
cancellation handling.

The only change which can not be implemented with posix_spawn the
/dev/null check to certify it is indeed the expected device.  I am
not sure how effetive this check is since /dev/null tampering means
something very wrong with the system and this is the least of the
issues.  My view is the tests is really out of the place and the
hardening provided is minimum.

If the idea is still to provide such check, I think a possibilty
would be to open /dev/null, check it, add a dup2 file action, and
close the file descriptor.

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

* include/spawn.h (__posix_spawn_file_actions_addopen): New
prototype.
* posix/spawn_faction_addopen.c (posix_spawn_file_actions_addopen):
Add internal alias.
* posix/wordexp.c (create_environment, free_environment): New
functions.
(exec_comm_child, exec_comm): Use posix_spawn instead of fork+exec.
* posix/wordexp-test.c: Use libsupport.

4 years agomips: Do not malloc on getdents64 fallback
Adhemerval Zanella [Wed, 24 Jul 2019 16:48:12 +0000 (13:48 -0300)] 
mips: Do not malloc on getdents64 fallback

This patch changes how the fallback getdents64 implementation calls
non-LFS getdents by replacing the scratch_buffer with static buffer
plus a loop on getdents calls.  This avoids the potential malloc
call on scratch_buffer_set_array_size for large input buffer size
at the cost of more getdents syscalls.

It also adds a small optimization for older kernels, where the first
ENOSYS failure for getdents64 disable subsequent calls.

Check the dirent tests on a mips64-linux-gnu with getdents64 code
disabled.

* sysdeps/unix/sysv/linux/mips/mips64/getdents64.c (__getdents64):
Add small optimization for older kernel to avoid issuing
__NR_getdents64 on each call and replace scratch_buffer usage with
a static allocated buffer.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 years agosparc: Assume GOTDATA support in the toolchain
Florian Weimer [Wed, 9 Oct 2019 17:15:33 +0000 (19:15 +0200)] 
sparc: Assume GOTDATA support in the toolchain

HAVE_GCC_GOTDATA has apparently never been used.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years ago<dirent.h>: Remove wrong comment about getdents64 declaration
Petr Vorel [Wed, 9 Oct 2019 09:31:03 +0000 (11:31 +0200)] 
<dirent.h>: Remove wrong comment about getdents64 declaration

Originally the public interface for getdents64 was declared in
<unistd.h> in 51ea67d548. Later, b8b3d5a14e moved it to <dirent.h>.

Fixes: b8b3d5a14e ("Linux: Move getdents64 to <dirent.h>")
4 years agoChangeLog: Remove leading spaces before tabs and trailing whitespace
Florian Weimer [Wed, 9 Oct 2019 07:06:00 +0000 (09:06 +0200)] 
ChangeLog: Remove leading spaces before tabs and trailing whitespace

4 years agoMake tst-strftime2 and tst-strftime3 depend on locale generation
Gabriel F. T. Gomes [Tue, 8 Oct 2019 17:32:17 +0000 (14:32 -0300)] 
Make tst-strftime2 and tst-strftime3 depend on locale generation

Building the test cases in parallel might make tst-strftime2 and
tst-strftime3 fail.  Simply re-running the test case (or building
serially) makes the problem go away.  This patch adds the necessary
dependency to allow parallel builds in the time subdirectory.

Tested for powerpc64le.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agoposix/tst-wordexp-nocmd: Fix diagnostics output in test
Florian Weimer [Tue, 8 Oct 2019 16:55:48 +0000 (18:55 +0200)] 
posix/tst-wordexp-nocmd: Fix diagnostics output in test

4 years agowordexp: Split out command execution tests from posix/wordexp-test
Florian Weimer [Tue, 8 Oct 2019 11:04:15 +0000 (13:04 +0200)] 
wordexp: Split out command execution tests from posix/wordexp-test

Once wordexp switches to posix_spawn, testing for command execution
based on fork handlers will not work anymore.  Therefore, move these
subtests into  a new test, posix/tst-wordexp-nocmd, which uses a
different form of command execution detection, based on PID
namespaces.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_attr_setschedparam implementation into libc
Florian Weimer [Mon, 7 Oct 2019 18:00:38 +0000 (20:00 +0200)] 
nptl: Move pthread_attr_setschedparam implementation into libc

This is part of the libpthread removal project:

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoriscv: Remove support for variable page sizes
Florian Weimer [Mon, 7 Oct 2019 17:03:50 +0000 (19:03 +0200)] 
riscv: Remove support for variable page sizes

_dl_var_init is used to patch the read-only data section after
relocation.  Several architectures use this to update
GLRO(page_size) with the correct value for the static dlopen case,
where _rtld_global_ro has not been initialized by the dynamic
loader.

RISC-V does not need this.  The RISC-V Instruction Set Manual,
Volume II: Privileged Architecture, Document Version
20190608-Priv-MSU-Ratified says this:

    After much deliberation, we have settled on a conventional
    page size of 4 KiB for both RV32 and RV64. We expect this
    decision to ease the porting of low-level runtime software
    and device drivers. The TLB reach problem is ameliorated by
    transparent superpage support in modern operating systems
    [2]. Additionally, multi-level TLB hierarchies are quite
    inexpensive relative to the multi-level cache hierarchies
    whose address space they map.

    [2] Juan Navarro, Sitaram Iyer, Peter Druschel, and
      Alan Cox. Practical, transparent operating system support
      for superpages.  SIGOPS Oper. Syst. Rev., 36(SI):89–104,
      December 2002.

This means that the initialization of
_rtld_global_ro._dl_page_size in elf/rtld.c with EXEC_PAGESIZE
is sufficient for RISC-V.

4 years agonptl: Move pthread_attr_getschedparam implementation into libc
Florian Weimer [Mon, 7 Oct 2019 13:49:48 +0000 (15:49 +0200)] 
nptl: Move pthread_attr_getschedparam implementation into libc

This is part of the libpthread removal project:

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoelf: Assign TLS modid later during dlopen [BZ #24930]
Florian Weimer [Fri, 4 Oct 2019 19:23:51 +0000 (21:23 +0200)] 
elf: Assign TLS modid later during dlopen [BZ #24930]

Commit a42faf59d6d9f82e5293a9ebcc26d9c9e562b12b ("Fix BZ #16634.")
attempted to fix a TLS modid consistency issue by adding additional
checks to the open_verify function.  However, this is fragile
because open_verify cannot reliably predict whether
_dl_map_object_from_fd will later fail in the more complex cases
(such as memory allocation failures).  Therefore, this commit
assigns the TLS modid as late as possible.  At that point, the link
map pointer will eventually be passed to _dl_close, which will undo
the TLS modid assignment.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
4 years agoelf: Never use the file ID of the main executable [BZ #24900]
Florian Weimer [Fri, 4 Oct 2019 19:22:54 +0000 (21:22 +0200)] 
elf: Never use the file ID of the main executable [BZ #24900]

If the loader is invoked explicitly and loads the main executable,
it stores the file ID of the main executable in l_file_id.  This
information is not available if the main excutable is loaded by the
kernel, so this is another case where the two cases differ.

This enhances commit 23d2e5faf0bca6d9b31bef4aa162b95ee64cbfc6
("elf: Self-dlopen failure with explict loader invocation
[BZ #24900]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
4 years agonptl: Move pthread_attr_setinheritsched implementation into libc.
Florian Weimer [Fri, 4 Oct 2019 15:36:55 +0000 (17:36 +0200)] 
nptl: Move pthread_attr_setinheritsched implementation into libc.

This is part of the libpthread removal project:

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

4 years agoChangeLog update from my last commit
Paul A. Clarke [Thu, 3 Oct 2019 19:09:54 +0000 (14:09 -0500)] 
ChangeLog update from my last commit

I forgot to include the ChangeLog update with my last commit:
7b8481b330720d28c019a2e5994492a1923d5daa.

Signed-off-by: Paul A. Clarke <pc@us.ibm.com>
4 years agoDisable -Wmaybe-uninitialized for total_deadline in sunrpc/clnt_udp.c.
Joseph Myers [Wed, 2 Oct 2019 21:12:17 +0000 (21:12 +0000)] 
Disable -Wmaybe-uninitialized for total_deadline in sunrpc/clnt_udp.c.

To work around <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91691>
for RV32, we recently disabled -Wmaybe-uninitialized for some inline
functions in inet/net-internal.h, as included by sunrpc/clnt_udp.c.

The same error has now appeared with current GCC trunk for MIPS, in a
form that is located at the definition of the variable in question and
so unaffected by the disabling in inet/net-internal.h.  Thus, this
patch adds the same disabling around the definition of that variable,
to cover the MIPS case.

Tested with build-many-glibcs.py (compilers and glibcs stages) for
mips64-linux-gnu with GCC mainline.

* sunrpc/clnt_udp.c: Include <libc-diag.h>.
(clntudp_call): Disable -Wmaybe-uninitialized around declaration
of total_deadline.

4 years agostring/endian.h: Restore the __USE_MISC conditionals
Alistair Francis [Wed, 2 Oct 2019 17:00:40 +0000 (10:00 -0700)] 
string/endian.h: Restore the __USE_MISC conditionals

Commit 69fd157a3 "time: Add padding for the timespec if required"
caused a breakage in the glibc tests as the endian.h include file was
kept in the networking headers while the __USE_MISC #ifdefs had been
removed. This resulted in namespace violations in the networking
headers.

This patche restores the __USE_MISC conditionals in endian.h to fix the
test failures.

* string/endian.h: Restore the __USE_MISC conditionals.

4 years agoDisable warnings in string/tester.c at top level.
Joseph Myers [Wed, 2 Oct 2019 17:26:14 +0000 (17:26 +0000)] 
Disable warnings in string/tester.c at top level.

string/tester.c contains code that correctly triggers various GCC
warnings about dubious uses of string functions (uses that are being
deliberately tested there), and duly disables those warnings around
the relevant code.

A change in GCC mainline resulted in this code failing to compile with
a -Warray-bounds error, despite the location with the error having
-Warray-bounds already disabled.  This has been reported as
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91890>.  This patch
avoids that problem and possible future issues with these diagnostics
by moving all the warning disabling in this file to top level, as
suggested by Florian in
<https://sourceware.org/ml/libc-alpha/2019-10/msg00033.html>, rather
than only doing it locally around specific function calls.

Tested with build-many-glibcs.py for aarch64-linux-gnu with GCC
mainline (with only the conform/ failures noted in
<https://sourceware.org/ml/libc-alpha/2019-10/msg00043.html>).

* string/tester.c: Ignore -Warray-bounds and
-Wmemset-transposed-args at top level.
[__GNUC_PREREQ (7, 0)]: Ignore -Wrestrict and -Wstringop-overflow=
at top level.
[__GNUC_PREREQ (8, 0)]: Ignore -Wstringop-truncation at top level.
(test_stpncpy): Do not ignore warnings here.
(test_strncat): Likewise.
(test_strncpy): Likewise.
(test_memset): Likewise.

4 years agoY2038: Include proper header to provide support for struct timeval on HURD
Lukasz Majewski [Wed, 2 Oct 2019 08:19:55 +0000 (10:19 +0200)] 
Y2038: Include proper header to provide support for struct timeval on HURD

The HURD requires explicit inclusion of <bits/types/struct_timeval.h> to use
struct timeval in ./include/time.h.
For this particular glibc port, the proper header hasn't been included before
inclusion of time.h.

Tested with build-many-glibcs.py with i686-gnu and x86_64-linux-gnu:

build-many-glibcs.py /home/lukma/work/glibc/glibc-many-build --keep all compilers i686-gnu
build-many-glibcs.py /home/lukma/work/glibc/glibc-many-build --keep all glibcs i686-gnu

Also run of xcheck on x86_64:
./src/configure --prefix=/usr
make PARALLELMFLAGS="-j12" && make xcheck PARALLELMFLAGS="-j12"

* include/time.h: Add #include <bits/types/struct_timeval.h>

4 years ago[powerpc] No need to enter "Ignore Exceptions Mode"
Paul A. Clarke [Thu, 19 Sep 2019 16:11:04 +0000 (11:11 -0500)] 
[powerpc] No need to enter "Ignore Exceptions Mode"

Since at least POWER8, there is no performance advantage to entering
"Ignore Exceptions Mode", and doing so conditionally requires
 - the conditional logic, and
 - a system call.

Make it a no-op for uses within glibc.

4 years agoEnable passing arguments to the inferior in debugglibc.sh
Arjun Shankar [Wed, 2 Oct 2019 11:59:43 +0000 (13:59 +0200)] 
Enable passing arguments to the inferior in debugglibc.sh

This patch adds the ability to run debugglibc.sh's inferior program with
arguments specified on the command line. This enables convenient debugging
of non-testcase programs such as iconv/iconv_prog or other dynamically
linked programs. Program arguments may be passed using `--' as a separator.

For example:

  $ ./debugglibc.sh -b iconv -- iconv/iconv_prog -f ASCII -t UTF-8 input.txt

4 years agotime: Add padding for the timespec if required
Alistair Francis [Wed, 18 Sep 2019 23:51:23 +0000 (16:51 -0700)] 
time: Add padding for the timespec if required

If we are running on a 32-bit system with a 64-bit time_t we need to
ensure there is padding around the tv_nsec variable. This is requried as
the timespec is #defined to the __timespec64 struct.

* time/bits/types/struct_timespec.h: Add padding for the timespec if
required.

4 years agoSplit up endian.h to minimize exposure of BYTE_ORDER.
Alistair Francis [Fri, 20 Sep 2019 21:23:51 +0000 (14:23 -0700)] 
Split up endian.h to minimize exposure of BYTE_ORDER.

With only two exceptions (sys/types.h and sys/param.h, both of which
historically might have defined BYTE_ORDER) the public headers that
include <endian.h> only want to be able to test __BYTE_ORDER against
__*_ENDIAN.

This patch creates a new bits/endian.h that can be included by any
header that wants to be able to test __BYTE_ORDER and/or
__FLOAT_WORD_ORDER against the __*_ENDIAN constants, or needs
__LONG_LONG_PAIR.  It only defines macros in the implementation
namespace.

The existing bits/endian.h (which could not be included independently
of endian.h, and only defines __BYTE_ORDER and maybe __FLOAT_WORD_ORDER)
is renamed to bits/endianness.h.  I also took the opportunity to
canonicalize the form of this header, which we are stuck with having
one copy of per architecture.  Since they are so short, this means git
doesn’t understand that they were renamed from existing headers, sigh.

endian.h itself is a nonstandard header and its only remaining use
from a standard header is guarded by __USE_MISC, so I dropped the
__USE_MISC conditionals from around all of the public-namespace things
it defines.  (This means, an application that requests strict library
conformance but includes endian.h will still see the definition of
BYTE_ORDER.)

A few changes to specific bits/endian(ness).h variants deserve
mention:

 - sysdeps/unix/sysv/linux/ia64/bits/endian.h is moved to
   sysdeps/ia64/bits/endianness.h.  If I remember correctly, ia64 did
   have selectable endianness, but we have assembly code in
   sysdeps/ia64 that assumes it’s little-endian, so there is no reason
   to treat the ia64 endianness.h as linux-specific.

 - The C-SKY port does not fully support big-endian mode, the compile
   will error out if __CSKYBE__ is defined.

 - The PowerPC port had extra logic in its bits/endian.h to detect a
   broken compiler, which strikes me as unnecessary, so I removed it.

 - The only files that defined __FLOAT_WORD_ORDER always defined it to
   the same value as __BYTE_ORDER, so I removed those definitions.
   The SH bits/endian(ness).h had comments inconsistent with the
   actual setting of __FLOAT_WORD_ORDER, which I also removed.

 - I *removed* copyright boilerplate from the few bits/endian(ness).h
   headers that had it; these files record a single fact in a fashion
   dictated by an external spec, so I do not think they are copyrightable.

As long as I was changing every copy of ieee754.h in the tree, I
noticed that only the MIPS variant includes float.h, because it uses
LDBL_MANT_DIG to decide among three different versions of
ieee854_long_double.  This patch makes it not include float.h when
GCC’s intrinsic __LDBL_MANT_DIG__ is available.

* string/endian.h: Unconditionally define LITTLE_ENDIAN,
BIG_ENDIAN, PDP_ENDIAN, and BYTE_ORDER.  Condition byteswapping
macros only on !__ASSEMBLER__. Move the definitions of
__BIG_ENDIAN, __LITTLE_ENDIAN, __PDP_ENDIAN, __FLOAT_WORD_ORDER,
and __LONG_LONG_PAIR to...
* string/bits/endian.h: ...this new file, which includes
the renamed header bits/endianness.h for the definition of
__BYTE_ORDER and possibly __FLOAT_WORD_ORDER.

* string/Makefile: Install bits/endianness.h.
* include/bits/endian.h: New wrapper.

* bits/endian.h: Rename to bits/endianness.h.
Add multiple-include guard.  Rewrite the comment explaining what
the machine-specific variants of this file should do.

* sysdeps/unix/sysv/linux/ia64/bits/endian.h:
Move to sysdeps/ia64.

* sysdeps/aarch64/bits/endian.h
* sysdeps/alpha/bits/endian.h
* sysdeps/arm/bits/endian.h
* sysdeps/csky/bits/endian.h
* sysdeps/hppa/bits/endian.h
* sysdeps/ia64/bits/endian.h
* sysdeps/m68k/bits/endian.h
* sysdeps/microblaze/bits/endian.h
* sysdeps/mips/bits/endian.h
* sysdeps/nios2/bits/endian.h
* sysdeps/powerpc/bits/endian.h
* sysdeps/riscv/bits/endian.h
* sysdeps/s390/bits/endian.h
* sysdeps/sh/bits/endian.h
* sysdeps/sparc/bits/endian.h
* sysdeps/x86/bits/endian.h:
Rename to endianness.h; canonicalize form of file; remove
redundant definitions of __FLOAT_WORD_ORDER.

* sysdeps/powerpc/bits/endianness.h: Remove logic to check for
broken compilers.

* ctype/ctype.h
* sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h
* sysdeps/arm/nptl/bits/pthreadtypes-arch.h
* sysdeps/csky/nptl/bits/pthreadtypes-arch.h
* sysdeps/ia64/ieee754.h
* sysdeps/ieee754/ieee754.h
* sysdeps/ieee754/ldbl-128/ieee754.h
* sysdeps/ieee754/ldbl-128ibm/ieee754.h
* sysdeps/m68k/nptl/bits/pthreadtypes-arch.h
* sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h
* sysdeps/mips/ieee754/ieee754.h
* sysdeps/mips/nptl/bits/pthreadtypes-arch.h
* sysdeps/nios2/nptl/bits/pthreadtypes-arch.h
* sysdeps/nptl/pthread.h
* sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
* sysdeps/sh/nptl/bits/pthreadtypes-arch.h
* sysdeps/sparc/sparc32/ieee754.h
* sysdeps/unix/sysv/linux/generic/bits/stat.h
* sysdeps/unix/sysv/linux/generic/bits/statfs.h
* sysdeps/unix/sysv/linux/sys/acct.h
* wctype/bits/wctype-wchar.h:
Include bits/endian.h, not endian.h.

* sysdeps/unix/sysv/linux/hppa/pthread.h: Don’t include endian.h.

* sysdeps/mips/ieee754/ieee754.h: Use __LDBL_MANT_DIG__
in ifdefs, instead of LDBL_MANT_DIG.  Only include float.h
when __LDBL_MANT_DIG__ is not predefined, in which case
define __LDBL_MANT_DIG__ to equal LDBL_MANT_DIG.

4 years agoSync "language", "lang_name", "territory", "country_name" with CLDR/langtable
Mike FABIAN [Tue, 17 Sep 2019 15:20:32 +0000 (17:20 +0200)] 
Sync "language", "lang_name", "territory", "country_name" with CLDR/langtable

Sync these values with CLDR and langtable as much as possible.  Add
missing values.

If possible, take the values from CLDR, if CLDR does not have it,
take it from langtable. The values from langtable which are not from
CLDR are from  Wikipedia or native speakers.

4 years agoUse binutils 2.33 branch in build-many-glibcs.py.
Joseph Myers [Mon, 30 Sep 2019 22:21:39 +0000 (22:21 +0000)] 
Use binutils 2.33 branch in build-many-glibcs.py.

This patch makes build-many-glibcs.py default to binutils 2.33 branch.

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

* scripts/build-many-glibcs.py (Context.checkout): Default
binutils version to 2.33 branch.

4 years agoy2038: Provide conversion helpers for struct __timespec64
Lukasz Majewski [Mon, 25 Mar 2019 07:38:02 +0000 (08:38 +0100)] 
y2038: Provide conversion helpers for struct __timespec64

Those functions allow easy conversion between Y2038 safe struct
__timespec64 and other time related data structures (like struct timeval
or struct timespec).

* include/time.h (valid_timeval_to_timespec64): Add.
* include/time.h (valid_timespec_to_timespec64): Likewise.
* include/time.h (valid_timespec64_to_timespec): Likewise.
* include/time.h (valid_timespec64_to_timeval): Likewise.

4 years agoUpdate bits/mman.h constants and tst-mman-consts.py for Linux 5.3.
Joseph Myers [Mon, 30 Sep 2019 15:49:25 +0000 (15:49 +0000)] 
Update bits/mman.h constants and tst-mman-consts.py for Linux 5.3.

The Linux 5.3 uapi headers have some rearrangement relating to MAP_*
constants, which includes the effect of adding definitions of MAP_SYNC
on powerpc and sparc.  This patch updates the corresponding glibc
bits/mman.h headers accordingly, and updates the Linux kernel version
number in tst-mman-consts.py to reflect that these constants are now
current with that kernel version.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/powerpc/bits/mman.h [__USE_MISC]
(MAP_SYNC): New macro.
* sysdeps/unix/sysv/linux/sparc/bits/mman.h [__USE_MISC]
(MAP_SYNC): Likewise.
* sysdeps/unix/sysv/linux/tst-mman-consts.py (main): Update Linux
kernel version number to 5.3.

4 years agoAdd helper script for glibc debugging
Gabriel F. T. Gomes [Tue, 24 Sep 2019 17:21:42 +0000 (14:21 -0300)] 
Add helper script for glibc debugging

This patch adds a new make rule that generates a helper script for
debugging glibc test cases.  The new script, debugglibc.sh, is similar
to testrun.sh, in the sense that it allows the execution of the
specified test case, however, it opens the test case in GDB, setting the
library path the same way that testrun.sh does.  The commands are based
on the instructions on the wiki for glibc debugging [1,2].

By default, the script tells GDB to load the test case for symbol
information, so that, when a breakpoint is hit, the call stack is
displayed correctly (instead of printing lots of '??'s).  For instance,
after running 'make' and 'make check', one could do the following:

  $ ./debugglibc.sh nptl/tst-exec1 -b pthread_join

  Reading symbols from /home/gabriel/build/powerpc64le/glibc//elf/ld.so...done.
  Breakpoint 1 at 0x1444
  add symbol table from file "nptl/tst-exec1"
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/home/gabriel/build/powerpc64le/glibc//nptl_db/libthread_db.so.1".

  Breakpoint 1, 0x00007ffff7fb1444 in _dl_start_user () from /home/gabriel/build/powerpc64le/glibc/elf/ld.so
  Breakpoint 2 at 0x7ffff7f49d48: file pthread_join.c, line 23.

Notice that the script will always start GDB with the program running
and halted at _dl_start_user.  So, in order to reach the actual
breakpoint of interest, one should hit 'c', not 'r':

  >>> c
  Continuing.
  [New Thread 0x7ffff7d1f180 (LWP 76443)]
  [Switching to Thread 0x7ffff7d1f180 (LWP 76443)]

  Thread 2 "ld.so" hit Breakpoint 2, __pthread_join (threadid=140737354087616, thread_return=0x0) at pthread_join.c:24
  24        return __pthread_timedjoin_ex (threadid, thread_return, NULL, true);

Then inspect the call stack with 'bt', as usual, and see symbols from
both the test case and from the libraries themselves:

  >>> bt
  #0  __pthread_join (threadid=140737354087616, thread_return=0x0) at pthread_join.c:24
  #1  0x0000000010001f4c in tf (arg=<optimized out>) at tst-exec1.c:37
  #2  0x00007ffff7f487e8 in start_thread (arg=0x7ffff7510000) at pthread_create.c:479
  #3  0x00007ffff7e523a8 in clone () at ../sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S:82

Tested for powerpc64le and x86_64.

[1] https://sourceware.org/glibc/wiki/Debugging/Loader_Debugging
[2] https://sourceware.org/glibc/wiki/Testing/Builds#Required_gdb_setup

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
Reviewed-by: Joseph Myers <joseph@codesourcery.com>
Reviewed-by: Andreas Schwab <schwab@suse.de>
4 years ago[powerpc] Rename fesetenv_mode to fesetenv_control
Paul A. Clarke [Thu, 19 Sep 2019 19:04:45 +0000 (14:04 -0500)] 
[powerpc] Rename fesetenv_mode to fesetenv_control

fesetenv_mode is used variously to write the FPSCR exception enable
bits and rounding mode bits.  These are referred to as the control
bits in the POWER ISA.  Change the name to be reflective of its
current and expected use, and match up well with fegetenv_control.

4 years ago[powerpc] libc_feholdsetround_noex_ppc_ctx: optimize FPSCR write
Paul A. Clarke [Thu, 19 Sep 2019 16:31:31 +0000 (11:31 -0500)] 
[powerpc] libc_feholdsetround_noex_ppc_ctx: optimize FPSCR write

libc_feholdsetround_noex_ppc_ctx currently performs:
1. Read FPSCR, save to context.
2. Create new FPSCR value: clear enables and set new rounding mode.
3. Write new value to FPSCR.

Since other bits just pass through, there is no need to write them.

Instead, write just the changed values (enables and rounding mode),
which can be a bit more efficient.

4 years ago[powerpc] Rename fegetenv_status to fegetenv_control
Paul A. Clarke [Thu, 19 Sep 2019 16:58:46 +0000 (11:58 -0500)] 
[powerpc] Rename fegetenv_status to fegetenv_control

fegetenv_status is used variously to retrieve the FPSCR exception enable
bits, rounding mode bits, or both.  These are referred to as the control
bits in the POWER ISA.  FPSCR status bits are also returned by the
'mffs' and 'mffsl' instructions, but they are uniformly ignored by all
uses of fegetenv_status.  Change the name to be reflective of its
current and expected use.

Reviewed-By: Paul E Murphy <murphyp@linux.ibm.com>
4 years ago[powerpc] __fesetround_inline optimizations
Paul A. Clarke [Thu, 19 Sep 2019 16:39:44 +0000 (11:39 -0500)] 
[powerpc] __fesetround_inline optimizations

On POWER9, use more efficient means to update the 2-bit rounding mode
via the 'mffscrn' instruction (instead of two 'mtfsb0/1' instructions
or one 'mtfsfi' instruction that modifies 4 bits).

Suggested-by: Paul E. Murphy <murphyp@linux.ibm.com>
Reviewed-By: Paul E Murphy <murphyp@linux.ibm.com>
4 years ago[powerpc] libc_feupdateenv_test: optimize FPSCR access
Paul A. Clarke [Thu, 19 Sep 2019 16:18:33 +0000 (11:18 -0500)] 
[powerpc] libc_feupdateenv_test: optimize FPSCR access

ROUND_TO_ODD and a couple of other places use libc_feupdateenv_test to
restore the rounding mode and exception enables, preserve exception flags,
and test whether given exception(s) were generated.

If the exception flags haven't changed, then it is sufficient and a bit
more efficient to just restore the rounding mode and enables, rather than
writing the full Floating-Point Status and Control Register (FPSCR).

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years ago[powerpc] fenv_private.h clean up
Paul A. Clarke [Thu, 19 Sep 2019 14:13:14 +0000 (09:13 -0500)] 
[powerpc] fenv_private.h clean up

fenv_private.h includes unused functions, magic macro constants, and
some replicated common code fragments.

Remove unused functions, replace magic constants with constants from
fenv_libc.h, and refactor replicated code.

Suggested-by: Paul E. Murphy <murphyp@linux.ibm.com>
Reviewed-By: Paul E Murphy <murphyp@linux.ibm.com>
4 years agoAdd TCP_TX_DELAY from Linux 5.3 to netinet/tcp.h.
Joseph Myers [Fri, 27 Sep 2019 13:37:36 +0000 (13:37 +0000)] 
Add TCP_TX_DELAY from Linux 5.3 to netinet/tcp.h.

This patch adds the new TCP_TX_DELAY constant from Linux 5.3 to
sysdeps/gnu/netinet/tcp.h.

Tested for x86_64.

* sysdeps/gnu/netinet/tcp.h (TCP_TX_DELAY): New macro.

4 years agoy2038: Introduce struct __timespec64 - new internal glibc type
Lukasz Majewski [Fri, 22 Mar 2019 10:53:45 +0000 (11:53 +0100)] 
y2038: Introduce struct __timespec64 - new internal glibc type

This type is a glibc's "internal" type similar to struct timespec but
whose tv_sec field is a __time64_t rather than a time_t, which makes it
Y2038-proof and usable to pass syscalls between user code and Y2038-proof
kernel.

To support passing this structure to the kernel - the unnamed 32 bit
padding bit-field has been introduced. The placement of it depends on
the endianness of the SoC.

Tested on x86_64 and ARM.

4 years agoauto-changelog: Remove latin1 from codecs
Siddhesh Poyarekar [Thu, 26 Sep 2019 19:04:26 +0000 (12:04 -0700)] 
auto-changelog: Remove latin1 from codecs

Bruno Haible had pointed out that latin1 is a subset of cp1252 and is
hence redundant.  I forgot to remove it back then.

4 years agoSet the expects flags to clock_nanosleep
Adhemerval Zanella [Wed, 25 Sep 2019 22:10:00 +0000 (22:10 +0000)] 
Set the expects flags to clock_nanosleep

It moves the missing CFLAGS from rt/Makefile to time/Makefile missing
from 7b5af2d8f2a2b (Finish move of clock_* functions to libc. [BZ #24959]).

Checked on powerpc64le-linux-gnu.

* rt/Makefile (CFLAGS-clock_nanosleep.c): Move to ...
* time/Makefile (CFLAGS-clock_nanosleep.c): ... here.

4 years agoFix tst-sigcontext-get_pc rule name from a43565ac447b1
Adhemerval Zanella [Wed, 25 Sep 2019 22:06:34 +0000 (22:06 +0000)] 
Fix tst-sigcontext-get_pc rule name from a43565ac447b1

Checked on powerpc64le-linux-gnu.

* sysdeps/unix/sysv/linux/Makefile
(CFLAGS-tst-sigcontextinfo-get_pc.c): Rename to
CFLAGS-tst-sigcontext-get_pc.c.

4 years agoinet/net-internal.h: Fix uninitalised clntudp_call() variable
Alistair Francis [Tue, 24 Sep 2019 20:55:36 +0000 (21:55 +0100)] 
inet/net-internal.h: Fix uninitalised clntudp_call() variable

The total_deadline variable inside the clntudp_call() function inside
sunrpc/clnt_udp.c can cause uninitalised variable warnings when building
with GCC 8.3 or 9.2 on a platform with a 64-bit tv_nsec on a 32-bit
architecture.  To fix the warning let's use the DIAG_* macros to hide the
warning.

A GCC bug case has also been submitted:
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91691

2019-09-24  Alistair Francis  <alistair.francis@wdc.com>

* inet/net-internal.h: Fix uninitalised clntudp_call() variable.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoFix vDSO initialization on arm and mips
Andreas Schwab [Tue, 24 Sep 2019 10:16:37 +0000 (12:16 +0200)] 
Fix vDSO initialization on arm and mips

4 years agoScript to generate ChangeLog-like output from git log
Siddhesh Poyarekar [Fri, 20 Sep 2019 18:36:55 +0000 (11:36 -0700)] 
Script to generate ChangeLog-like output from git log

Co-authored-by: Gabriel F. T. Gomes <gabriel@inconstante.net.br>
Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.net.br>
Reviewed-by: Joseph Myers <joseph@codesourcery.com>
The utility of a ChangeLog file has been discussed in various mailing
list threads and GNU Tools Cauldrons in the past years and the general
consensus is that while the file may have been very useful in the past
when revision control did not exist or was not as powerful as it is
today, it's current utility is fast diminishing.  Further, the
ChangeLog format gets in the way of modernisation of processes since
it almost always results in rewriting of a commit, thus preventing use
of any code review tools to automatically manage patches in the glibc
project.

There is consensus in the glibc community that documentation of why a
change was done (i.e. a detailed description in a git commit) is more
useful than what changed (i.e. a ChangeLog entry) since the latter can
be deduced from the patch.  The GNU community would however like to
keep the option of ascertaining what changed through a ChangeLog-like
output and as a compromise, it was proposed that a script be developed
that generates this output.

The script below is the result of these discussions.  This script
takes two git revisions references as input and generates the git log
between those revisions in a form that resembles a ChangeLog.  Its
capabilities and limitations are listed in a comment in the script.
On a high level it is capable of parsing C code and telling what
changed at the top level, but not within constructs such as functions.

Design
------

At a high level, the script analyses the raw output of a VCS, parses
the source files that have changed and attempts to determine what
changed.  The script driver needs three distinct components to be
fully functional for a repository:

- A vcstocl_quirks.py file that helps it parse weird patterns in
  sources that may result from preprocessor defines.
- A VCS plugin backend; the git backend is implemented for glibc
- A programming language parser plugin.  C is currently implemented.

Additional programming language parsers can be added to give more
detailed output for changes in those types of files.

For input in languages other than those that have a parser, the script
only identifies if a file has been added, removed, modified,
permissions changed, etc. but cannot understand the change in content.

The C Parser
------------

The C parser is capable of parsing C programs with preprocessor macros
in place, as if they were part of the language.  This presents some
challenges with parsing code that expands macros on the fly and to
help work around that, a vcstocl_quirks.py file has transformations to
ease things.

The C parser currently can identify macro definitions and scopes and
all global and static declarations and definitions.  It cannot parse
(and compare) changes inside functions yet, it could be a future
enhancement if the need for it arises.

Testing
-------

The script has been tested with the glibc repository up to glibc-2.29
and also in the past with emacs.  While it would be ideal to have
something like this in a repository like gnulib, that should not be a
bottleneck for glibc to start using this, so this patch proposes to
add these scripts into glibc.

And here is (hopefully!) one of the last ChangeLog entries we'd have
to write for glibc:

* scripts/gitlog_to_changelog.py: New script to auto-generate
ChangeLog.
* scripts/vcs_to_changelog/frontend_c.py: New file.
* scripts/vcs_to_changelog/misc_util.py: New file.
* scripts/vcs_to_changelog/vcs_git.py: New file.
* scripts/vcs_to_changelog/vcstocl_quirks.py: Likewise.

4 years ago[powerpc] SET_RESTORE_ROUND optimizations and bug fix
Paul A. Clarke [Thu, 19 Sep 2019 13:35:16 +0000 (08:35 -0500)] 
[powerpc] SET_RESTORE_ROUND optimizations and bug fix

SET_RESTORE_ROUND brackets a block of code, temporarily setting and
restoring the rounding mode and letting everything else, including
exceptions generated within the block, pass through.

On powerpc, the current code clears the exception enables, which will hide
exceptions generated within the block.  This issue was introduced by me
in commit e905212627350d54b58426214b5a54ddc852b0c9.

Fix this by not clearing exception enable bits in the prologue.

Also, since we are no longer changing the enable bits in either the
prologue or the epilogue, there is no need to test for entering/exiting
non-stop mode.

Also, optimize the prologue get/save/set rounding mode operations for
POWER9 and later by using 'mffscrn' when possible.

Suggested-by: Paul E. Murphy <murphyp@linux.ibm.com>
Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
Fixes: e905212627350d54b58426214b5a54ddc852b0c9
2019-09-19  Paul A. Clarke  <pc@us.ibm.com>

* sysdeps/powerpc/fpu/fenv_libc.h (fegetenv_and_set_rn): New.
(__fe_mffscrn): New.
* sysdeps/powerpc/fpu/fenv_private.h (libc_feholdsetround_ppc_ctx):
Do not clear enable bits, remove obsolete code, use
fegetenv_and_set_rn.
(libc_feresetround_ppc): Remove obsolete code, use
fegetenv_and_set_rn.

4 years agoFix building support_ptrace.c on i686-gnu.
Stefan Liebler [Thu, 19 Sep 2019 10:26:18 +0000 (12:26 +0200)] 
Fix building support_ptrace.c on i686-gnu.

On i686-gnu the build is broken:
In file included from support_ptrace.c:22:
../include/sys/prctl.h:2:15: fatal error: sys/prctl.h: No such file or directory
 #include_next <sys/prctl.h>

This patch just removes the unused prctl.h inclusion.

ChangeLog:

* support/support_ptrace.c: Remove inclusion of sys/prctl.h.

4 years agoS390: Use _HP_TIMING_S390_H instead of _HP_TIMING_H.
Stefan Liebler [Thu, 19 Sep 2019 10:24:10 +0000 (12:24 +0200)] 
S390: Use _HP_TIMING_S390_H instead of _HP_TIMING_H.

Use macro _HP_TIMING_S390_H instead of _HP_TIMING_H
in s390 specific hp-timing.h

ChangeLog:

* sysdeps/s390/hp-timing.h (_HP_TIMING_H): Undefine.
(_HP_TIMING_S390_H): Define.

4 years agoUpdate syscall-names.list for Linux 5.3.
Joseph Myers [Wed, 18 Sep 2019 22:57:46 +0000 (22:57 +0000)] 
Update syscall-names.list for Linux 5.3.

This patch updates syscall-names.list for Linux 5.3, adding two new
syscalls.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
version to 5.3.
(clone3): New syscall.
(pidfd_open): Likewise.

4 years agoUse Linux 5.3 in build-many-glibcs.py.
Joseph Myers [Wed, 18 Sep 2019 15:13:33 +0000 (15:13 +0000)] 
Use Linux 5.3 in build-many-glibcs.py.

This patch makes build-many-glibcs.py use Linux 5.3.

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

* scripts/build-many-glibcs.py (Context.checkout): Default Linux
version to 5.3.

4 years agoS390: Add support for HP_TIMING_NOW.
Stefan Liebler [Wed, 18 Sep 2019 14:09:54 +0000 (16:09 +0200)] 
S390: Add support for HP_TIMING_NOW.

This patch adds support for HP_TIMING_NOW if we build at least
with -march=z10 -mzarch.  Otherwise we are still using the
generic hp-timing.h.

ChangeLog:

* sysdeps/s390/hp-timing.h: New file.

4 years agoFix RISC-V vfork build with Linux 5.3 kernel headers.
Joseph Myers [Wed, 18 Sep 2019 13:22:24 +0000 (13:22 +0000)] 
Fix RISC-V vfork build with Linux 5.3 kernel headers.

Building glibc for RISC-V with Linux 5.3 kernel headers fails because
<linux/sched.h>, included in vfork.S for CLONE_* constants, contains a
structure definition not safe for inclusion in assembly code.

All other architectures already avoid use of that header in vfork.S,
either defining the CLONE_* constants locally or embedding the
required values directly in the relevant instruction, where they
implement vfork using the clone syscall (see the implementations for
aarch64, ia64, mips and nios2).  This patch makes the RISC-V version
define the constants locally like the other architectures.

Tested build for all three RISC-V configurations in
build-many-glibcs.py with Linux 5.3 headers.

* sysdeps/unix/sysv/linux/riscv/vfork.S: Do not include
<linux/sched.h>.
(CLONE_VM): New macro.
(CLONE_VFORK): Likewise.

4 years agoAdd UNSUPPORTED check in elf/tst-pldd.
Stefan Liebler [Wed, 18 Sep 2019 10:40:00 +0000 (12:40 +0200)] 
Add UNSUPPORTED check in elf/tst-pldd.

The testcase forks a child process and runs pldd with PID of
this child.  On systems where /proc/sys/kernel/yama/ptrace_scope
differs from zero, pldd will fail with
/usr/bin/pldd: cannot attach to process 3: Operation not permitted

This patch checks if ptrace_scope exists, is zero "classic ptrace permissions"
or one "restricted ptrace".  If ptrace_scope exists and has a higher
restriction, then the test is marked as UNSUPPORTED.

The case "restricted ptrace" is handled by rearranging the processes involved
during the test.  Now we have the following process tree:
-parent: do_test (performs output checks)
--subprocess 1: pldd_process (becomes pldd via execve)
---subprocess 2: target_process (ptraced via pldd)

ChangeLog:

* elf/tst-pldd.c (do_test): Add UNSUPPORTED check.
Rearrange subprocesses.
(pldd_process): New function.
* support/Makefile (libsupport-routines): Add support_ptrace.
* support/xptrace.h: New file.
* support/support_ptrace.c: Likewise.

4 years agosparc64: Use linux generic time implementation
Adhemerval Zanella [Wed, 5 Jun 2019 14:02:35 +0000 (11:02 -0300)] 
sparc64: Use linux generic time implementation

There is no need to sparc64 provide an arch-specific implementation to
route to POSIX one (which uses gettimeofday).  Linux one already handles
the case for architecture that does not have __NR_time.

No semantic changes, checked against a build for sparc64-linux-gnu.

* sysdeps/unix/sysv/linux/sparc/sparc64/time.c: Remove file.

4 years agomips: Consolidate INTERNAL_VSYSCALL_CALL
Adhemerval Zanella [Tue, 4 Jun 2019 17:29:42 +0000 (17:29 +0000)] 
mips: Consolidate INTERNAL_VSYSCALL_CALL

This patch consolidates the mips, mips64, and mips64-n32
INTERNAL_VSYSCALL_CALL on a single implementation.

No semantic changes. I checked against a build for mips-linux-gnu,
mips64-linux-gnu, and mips64-n32-linux-gnu.

* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
(INTERNAL_VSYSCALL_CALL): Remove.
* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
(INTERNAL_VSYSCALL_CALL): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
(INTERNAL_VSYSCALL_CALL): Likewise.
* sysdeps/unix/sysv/linux/mips/sysdep.h (INTERNAL_VSYSCALL_CALL):
New macro.

4 years agopowerpc: Simplify vsyscall internal macros
Adhemerval Zanella [Mon, 3 Jun 2019 21:07:25 +0000 (21:07 +0000)] 
powerpc: Simplify vsyscall internal macros

This patch simplifies the powerpc internal macros for vDSO calls
by:

  - Removing INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK, used solely on
    get_timebase_freq.

  - Adjust INTERNAL_VSYSCALL_CALL_TYPE powerpc32 to follow powerpc64
    argument ordering.

  - Use HAVE_*_VSYSCALL instead of explicit strings.

  - Make powerpc libc-vdso.h include generic implementation.

No semantic change expected, checked on powerpc-linux-gnu-power4,
powerpc64-linux-gnu, and powerpc64le-linux-gnu.

* sysdeps/unix/sysv/linux/libc-vdso.h (VDSO_IFUNC_RET): Define if not
defined.
* sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
(__get_timebase_freq): Remove use of
INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK.
(get_timebase_freq_fallback): New symbol.
* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c (time): Use
HAVE_GETTIMEOFDAY_VSYSCALL.
* sysdeps/unix/sysv/linux/powerpc/time.c (gettimeofday): Use
HAVE_TIME_VSYSCALL.
* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Include generic
implementation.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
(INTERNAL_VSYSCALL_CALL_TYPE): Make calling convention similar to
powerpc64.
(INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK): Remove macro.
* .../sysv/linux/powerpc/powerpc64/sysdep.h
(INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK): Likewise.
* sysdeps/unix/sysv/linux/powerpc/sysdep.h
(HAVE_GETTIMEOFDAY_VSYSCALL): Define.

4 years agoRefactor vDSO initialization code
Adhemerval Zanella [Mon, 3 Jun 2019 13:22:13 +0000 (10:22 -0300)] 
Refactor vDSO initialization code

Linux vDSO initialization code the internal function pointers require a
lot of duplicated boilerplate over different architectures.  This patch
aims to simplify not only the code but the required definition to enable
a vDSO symbol.

The changes are:

  1. Consolidate all init-first.c on only one implementation and enable
     the symbol based on HAVE_*_VSYSCALL existence.

  2. Set the HAVE_*_VSYSCALL to the architecture expected names string.

  3. Add a new internal implementation, get_vdso_mangle_symbol, which
     returns a mangled function pointer.

Currently the clock_gettime, clock_getres, gettimeofday, getcpu, and time
are handled in an arch-independent way, powerpc still uses some
arch-specific vDSO symbol handled in a specific init-first implementation.

Checked on aarch64-linux-gnu, arm-linux-gnueabihf, i386-linux-gnu,
mips64-linux-gnu, powerpc64le-linux-gnu, s390x-linux-gnu,
sparc64-linux-gnu, and x86_64-linux-gnu.

* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address,
is_sigtramp_address_rt): Use HAVE_SIGTRAMP_{RT}32 instead of SHARED.
* sysdeps/powerpc/powerpc64/backtrace.c (is_sigtramp_address):
Likewise.
* sysdeps/unix/sysv/linux/aarch64/init-first.c: Remove file.
* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/arm/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/arm/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/mips/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/mips/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/i386/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/s390/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/s390/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/sysdep.h
(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Define value based on kernel exported
name.
* sysdeps/unix/sysv/linux/arm/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/i386/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/mips/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/sysdep.h
(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETCPU_VSYSCALL, HAVE_TIME_VSYSCALL, HAVE_GET_TBFREQ,
HAVE_SIGTRAMP_RT64, HAVE_SIGTRAMP_32, HAVE_SIGTRAMP_RT32i,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/riscv/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/dl-vdso.h (VDSO_NAME, VDSO_HASH): Define to
invalid names if architecture does not define them.
(get_vdso_mangle_symbol): New symbol.
* sysdeps/unix/sysv/linux/init-first.c: New file.
* sysdeps/unix/sysv/linux/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/init-first.c (gettimeofday,
clock_gettime, clock_getres, getcpu, time): Remove declaration.
(__libc_vdso_platform_setup_arch): Likewise and use
get_vdso_mangle_symbol to setup vDSO symbols.
(sigtramp_rt64, sigtramp32, sigtramp_rt32, get_tbfreq): Add
attribute_hidden.
* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Likewise.
* sysdeps/unix/sysv/linux/sysdep-vdso.h (VDSO_SYMBOL): Remove
definition.

4 years agoRemove PREPARE_VERSION and PREPARE_VERSION_KNOW
Adhemerval Zanella [Thu, 23 May 2019 19:33:32 +0000 (16:33 -0300)] 
Remove PREPARE_VERSION and PREPARE_VERSION_KNOW

This patch removes the PREPARE_VERSION and PREPARE_VERSION_KNOW macro
and uses a static inline function instead, get_vdso_symbol.  Each
architecture that supports vDSO must define the Linux version and its
hash for symbol resolution (VDSO_NAME and VDSO_HASH macro respectively).

It also organizes the HAVE_*_VSYSCALL for mips, powerpc, and s390 to
define them on a common header.

The idea is to require less code to configure and enable vDSO support
for newer ports.  No semantic changes are expected.

Checked with a build against all affected architectures.

* sysdeps/unix/make-syscalls.sh: Make vDSO call use get_vdso_symbol.
* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c (__gettimeofday):
Use get_vdso_symbol instead of _dl_vdso_vsym.
* sysdeps/unix/sysv/linux/powerpc/time.c (time): Likewise.
* sysdeps/unix/sysv/linux/riscv/flush-icache.c
(__lookup_riscv_flush_icache): Likewise.
* sysdeps/unix/sysv/linux/x86/gettimeofday.c (__gettimeofday):
Likewise.
* sysdeps/unix/sysv/linux/x86/time.c (time): Likewise.
* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/arm/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/i386/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/mips/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/s390/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/x86_64/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/sysdep.h (VDSO_NAME, VDSO_HASH):
Define.
* sysdeps/unix/sysv/linux/arm/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/i386/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/riscv/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (VDSO_NAME, VDSO_HASH):
Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Remove
definition.
* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL, HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
HAVE_GETTIMEOFDAY_VSYSCALL, HAVE_GETCPU_VSYSCALL): Likewise.
* sysdeps/unix/sysv/linux/mips/sysdep.h: New file.
* sysdeps/unix/sysv/linux/powerpc/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/s390/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/dl-vdso.h (PREPARE_VERSION,
PREPARE_VERSION_KNOWN, VDSO_NAME_LINUX_2_6, VDSO_HASH_LINUX_2_6,
VDSO_NAME_LINUX_2_6_15, VDSO_HASH_LINUX_2_6_15,
VDSO_NAME_LINUX_2_6_29, VDSO_HASH_LINUX_2_6_29,
VDSO_NAME_LINUX_4_15, VDSO_HASH_LINUX_4_15): Remove defines.
(get_vdso_symbol): New function.

4 years agoFix small error in HP_TIMING_PRINT trailing null char setting
Chung-Lin Tang [Tue, 17 Sep 2019 09:50:11 +0000 (17:50 +0800)] 
Fix small error in HP_TIMING_PRINT trailing null char setting

Fix a small error in the HP_TIMING_PRINT trailing zero setting; the '\0'
should be set at MIN(Len,string length), instead of always at the 'Len'
position.

* sysdeps/generic/hp-timing-common.h (HP_TIMING_PRINT): Correct
position of string null termination.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoalpha: force old OSF1 syscalls for getegid, geteuid and getppid [BZ #24986]
Aurelien Jarno [Sat, 14 Sep 2019 16:22:52 +0000 (18:22 +0200)] 
alpha: force old OSF1 syscalls for getegid, geteuid and getppid [BZ #24986]

On alpha, Linux kernel 5.1 added the standard getegid, geteuid and
getppid syscalls (commit ecf7e0a4ad15287). Up to now alpha was using
the corresponding OSF1 syscalls through:
 - sysdeps/unix/alpha/getegid.S
 - sysdeps/unix/alpha/geteuid.S
 - sysdeps/unix/alpha/getppid.S

When building against kernel headers >= 5.1, the glibc now use the new
syscalls through sysdeps/unix/sysv/linux/syscalls.list. When it is then
used with an older kernel, the corresponding 3 functions fail.

A quick fix is to move the OSF1 wrappers under the
sysdeps/unix/sysv/linux/alpha directory so they override the standard
linux ones. A better fix would be to try the new syscalls and fallback
to the old OSF1 in case the new ones fail. This can be implemented in
a later commit.

Changelog:
[BZ #24986]
        * sysdeps/unix/alpha/getegid.S: Move to ...
* sysdeps/unix/sysv/linux/alpha/getegid.S: ... here.
        * sysdeps/unix/alpha/geteuid.S: Move to ...
* sysdeps/unix/sysv/linux/alpha/geteuid.S: ... here.
        * sysdeps/unix/alpha/getppid.S: Move to ...
* sysdeps/unix/sysv/linux/alpha/getppid.S: ... here

4 years agoFix http: URL in 'configure'
Paul Eggert [Mon, 9 Sep 2019 21:10:23 +0000 (14:10 -0700)] 
Fix http: URL in 'configure'

* configure.ac: Add URL to AC_INIT so that it generates an
https: URL instead of an http: URL.
* configure: Regenerate.

4 years agoRegenerate charmap-kw.h, locfile-kw.h
Paul Eggert [Mon, 9 Sep 2019 21:08:46 +0000 (14:08 -0700)] 
Regenerate charmap-kw.h, locfile-kw.h

This propagates the recent http->https URL changes.
Since I used gperf 3.1 to regenerate, this is also a minor
internal-to-localedef API change.
URL problem reported by Joseph Myers in:
https://www.sourceware.org/ml/libc-alpha/2019-09/msg00143.html
* locale/programs/charmap-kw.h, locale/programs/locfile-kw.h:
Regenerate with gperf 3.1.
* locale/programs/linereader.h (kw_hash_fct_t):
* locale/programs/repertoire.c (repertoiremap_hash):
2nd arg is now size_t not unsigned, for compatibility with gperf 3.1.

4 years agoFix three GNU license URLs, along with trailing-newline issues.
Paul Eggert [Sat, 7 Sep 2019 09:54:48 +0000 (02:54 -0700)] 
Fix three GNU license URLs, along with trailing-newline issues.

4 years agoPrefer https to http for gnu.org and fsf.org URLs
Paul Eggert [Sat, 7 Sep 2019 05:40:42 +0000 (22:40 -0700)] 
Prefer https to http for gnu.org and fsf.org URLs

Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:

sed -ri '
  s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
  s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
  $(find $(git ls-files) -prune -type f \
      ! -name '*.po' \
      ! -name 'ChangeLog*' \
      ! -path COPYING ! -path COPYING.LIB \
      ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
      ! -path manual/texinfo.tex ! -path scripts/config.guess \
      ! -path scripts/config.sub ! -path scripts/install-sh \
      ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
      ! -path INSTALL ! -path  locale/programs/charmap-kw.h \
      ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
      ! '(' -name configure \
            -execdir test -f configure.ac -o -f configure.in ';' ')' \
      ! '(' -name preconfigure \
            -execdir test -f preconfigure.ac ';' ')' \
      -print)

and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:

  chmod a+x sysdeps/unix/sysv/linux/riscv/configure
  # Omit irrelevant whitespace and comment-only changes,
  # perhaps from a slightly-different Autoconf version.
  git checkout -f \
    sysdeps/csky/configure \
    sysdeps/hppa/configure \
    sysdeps/riscv/configure \
    sysdeps/unix/sysv/linux/csky/configure
  # Omit changes that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
  git checkout -f \
    sysdeps/powerpc/powerpc64/ppc-mcount.S \
    sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
  # Omit change that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
  git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S

4 years agoUse __attribute_pure__ macro in bits/mathcalls.h
Gabriel F. T. Gomes [Thu, 5 Sep 2019 20:06:03 +0000 (17:06 -0300)] 
Use __attribute_pure__ macro in bits/mathcalls.h

When the const attribute of totalorder* functions was replaced with the
pure attribute, by commit ID ab41100bab12, it did not use the
__attribute_pure__ macro, but the __attribute__ ((__pure__)) statement.
All other uses of the pure attribute in glibc use the macro.

Tested for powerpc64le.

4 years agolocale: Avoid zero-length array in _nl_category_names [BZ #24962]
Florian Weimer [Thu, 5 Sep 2019 20:16:58 +0000 (22:16 +0200)] 
locale: Avoid zero-length array in _nl_category_names [BZ #24962]

The union wrapper is unnecessary because C allows to read any object
as a sequence of chars.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agomath: Replace const attribute with pure in totalorder* functions
Gabriel F. T. Gomes [Wed, 4 Sep 2019 16:36:23 +0000 (13:36 -0300)] 
math: Replace const attribute with pure in totalorder* functions

Since the commit

commit 42760d764649ad82f5fe45a26cbdf2c2500409f7
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Thu Aug 15 15:18:34 2019 +0000

    Make totalorder and totalordermag functions take pointer arguments.

the test case math/test-totalorderl-ldbl-128ibm fails on every input
pair, when compiled with -O2, which is the case for glibc test suite.

Debugging showed that the test case is passing arguments incorrectly to
totalorderl.  This can also be inferred by the fact that compiling the
test case with -O0 hides the bug.

The documentation for the const attribute in GCC manual reads:

  Note that a function that has pointer arguments and examines the data
  pointed to must not be declared const if the pointed-to data might
  change between successive invocations of the function. In general,
  since a function cannot distinguish data that might change from data
  that cannot, const functions should never take pointer or, in C++,
  reference arguments. Likewise, a function that calls a non-const
  function usually must not be const itself.

Since the pointed-to data is likely to be changed by user code between
invocations of totalorder*, this patch removes the const attribute from
the declarations of all totalorder functions, replacing it with the pure
attribute, as suggested in the manual:

  The pure attribute imposes similar but looser restrictions on a
  function’s definition than the const attribute: pure allows the
  function to read any non-volatile memory, even if it changes in
  between successive invocations of the function.

Tested for powerpc64le and x86_64.

4 years agoy2038: Introduce the __ASSUME_TIME64_SYSCALLS define
Lukasz Majewski [Wed, 28 Aug 2019 18:27:03 +0000 (14:27 -0400)] 
y2038: Introduce the __ASSUME_TIME64_SYSCALLS define

Add a macro to linux/kernel-features.h, __ASSUME_TIME64_SYSCALLS, to
indicate whether the kernel can be assumed to provide a set of system
calls that process 64-bit time_t.

__ASSUME_TIME64_SYSCALLS does not indicate whether time_t is actually
64 bits (that's __TIMEBITS) and also does not indicate whether the
64-bit time_t system calls have "time64" suffixes on their names.

Code that uses __ASSUME_TIME64_SYSCALLS will be added in subsequent
patches.

* sysdeps/unix/sysv/linux/kernel-features.h
(__ASSUME_TIME64_SYSCALLS): New macro.

Reviewed-by: Alistair Francis <alistair23@gmail.com>
Reviewed-by: Joseph Myers <joseph@codesourcery.com>
Reviewed-by: Zack Weinberg <zackw@panix.com>
4 years agoFinish move of clock_* functions to libc. [BZ #24959]
Zack Weinberg [Wed, 4 Sep 2019 06:18:57 +0000 (08:18 +0200)] 
Finish move of clock_* functions to libc. [BZ #24959]

In glibc 2.17, the functions clock_getcpuclockid, clock_getres,
clock_gettime, clock_nanosleep, and clock_settime were moved from
librt.so to libc.so, leaving compatibility stubs behind.  Now that the
dynamic linker no longer insists on finding versioned symbols in the
same library that originally defined them, we do not need the stubs
anymore, and this means we don't need GLIBC_PRIVATE __-prefix aliases
for most of the functions anymore either.  (clock_gettime still needs
one.)  For ports added before 2.17, libc.so needs to provide two
symbol versions for each, the default at GLIBC_2.17 plus a compat
version matching what librt had.

While I'm at it, move the clock_*.c files and their tests from rt/ to
time/.

4 years agoUpdate Alpha libm-test-ulps
Aurelien Jarno [Tue, 3 Sep 2019 19:35:51 +0000 (21:35 +0200)] 
Update Alpha libm-test-ulps

Changelog:

* sysdeps/alpha/fpu/libm-test-ulps: Regenerated using GCC 9.2.

4 years agolocaledef: Use initializer for flexible array member [BZ #24950]
Florian Weimer [Tue, 3 Sep 2019 12:01:39 +0000 (14:01 +0200)] 
localedef: Use initializer for flexible array member [BZ #24950]

struct charseq used a zero-length array instead of a flexible array
member.  This required a strange construct to initialize struct
charseq objects, and GCC 10 warns about that:

cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
In file included from programs/repertoire.h:24,
                 from programs/localedef.h:32,
                 from programs/ld-ctype.c:35:
programs/charmap.h:63:17: note: destination object declared here
   63 |   unsigned char bytes[0];
      |                 ^~~~~
cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
programs/charmap.h:63:17: note: destination object declared here
cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
programs/charmap.h:63:17: note: destination object declared here
cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
programs/charmap.h:63:17: note: destination object declared here

The change makes the object physically const, but it is not expected
to be modified.

4 years agoAdd misc/tst-mntent-autofs, testing autofs "ignore" filtering
Florian Weimer [Mon, 2 Sep 2019 10:40:38 +0000 (12:40 +0200)] 
Add misc/tst-mntent-autofs, testing autofs "ignore" filtering

4 years agoUse autofs "ignore" mount hint in getmntent_r/getmntent
Ian Kent [Mon, 2 Sep 2019 11:26:14 +0000 (13:26 +0200)] 
Use autofs "ignore" mount hint in getmntent_r/getmntent

Historically autofs mounts were not included in mount table
listings. This is the case in other SysV autofs implementations
and was also the case with Linux autofs.

But now that /etc/mtab is a symlink to the proc filesystem
mount table the autofs mount entries appear in the mount table
on Linux.

Prior to the symlinking of /etc/mtab mount table it was
sufficient to call mount(2) and simply not update /etc/mtab
to exclude autofs mounts from mount listings.

Also, with the symlinking of /etc/mtab we have seen a shift in
usage toward using the proc mount tables directly.

But the autofs mount entries need to be retained when coming
from the proc file system for applications that need them
(largely autofs file system users themselves) so filtering out
these entries within the kernel itself can't be done. So it
needs be done in user space.

There are three reasons to omit the autofs mount entries.

One is that certain types of auto-mounts have an autofs mount
for every entry in their autofs mount map and these maps can
be quite large. This leads to mount table listings containing
a lot of unnecessary entries.

Also, this change in behaviour between autofs implementations
can cause problems for applications that use getmntent(3) in
other OS implementations as well as Linux.

Lastly, there's very little that user space can do with autofs
mount entries since this must be left to the autofs mount owner,
typically the automount daemon. But it can also lead to attempts
to access automount managed paths resulting mounts being triggered
when they aren't needed or mounts staying mounted for much longer
thay they need be. While the point of this change ins't to help
with these problems (and it can be quite a problem) it may be
a welcome side effect.

So the Linux autofs file system has been modified to accept a
pseudo mount option of "ignore" (as is used in other OS
implementations) so that user space can use this as a hint to
skip autofs entries on reading the mount table.

The Linux autofs automount daemon used getmntent(3) itself and
has been modified to use the proc file system directly so that
it can "ignore" mount option.

The use of this mount option is opt-in and a configuration
option has been added which defaults to not use this option
so if there are applications that need these entries, other
than autofs itself, they can be retained. Also, since this
filtering is based on an added mount option earlier versions
of Linux autofs iand other autofs file system users will not
use the option and so won't be affected by the change.

4 years agohurd: Fix build
Samuel Thibault [Fri, 30 Aug 2019 16:27:47 +0000 (18:27 +0200)] 
hurd: Fix build

* sysdeps/mach/hurd/i386/sigreturn.c (__sigreturn2): Spin-lock '&ss->lock',
not 'ss'.

4 years agoUse generic memset/memcpy/memmove in benchtests
Wilco Dijkstra [Thu, 29 Aug 2019 14:45:49 +0000 (15:45 +0100)] 
Use generic memset/memcpy/memmove in benchtests

Use the generic C memset/memcpy/memmove in benchtests since comparing
against a slow byte-oriented implementation makes no sense.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2019-08-29  Wilco Dijkstra  <wdijkstr@arm.com>

* benchtests/bench-memcpy.c (simple_memcpy): Remove.
(generic_memcpy): Include generic C memcpy.
* benchtests/bench-memmove.c (simple_memmove): Remove.
(generic_memmove): Include generic C memmove.
* benchtests/bench-memset.c (simple_memset): Remove.
(generic_memset): Include generic C memset.
* benchtests/bench-memset-large.c (simple_memset): Remove.
(generic_memset): Include generic C memset.
* benchtests/bench-memset-walk.c (simple_memset): Remove.
(generic_memset): Include generic C memset.
* string/memcpy.c (MEMCPY): Add defines to enable redirection.
* string/memset.c (MEMSET): Likewise.
* sysdeps/x86_64/memcopy.h: Remove empty file.

4 years agonptl: Move pthread_attr_getinheritsched implementation into libc
Florian Weimer [Fri, 30 Aug 2019 05:33:02 +0000 (07:33 +0200)] 
nptl: Move pthread_attr_getinheritsched implementation into libc

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agohurd: Fix SS_ONSTACK support
Samuel Thibault [Thu, 29 Aug 2019 23:48:38 +0000 (01:48 +0200)] 
hurd: Fix SS_ONSTACK support

* sysdeps/mach/hurd/i386/sigreturn.c (__sigreturn2): New function,
unlocks SS and returns to the saved PC.
(__sigreturn): Do not unlock SS, and "return" into __sigreturn2 on the
thread stack instead of the saved PC.

4 years agohurd: Remove optimizing anonymous maps as __vm_allocate.
Samuel Thibault [Thu, 29 Aug 2019 23:41:50 +0000 (01:41 +0200)] 
hurd: Remove optimizing anonymous maps as __vm_allocate.

Optimizing anonymous maps brings bugs, and does not optimize much anyway.

[BZ #19903]
* sysdeps/mach/hurd/mmap.c (__mmap): Remove optimizing anonymous maps
as __vm_allocate.

4 years agohurd: Fix poll and select POSIX compliancy details about errors
Samuel Thibault [Thu, 29 Aug 2019 23:20:23 +0000 (01:20 +0200)] 
hurd: Fix poll and select POSIX compliancy details about errors

This fixes the following:

- On error, poll must not return without polling, including EBADF, and instead
report POLLHUP/POLLERR/POLLNVAL
- Select must report EBADF if some set contains an invalid FD.

The idea is to move error management to after all select calls, in the
poll/select final treatment. The error is instead recorded in a new `error'
field, and a new SELECT_ERROR bit set.

Thanks Svante Signell for the initial version of the patch.

* hurd/hurdselect.c (SELECT_ERROR): New macro.
(_hurd_select):
- Add `error' field to `d' structures array.
- If a poll descriptor is bogus, set EBADF, but continue with a zero
timeout.
- Go through the whole fd_set, not only until _hurd_dtablesize. Return
EBADF there is any bit set above _hurd_dtablesize.
- Do not request io_select on bogus descriptors (SELECT_ERROR).
- On io_select request error, record the error.
- On io_select bogus reply, use EIO error code.
- On io_select bogus or error reply, record the error.
- Do not destroy reply port for bogus FDs.
- On error, make poll set POLLHUP in the EPIPE case, POLLNVAL in the
EBADF case, or else POLLERR.
- On error, make select simulated readiness.

4 years agohurd: Fix timeout handling in _hurd_select
Richard Braun [Thu, 29 Aug 2019 23:16:37 +0000 (01:16 +0200)] 
hurd: Fix timeout handling in _hurd_select

Rely on servers to implement timeouts, so that very short values (including
0) don't make mach_msg return before valid replies can be received. The
purpose of this scheme is to guarantee a full client-server round-trip,
whatever the timeout value.

This change depends on the new io_select_timeout RPC being implemented by
servers.

* hurd/Makefile (user-interfaces): Add io_reply and io_request.
* hurd/hurdselect.c: Include <sys/time.h>, <hurd/io_request.h> and
<limits.h>.
(_hurd_select): Replace the call to __io_select with either
__io_select_request or __io_select_timeout_request, depending on the
timeout. Count the number of ready descriptors (replies for which at
least one type bit is set). Implement the timeout locally when there is
no file descriptor.

4 years agohurd getcwd: Allow unknown root directory
Samuel Thibault [Thu, 29 Aug 2019 23:08:09 +0000 (01:08 +0200)] 
hurd getcwd: Allow unknown root directory

To be efficient, the remap translator simply returns ports from the underlying
filesystem, and thus the root directory found through browsing '..' is the
underlying root, not the remap root. This should not be a reason for getcwd to
fail.

* sysdeps/mach/hurd/getcwd.c (_hurd_canonicalize_directory_name_internal): Do
not remove the heading slash if we got an unknown root directory.
(__getcwd): Do not fail with EGRATUITOUS if we got an unknown root directory.

4 years agohurd: Fix implementation of setitimer.
Samuel Thibault [Thu, 29 Aug 2019 23:04:17 +0000 (01:04 +0200)] 
hurd: Fix implementation of setitimer.

The preemptor sigcode doesn't match since the POSIX sigcode SI_TIMER is
used when SIGALRM is sent. In addition, The inline version of
hurd_preempt_signals doesn't update _hurdsig_preempted_set. For these
reasons, the preemptor would be skipped by post_signal.

    * sysdeps/mach/hurd/setitimer.c (setitimer_locked): Fix preemptor setup.