glibc:zack/obsolete-time-functions

Last commit made on 2020-01-06
Get this branch:
git clone -b zack/obsolete-time-functions https://git.launchpad.net/glibc

Branch merges

Branch information

Name:
zack/obsolete-time-functions
Repository:
lp:glibc

Recent commits

c246b06... by Zack Weinberg on 2019-08-19

Warn when gettimeofday is called with non-null tzp argument.

Since there are no known uses of gettimeofday's vestigial "get time
zone" feature that are not bugs, add a fortify-style wrapper inline to
sys/time.h that issues a warning whenever gettimeofday is called with
a second argument that is not a compile-time null pointer
constant.

At present this is only possible with GCC; clang does not implement
attribute((warning)). The wrapper is only activated when __OPTIMIZE__
is defined because it throws false positives when optimization is off,
even though it's an always-inline function.

An oversight in the implementation of __builtin_constant_p causes it
to fail to detect compile-time *pointer* constants unless they are
cast to an integer of a different size. (Loss of data in this cast is
harmless; the overall expression is still constant if and only if the
original pointer was.) This is GCC bug 95514. Thanks to
Kamil Cukrowski <email address hidden> for the workaround.
As a precaution, I added a static assertion to debug/warning-nop.c to
make sure that the cast _is_ casting to an integer of a different
size; this is too unlikely a scenario to be worth checking in the
public header, but if someone ever adds a port where short is the
same size as intptr_t, we'll still catch it.

d5f4d0a... by Zack Weinberg on 2019-08-28

Use exclusively clock_gettime to implement gettimeofday.

In 2.31 we changed most ports to implement gettimeofday using
clock_gettime(CLOCK_REALTIME[_COARSE]), but we kept around a handful
of Linux-specific implementations that went directly to the vDSO.

Actual performance testing (on x86-64) indicates that there is no
measurable difference between invoking the vDSO directly and calling
clock_gettime (which then calls into the vDSO), so remove all of these
for simplicity’s sake.

9ac2398... by Zack Weinberg on 2019-08-17

Demote ftime to a compat symbol; don’t install sys/timeb.h.

ftime is an obsolete variation on gettimeofday, offering only
millisecond time resolution; it was probably a system call in ooold
versions of BSD Unix. It is the only function declared by
sys/timeb.h. It was deprecated in POSIX.1-2001 and removed from
POSIX.1-2008. In glibc 2.31, we marked its declaration with
__attribute_deprecated__.

Demote it to a compat symbol and stop installing sys/timeb.h.
Remove the minimal test of it (time/tst-ftime.c).

Rename time/tst-ftime_l.c to tst-strftime_l.c; this test program has
never had anything to do with ftime, it tests strftime_l.

cbce69e... by Samuel thibault on 2020-01-05

hurd: Fix message reception for timer_thread

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

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

25c084e... by Samuel thibault on 2020-01-04

htl: Add __errno_location and __h_errno_location

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

50a78ba... by Samuel thibault on 2020-01-04

htl: Move pthread_atfork to libc_nonshared.a

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

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

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

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

12e166d... by Samuel thibault on 2020-01-04

htl: Drop common tcbhead_t definition

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

af7be49... by Samuel thibault on 2020-01-04

htl: Use dso_handle.h

92b9636... by Adhemerval Zanella on 2019-12-16

linux: Optimize fallback 32-bit clock_getres

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

The following snippet:

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

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

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

Checked on i686-linux-gnu on 4.15 kernel.

Reviewed-by: Siddhesh Poyarekar <email address hidden>

0dc1a37... by Adhemerval Zanella on 2019-12-11

linux: Add support for clock_getres64 vDSO

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

Reviewed-by: Siddhesh Poyarekar <email address hidden>