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