This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
[glibc/zack/y2038-preliminaries] (10 commits) Revise the documentation of ‘simple calendar time’.
- From: Zack Weinberg <zack at sourceware dot org>
- To: glibc-cvs at sourceware dot org
- Date: 20 Aug 2019 13:24:02 -0000
- Subject: [glibc/zack/y2038-preliminaries] (10 commits) Revise the documentation of ‘simple calendar time’.
The branch 'zack/y2038-preliminaries' was updated to point to:
ca15d90... Revise the documentation of â??simple calendar timeâ??.
It previously pointed to:
e72bcbd... Revise the documentation of â??simple calendar timeâ??.
Diff:
!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
-------------------------------------------------------------------
e72bcbd... Revise the documentation of â??simple calendar timeâ??.
86c56ab... Linux/Alpha: donâ??t use timeval32 system calls.
5fc9cbd... Warn when gettimeofday is called with non-null tzp argument
ee79916... Finish move of clock_* functions to libc.
6ec0607... Use clock_gettime to implement gettimeofday.
8e9ce23... Use clock_gettime to implement ftime.
069a421... Use clock_gettime to implement time.
f66ff8e... Use clock_settime to implement settimeofday.
4e83f31... Use clock_settime to implement stime.
c101e8b... Donâ??t use the argument to time.
commit e72bcbd79348e4a168590ba40971f8e4319aa71e
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Aug 19 10:31:07 2019 -0400
Revise the documentation of â??simple calendar timeâ??.
This is a thorough revision of all the material relating to the
functions time, stime, gettimeofday, settimeofday, clock_gettime,
clock_getres, clock_settime, and difftime, spilling over into the
discussion of time-related data types (which now get their own
section) and touching the adjtime family as well (which deserves its
own thorough revision, but Iâ??d have to do a bunch of research first).
Substantive changes are:
* Document clock_gettime, clock_getres, and clock_settime. (Only
CLOCK_REALTIME and CLOCK_MONOTONIC are documented; the others are
either a bit too Linux-specific, or have more to do with measuring
CPU/processor time. That section _also_ deserves its own thorough
revision but again Iâ??d have to do a bunch of research first.)
* Present gettimeofday, settimeofday, and struct timeval as obsolete
relative to clock_*.
* Remove the documentation of struct timezone. Matching POSIX,
say that the type of the second argument to gettimeofday and
settimeofday is [const] void *.
* Clarify ISO C and POSIXâ??s requirements on time_t. Clarify the
circumstances under which difftime is equivalent to simple
subtraction.
* Consolidate documentation of most of the time-related data types
into a new section â??Time Types,â?? right after â??Time Basics.â?? (The
exceptions are struct tm, which stays in â??Broken-down Time,â?? and
struct times, which stays in â??Processor And CPU Time.â??
* The â??Elapsed Timeâ?? section is now called â??Calculating Elapsed Timeâ??
and includes only difftime and the discussion of how to compute
timeval differences by hand.
* Fold the â??Simple Calendar Time,â?? â??High Resolution Calendar,â?? and
â??High Accuracy Clockâ?? sections together into two new sections titled
â??Getting the Timeâ?? and â??Setting and Adjusting the Time.â??
ChangeLog:
* manual/time.texi: Major revision of text related to simple
calendar time. clock_gettime, clock_getres, and clock_settime
are now documented.
* manual/filesys.texi, manual/llio.texi, manual/threads.texi:
Update cross-references to renamed sections in time.texi.
Large blocks of text are moved around, so the diff is not terribly
informative; reviewers may find it easier to apply the diff and then
read the changed sections of the rendered manual.
This patch also includes a NEWS update covering all of the
user-visible changes in this patch series.
commit 86c56abeb28b140fd3d83793380137d8951cefb1
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Aug 19 14:18:08 2019 -0400
Linux/Alpha: donâ??t use timeval32 system calls.
Linux/Alpha has two versions of several system call wrappers that take
or return data of type â??struct timevalâ?? (possibly nested inside a
larger structure). The GLIBC_2.0 version is a compat symbol that
calls __NR_osf_foo or __NR_old_foo and uses a struct timeval with a
32-bit tv_sec field. The GLIBC_2.1 version is used for current code,
calls __NR_foo, and uses a struct timeval with a 64-bit tv_sec field.
This patch changes all of the remaining compat symbols of this type to
be wrappers around their GLIBC_2.1 counterparts. (gettimeofday
already received this treatment in an earlier patch in this series.)
The compat symbols that copy out a 32-bit struct timeval all check for
overflow. After the Y2038 deadline, they will fail with errno set to
EOVERFLOW, but only after copying out as much as they can, and filling
in the overflowed â??struct timevalâ??(s) with tv_sec set to INT32_MAX and
tv_nsec set to zero.
The new header file tv32-compat.h is currently Alpha-specific but I
donâ??t know any reason why it couldnâ??t be reused to aid in writing
wrappers for all affected architectures.
* sysdeps/unix/sysv/linux/alpha/tv32-compat.h: New file declaring
types and helper functions for 32/64-bit time_t conversion.
* sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove entries for
osf_getitimer, osf_setitimer, osf_utimes, osf_getrusage, and osf_wait4.
* sysdeps/unix/sysv/linux/alpha/osf_getitimer.c
* sysdeps/unix/sysv/linux/alpha/osf_getrusage.c
* sysdeps/unix/sysv/linux/alpha/osf_setitimer.c
* sysdeps/unix/sysv/linux/alpha/osf_utimes.c
* sysdeps/unix/sysv/linux/alpha/osf_wait4.c:
New files defining compatibility symbols formerly defined by
alpha/syscalls.list.
* sysdeps/unix/sysv/linux/alpha/adjtime.c: Split the compat code to...
* sysdeps/unix/sysv/linux/alpha/osf_adjtime.c: ...this new file.
* sysdeps/unix/sysv/linux/alpha/Makefile (sysdep_routines):
Add osf_adjtime.
* sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c
* sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c:
Use tv32-compat.h helpers.
commit 5fc9cbd920c43edf56e12c15ebb1b62b8d9d24b7
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Aug 19 13:51:25 2019 -0400
Warn when gettimeofday is called with non-null tzp argument.
At this stage I donâ??t think we can issue warnings for settimeofday
with a non-null tzp argument, nor for arbitrary use of struct
timezone. But we can warn about gettimeofday with non-null tzp.
This uses a macro instead of an inline (fortify-style) function
because I got false positives with an inline, even with GCC 9.
* time/sys/time.h (__timezone_ptr_t): Delete.
(gettimeofday): Always declare second argument with type â??void *â??.
When possible, wrap with a macro that detects non-null and
non-constant second argument and issues a warning.
Improve commentary.
(settimeofday): Improve commentary.
* time/gettimeofday.c (gettimeofday):
Declare second argument as type â??void *â??.
commit ee799168e8a011b082a50c955a8eab265c7b8a0a
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Aug 19 12:25:14 2019 -0400
Finish move of clock_* functions to libc.
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 is still called
all over the place internally and therefore still needs one.)
While Iâ??m at it, move the clock_*.c files and their tests from rt/ to
time/.
* rt/clock-compat.c: Delete file.
* rt/clock_getcpuclockid.c: Move to time/clock_getcpuclockid.c.
* rt/clock_getres.c: Move to time/clock_getres.c.
* rt/clock_gettime.c: Move to time/clock_gettime.c.
* rt/clock_nanosleep.c: Move to time/clock_nanosleep.c.
* rt/clock_settime.c: Move to time/clock_settime.c.
* rt/tst-clock.c: Move to time/tst-clock.c.
* rt/tst-clock2.c: Move to time/tst-clock2.c.
* rt/tst-clock_nanosleep.c: Move to time/tst-clock_nanosleep.c.
* rt/tst-cpuclock1.c: Move to time/tst-cpuclock1.c.
* include/time.h: Remove internal prototypes for __clock_getres,
__clock_nanosleep, and __clock_getcpuclockid.
* rt/Makefile (routines, clock-routines): Delete.
(librt-routines): Remove clock-compat.
(tests): Remove tst-clock, tst-clock2, tst-clock_nanosleep, and
tst-cpuclock1.
* time/Makefile (routines): Add clock_getcpuclockid, clock_getres,
clock_gettime, clock_settime, and clock_nanosleep.
(tests): Add tst-clock, tst-clock2, tst-clock_nanosleep, and
tst-cpuclock1.
* rt/Versions (libc GLIBC_PRIVATE): Remove __clock_getres,
__clock_settime, __clock_getcpuclockid, and __clock_nanosleep.
(librt GLIBC_2.2): Remove clock_getres, clock_gettime,
clock_settime, clock_getcpuclockid, and clock_nanosleep.
* sysdeps/**/librt.abilist: Update to match.
commit 6ec060709aecd5d8459f1f6be6801cf421d8f354
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 19:28:17 2019 -0400
Use clock_gettime to implement gettimeofday.
Abstractly, this is the same change as using clock_gettime to
implement time, but the vestigial â??get time zoneâ?? feature of
gettimeofday complicates matters a little. Unlike settimeofday, there
are *no* known uses of this feature that are not bugs, so it is simply
dummied out. (The per-process timezone support in â??localtimeâ?? and
friends is unrelated, and the programs that set the kernelâ??s offset
between the hardware clock and UTC do not need to read it back.)
Henceforth, if gettimeofdayâ??s â??struct timezoneâ?? argument is not NULL,
it will write zeroes to both fields. Any program that is actually
looking at this data will thus think it is running in UTC, which is
probably more correct than whatever it was doing before.
Hurd having already been converted, this patch only affects Linux and
hypothetical future ports. Most Linux ports supplied a vDSO symbol
for gettimeofday, and some wrapped that with an ifunc, so this patch
deletes a lot of code. For ease of future edits to the many copies of
_libc_vdso_platform_setup, the variable â??pâ?? in each is now declared
separately from any use of it.
As with settimeofday, the alpha-linux-gnu configuration has two
versions, GLIBC_2.0 and GLIBC_2.1, with the older symbol using 32-bit
time_t (yes, really) and the same solution is implemented here.
__gettimeofday is no longer called by anyone, so remove its internal
prototype and its entries in Versions and .abilits files. (It would
have been a GLIBC_PRIVATE symbol if the GLIBC_PRIVATE convention had
been invented back in the days of 2.0.)
* time/gettimeofday.c: No longer a stub implementation.
Call __clock_gettime. If â??tzâ?? argument is not NULL, clear the
object it points to. Remove libc_hidden_def for __gettimeofday
and libc_hidden_weak for gettimeofday. Optionally override the
default symbol version for gettimeofday.
* include/sys/time.h: Remove internal prototype and libc_hidden_proto
for __gettimeofday, and libc_hidden_proto for gettimeofday.
* time/Versions
* sysdeps/unix/sysv/linux/alpha/Versions
* sysdeps/**/libc.abilist: Remove entry for __gettimeofday.
* sysdeps/unix/sysv/linux/aarch64/init-first.c
* sysdeps/unix/sysv/linux/arm/init-first.c
* sysdeps/unix/sysv/linux/mips/init-first.c
* sysdeps/unix/sysv/linux/powerpc/init-first.c
* sysdeps/unix/sysv/linux/riscv/init-first.c
* sysdeps/unix/sysv/linux/s390/init-first.c
* sysdeps/unix/sysv/linux/sparc/init-first.c:
Do not define nor initialize VDSO_SYMBOL(gettimeofday).
* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h
* sysdeps/unix/sysv/linux/arm/libc-vdso.h
* sysdeps/unix/sysv/linux/mips/libc-vdso.h
* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
* sysdeps/unix/sysv/linux/riscv/libc-vdso.h
* sysdeps/unix/sysv/linux/s390/libc-vdso.h
* sysdeps/unix/sysv/linux/sparc/libc-vdso.h:
Do not declare VDSO_SYMBOL(gettimeofday).
* sysdeps/unix/syscalls.list: Remove entry for gettimeofday.
* sysdeps/unix/sysv/linux/alpha/syscalls.list:
Remove entries for gettimeofday and osf_gettimeofday.
* sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list:
Remove entry for gettimeofday.
* sysdeps/posix/gettimeofday.c
* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
* sysdeps/unix/sysv/linux/gettimeofday.c
* sysdeps/unix/sysv/linux/i386/gettimeofday.c
* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
* sysdeps/unix/sysv/linux/x86/gettimeofday.c: Delete file.
* sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c:
New file, defines gettimeofday@GLIBC_2.0.
* sysdeps/unix/sysv/linux/alpha/gettimeofday.c
New file, defines gettimeofday@@GLIBC_2.1.
* sysdeps/unix/make-syscalls.sh: Change an example in a comment
from referring to gettimeofday, to referring to sigaction.
commit 8e9ce235eef63c354b278d13d118c6eb3dfc23b3
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 20:56:02 2019 -0400
Use clock_gettime to implement ftime.
ftime is an obsolete variation on gettimeofday, offering only
millisecond time resolution; it was probably a system call in ooold
versions of BSD Unix. For historic reasons, we had three
implementations of it. These are all consolidated into time/ftime.c.
Like gettimeofday, ftime tries to report the time zone, and using that
information is always a bug. This patch dummies out the reported
timezone information; the â??timezoneâ?? and â??dstflagâ?? fields of the
returned â??struct timebâ?? will always be zero.
(There is an argument for turning this function into a compat symbol,
and not installing sys/timeb.h anymore. Thoughts?)
* time/ftime.c (ftime): Replace implementation with the code
formerly in sysdeps/unix/bsd/ftime.c, then change that code to use
__clock_gettime instead of __gettimeofday. Always set the
timezone and dstflag fields of the â??timebufâ?? argument to zero.
* sysdeps/unix/bsd/ftime.c
* sysdeps/unix/sysv/linux/ftime.c: Delete file.
commit 069a4219518dd2f35c611e8ff186f92e118dcbf2
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 14:22:42 2019 -0400
Use clock_gettime to implement time.
Most ports were using gettimeofday to implement time, or they were
making a direct (v)syscall. Unconditionally switch to using
clock_gettime instead. All sysdeps implementations of time are
removed.
* time/time.c (time): No longer a stub implementation.
Call __clock_gettime.
* sysdeps/unix/sysv/linux/powerpc/Versions (GLIBC_PRIVATE):
Remove __vdso_time.
* sysdeps/unix/sysv/linux/powerpc/init-first.c (__vdso_time): Delete.
(_libc_vdso_platform_setup): Donâ??t initialize __vdso_time.
* sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list: Remove entry
for time.
* sysdeps/posix/time.c
* sysdeps/unix/sysv/linux/time.c
* sysdeps/unix/sysv/linux/i386/time.c
* sysdeps/unix/sysv/linux/powerpc/time.c
* sysdeps/unix/sysv/linux/sparc/sparc64/time.c
* sysdeps/unix/sysv/linux/x86/time.c:
Delete file.
commit f66ff8e42db3f23324c9d214c06cde468b3382b2
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 16:21:13 2019 -0400
Use clock_settime to implement settimeofday.
Unconditionally, on all ports, use clock_settime to implement
settimeofday. This is a little different from using clock_settime to
implement stime, because the vestigial â??set time zoneâ?? feature of
settimeofday complicates matters.
The only remaining uses of this feature that arenâ??t just bugs are
using it to inform the Linux kernel of the offset between the hardware
clock and UTC, on systems where the hardware clock doesnâ??t run in
UTC (usually because of dual-booting with Windows). They call
settimeofday with _only_ the timezone argument non-NULL. Therefore,
glibcâ??s new behavior is: callers of settimeofday must supply one and
only one of the two arguments. If both arguments are non-NULL, or
both arguments are NULL, the call fails and sets errno to EINVAL.
When only the timeval argument is supplied, settimeofday calls
__clock_settime(CLOCK_REALTIME), same as stime.
When only the timezone argument is supplied, settimeofday calls a new
internal function called __settimezone. On Linux, only, this function
will pass the timezone structure to the settimeofday system call. On
all other operating systems, and on Linux architectures that donâ??t
define __NR_settimeofday, __settimezone is a stub that always sets
errno to ENOSYS and returns -1.
Another complication is that the alpha-linux-gnu configuration has two
versions of settimeofday, GLIBC_2.0 and GLIBC_2.1, with the older
symbol using 32-bit time_t (yes, really). The older symbol is
reimplemented from scratch (with the same semantics); the newer symbol
uses the generic implementation with some #ifdeffage to get the
versioning right. Henceforth, __NR_osf_settimeofday will never be
used, and __NR_settimeofday only for the timezone feature.
There are no longer any internal callers of __settimeofday, so the
internal prototype is removed.
* time/settimeofday.c (settimeofday): No longer a stub
implementation. Call __clock_settime or __settimezone depending
on arguments. Optionally override the default symbol version for
settimeofday.
* include/sys/time.h: Remove prototype for __settimeofday.
Add prototype for __settimezone.
* sysdeps/unix/syscalls.list: Remove entry for settimeofday.
* time/settimezone.c: New file.
(__settimezone): New stub implementation.
* sysdeps/unix/sysv/linux/settimezone.c: New file.
(__settimezone): Implement using settimeofday system call,
if available.
* time/Makefile (routines): Add settimezone.
* sysdeps/unix/sysv/linux/alpha/syscalls.list:
Remove entries for settimeofday and osf_settimeofday.
* sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c
New file, defines settimeofday@GLIBC_2.0.
* sysdeps/unix/sysv/linux/alpha/settimeofday.c:
New file, defines settimeofday@@GLIBC_2.1.
commit 4e83f317688294ccbf554920febe9c25fd489b33
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 15:03:16 2019 -0400
Use clock_settime to implement stime.
Unconditionally, on all ports, use clock_settime to implement stime,
not settimeofday or a direct syscall.
Note that the former stub implementation of stime would return -1 with
errno set to EINVAL if passed a null pointer. With this change, it
instead unconditionally dereferences the pointer, so any hypothetical
callers that passed NULL will now segfault. I donâ??t think this will break
any non-contrived programs.
* time/stime.c (stime): No longer a stub implementation.
Call __clock_settime.
* sysdeps/unix/stime.c: Delete file.
* sysdeps/unix/sysv/linux/syscalls.list: Remove entry for stime.
* include/time.h: Add libc_hidden_proto for __clock_settime.
* rt/clock_settime.c, sysdeps/unix/sysv/linux/clock_settime.c:
Add libc_hidden_def for __clock_settime.
commit c101e8b1860b24eba152d92b5551b3d231113508
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 21:10:11 2019 -0400
Donâ??t use the argument to time.
Unlike gettimeofday, I donâ??t think it makes sense to remove all the
internal uses of time. Its callers donâ??t care about sub-second
resolution and would be unnecessarily complicated if they had to
declare a struct timespec instead of just a time_t. However, a
handful of places were using the vestigial â??resultâ?? argument instead
of the return value, which is ever so slightly less efficient and also
looks weird. Correct this.
* misc/syslog.c (__vsyslog_internal)
* string/strfry.c (strfry)
* time/getdate.c (__getdate_r)
* time/tst_wcsftime.c (main):
Use return value of time, not its argument.
* sysdeps/mach/sleep.c (__sleep): Remove unnecessary casts of NULL.
Summary of changes (added commits):
-----------------------------------
ca15d90... Revise the documentation of â??simple calendar timeâ??.
7f0aceb... Linux/Alpha: donâ??t use timeval32 system calls.
b12e7a6... Warn when gettimeofday is called with non-null tzp argument
fce7a73... Finish move of clock_* functions to libc.
557dcea... Use clock_gettime to implement gettimeofday.
a98d081... Use clock_gettime to implement ftime.
90b7676... Use clock_gettime to implement time.
458e752... Use clock_settime to implement settimeofday.
da7859e... Use clock_settime to implement stime.
2b46d37... Donâ??t use the argument to time.
commit ca15d90019f4e844d03e434172b9e3b7ab84f716
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Aug 19 10:31:07 2019 -0400
Revise the documentation of â??simple calendar timeâ??.
This is a thorough revision of all the material relating to the
functions time, stime, gettimeofday, settimeofday, clock_gettime,
clock_getres, clock_settime, and difftime, spilling over into the
discussion of time-related data types (which now get their own
section) and touching the adjtime family as well (which deserves its
own thorough revision, but Iâ??d have to do a bunch of research first).
Substantive changes are:
* Document clock_gettime, clock_getres, and clock_settime. (Only
CLOCK_REALTIME and CLOCK_MONOTONIC are documented; the others are
either a bit too Linux-specific, or have more to do with measuring
CPU/processor time. That section _also_ deserves its own thorough
revision but again Iâ??d have to do a bunch of research first.)
* Present gettimeofday, settimeofday, and struct timeval as obsolete
relative to clock_*.
* Remove the documentation of struct timezone. Matching POSIX,
say that the type of the second argument to gettimeofday and
settimeofday is [const] void *.
* Clarify ISO C and POSIXâ??s requirements on time_t. Clarify the
circumstances under which difftime is equivalent to simple
subtraction.
* Consolidate documentation of most of the time-related data types
into a new section â??Time Types,â?? right after â??Time Basics.â?? (The
exceptions are struct tm, which stays in â??Broken-down Time,â?? and
struct times, which stays in â??Processor And CPU Time.â??
* The â??Elapsed Timeâ?? section is now called â??Calculating Elapsed Timeâ??
and includes only difftime and the discussion of how to compute
timeval differences by hand.
* Fold the â??Simple Calendar Time,â?? â??High Resolution Calendar,â?? and
â??High Accuracy Clockâ?? sections together into two new sections titled
â??Getting the Timeâ?? and â??Setting and Adjusting the Time.â??
ChangeLog:
* manual/time.texi: Major revision of text related to simple
calendar time. clock_gettime, clock_getres, and clock_settime
are now documented.
* manual/filesys.texi, manual/llio.texi, manual/threads.texi:
Update cross-references to renamed sections in time.texi.
commit 7f0acebb6bf12257cf19ef5810b654b8dde398c6
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Aug 19 14:18:08 2019 -0400
Linux/Alpha: donâ??t use timeval32 system calls.
Linux/Alpha has two versions of several system call wrappers that take
or return data of type â??struct timevalâ?? (possibly nested inside a
larger structure). The GLIBC_2.0 version is a compat symbol that
calls __NR_osf_foo or __NR_old_foo and uses a struct timeval with a
32-bit tv_sec field. The GLIBC_2.1 version is used for current code,
calls __NR_foo, and uses a struct timeval with a 64-bit tv_sec field.
This patch changes all of the remaining compat symbols of this type to
be wrappers around their GLIBC_2.1 counterparts. (gettimeofday
already received this treatment in an earlier patch in this series.)
The compat symbols that copy out a 32-bit struct timeval all check for
overflow. After the Y2038 deadline, they will fail with errno set to
EOVERFLOW, but only after copying out as much as they can, and filling
in the overflowed â??struct timevalâ??(s) with tv_sec set to INT32_MAX and
tv_nsec set to zero.
The new header file tv32-compat.h is currently Alpha-specific but I
donâ??t know any reason why it couldnâ??t be reused to aid in writing
wrappers for all affected architectures.
* sysdeps/unix/sysv/linux/alpha/tv32-compat.h: New file declaring
types and helper functions for 32/64-bit time_t conversion.
* sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove entries for
osf_getitimer, osf_setitimer, osf_utimes, osf_getrusage, and osf_wait4.
* sysdeps/unix/sysv/linux/alpha/osf_getitimer.c
* sysdeps/unix/sysv/linux/alpha/osf_getrusage.c
* sysdeps/unix/sysv/linux/alpha/osf_setitimer.c
* sysdeps/unix/sysv/linux/alpha/osf_utimes.c
* sysdeps/unix/sysv/linux/alpha/osf_wait4.c:
New files defining compatibility symbols formerly defined by
alpha/syscalls.list.
* sysdeps/unix/sysv/linux/alpha/adjtime.c: Split the compat code to...
* sysdeps/unix/sysv/linux/alpha/osf_adjtime.c: ...this new file.
* sysdeps/unix/sysv/linux/alpha/Makefile (sysdep_routines):
Add osf_adjtime.
* sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c
* sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c:
Use tv32-compat.h helpers.
commit b12e7a6f9d0bc12b0d3d632f3392d567f0bb9cda
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Aug 19 13:51:25 2019 -0400
Warn when gettimeofday is called with non-null tzp argument.
At this stage I donâ??t think we can issue warnings for settimeofday
with a non-null tzp argument, nor for arbitrary use of struct
timezone. But we can warn about gettimeofday with non-null tzp.
This uses a macro instead of an inline (fortify-style) function
because I got false positives with an inline, even with GCC 9.
* time/sys/time.h (__timezone_ptr_t): Delete.
(gettimeofday): Always declare second argument with type â??void *â??.
When possible, wrap with a macro that detects non-null and
non-constant second argument and issues a warning.
Improve commentary.
(settimeofday): Improve commentary.
* time/gettimeofday.c (gettimeofday):
Declare second argument as type â??void *â??.
commit fce7a734b002abed78f32bb54207bd25e54ca8aa
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Aug 19 12:25:14 2019 -0400
Finish move of clock_* functions to libc.
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 is still called
all over the place internally and therefore still needs one.)
While Iâ??m at it, move the clock_*.c files and their tests from rt/ to
time/.
* rt/clock-compat.c: Delete file.
* rt/clock_getcpuclockid.c: Move to time/clock_getcpuclockid.c.
* rt/clock_getres.c: Move to time/clock_getres.c.
* rt/clock_gettime.c: Move to time/clock_gettime.c.
* rt/clock_nanosleep.c: Move to time/clock_nanosleep.c.
* rt/clock_settime.c: Move to time/clock_settime.c.
* rt/tst-clock.c: Move to time/tst-clock.c.
* rt/tst-clock2.c: Move to time/tst-clock2.c.
* rt/tst-clock_nanosleep.c: Move to time/tst-clock_nanosleep.c.
* rt/tst-cpuclock1.c: Move to time/tst-cpuclock1.c.
* include/time.h: Remove internal prototypes for __clock_getres,
__clock_nanosleep, and __clock_getcpuclockid.
* rt/Makefile (routines, clock-routines): Delete.
(librt-routines): Remove clock-compat.
(tests): Remove tst-clock, tst-clock2, tst-clock_nanosleep, and
tst-cpuclock1.
* time/Makefile (routines): Add clock_getcpuclockid, clock_getres,
clock_gettime, clock_settime, and clock_nanosleep.
(tests): Add tst-clock, tst-clock2, tst-clock_nanosleep, and
tst-cpuclock1.
* rt/Versions (libc GLIBC_PRIVATE): Remove __clock_getres,
__clock_settime, __clock_getcpuclockid, and __clock_nanosleep.
(librt GLIBC_2.2): Remove clock_getres, clock_gettime,
clock_settime, clock_getcpuclockid, and clock_nanosleep.
* sysdeps/**/librt.abilist: Update to match.
commit 557dceaba0d503544b87c3f43ab5a97e0ba639fb
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 19:28:17 2019 -0400
Use clock_gettime to implement gettimeofday.
Abstractly, this is the same change as using clock_gettime to
implement time, but the vestigial â??get time zoneâ?? feature of
gettimeofday complicates matters a little. Unlike settimeofday, there
are *no* known uses of this feature that are not bugs, so it is simply
dummied out. (The per-process timezone support in â??localtimeâ?? and
friends is unrelated, and the programs that set the kernelâ??s offset
between the hardware clock and UTC do not need to read it back.)
Henceforth, if gettimeofdayâ??s â??struct timezoneâ?? argument is not NULL,
it will write zeroes to both fields. Any program that is actually
looking at this data will thus think it is running in UTC, which is
probably more correct than whatever it was doing before.
Hurd having already been converted, this patch only affects Linux and
hypothetical future ports. Most Linux ports supplied a vDSO symbol
for gettimeofday, and some wrapped that with an ifunc, so this patch
deletes a lot of code. For ease of future edits to the many copies of
_libc_vdso_platform_setup, the variable â??pâ?? in each is now declared
separately from any use of it.
As with settimeofday, the alpha-linux-gnu configuration has two
versions, GLIBC_2.0 and GLIBC_2.1, with the older symbol using 32-bit
time_t (yes, really) and the same solution is implemented here.
__gettimeofday is no longer called by anyone, so remove its internal
prototype and its entries in Versions and .abilist files. (It would
have been a GLIBC_PRIVATE symbol if the GLIBC_PRIVATE convention had
been invented back in the days of 2.0.)
* time/gettimeofday.c: No longer a stub implementation.
Call __clock_gettime. If â??tzâ?? argument is not NULL, clear the
object it points to. Remove libc_hidden_def for __gettimeofday
and libc_hidden_weak for gettimeofday. Optionally override the
default symbol version for gettimeofday.
* include/sys/time.h: Remove internal prototype and libc_hidden_proto
for __gettimeofday, and libc_hidden_proto for gettimeofday.
* time/Versions
* sysdeps/unix/sysv/linux/alpha/Versions
* sysdeps/**/libc.abilist: Remove entry for __gettimeofday.
* sysdeps/unix/sysv/linux/aarch64/init-first.c
* sysdeps/unix/sysv/linux/arm/init-first.c
* sysdeps/unix/sysv/linux/mips/init-first.c
* sysdeps/unix/sysv/linux/powerpc/init-first.c
* sysdeps/unix/sysv/linux/riscv/init-first.c
* sysdeps/unix/sysv/linux/s390/init-first.c
* sysdeps/unix/sysv/linux/sparc/init-first.c:
Do not define nor initialize VDSO_SYMBOL(gettimeofday).
* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h
* sysdeps/unix/sysv/linux/arm/libc-vdso.h
* sysdeps/unix/sysv/linux/mips/libc-vdso.h
* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
* sysdeps/unix/sysv/linux/riscv/libc-vdso.h
* sysdeps/unix/sysv/linux/s390/libc-vdso.h
* sysdeps/unix/sysv/linux/sparc/libc-vdso.h:
Do not declare VDSO_SYMBOL(gettimeofday).
* sysdeps/unix/syscalls.list: Remove entry for gettimeofday.
* sysdeps/unix/sysv/linux/alpha/syscalls.list:
Remove entries for gettimeofday and osf_gettimeofday.
* sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list:
Remove entry for gettimeofday.
* sysdeps/posix/gettimeofday.c
* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
* sysdeps/unix/sysv/linux/gettimeofday.c
* sysdeps/unix/sysv/linux/i386/gettimeofday.c
* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
* sysdeps/unix/sysv/linux/x86/gettimeofday.c: Delete file.
* sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c:
New file, defines gettimeofday@GLIBC_2.0.
* sysdeps/unix/sysv/linux/alpha/gettimeofday.c
New file, defines gettimeofday@@GLIBC_2.1.
* sysdeps/unix/make-syscalls.sh: Change an example in a comment
from referring to gettimeofday, to referring to sigaction.
commit a98d0813fb5de58a9a99dca8495f87b3e6ea86bd
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 20:56:02 2019 -0400
Use clock_gettime to implement ftime.
ftime is an obsolete variation on gettimeofday, offering only
millisecond time resolution; it was probably a system call in ooold
versions of BSD Unix. For historic reasons, we had three
implementations of it. These are all consolidated into time/ftime.c.
Like gettimeofday, ftime tries to report the time zone, and using that
information is always a bug. This patch dummies out the reported
timezone information; the â??timezoneâ?? and â??dstflagâ?? fields of the
returned â??struct timebâ?? will always be zero.
(There is an argument for turning this function into a compat symbol,
and not installing sys/timeb.h anymore. Thoughts?)
* time/ftime.c (ftime): Replace implementation with the code
formerly in sysdeps/unix/bsd/ftime.c, then change that code to use
__clock_gettime instead of __gettimeofday. Always set the
timezone and dstflag fields of the â??timebufâ?? argument to zero.
* sysdeps/unix/bsd/ftime.c
* sysdeps/unix/sysv/linux/ftime.c: Delete file.
commit 90b7676ef50191068372ba061009909032ddf55f
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 14:22:42 2019 -0400
Use clock_gettime to implement time.
Most ports were using gettimeofday to implement time, or they were
making a direct (v)syscall. Unconditionally switch to using
clock_gettime instead. All sysdeps implementations of time are
removed.
* time/time.c (time): No longer a stub implementation.
Call __clock_gettime.
* sysdeps/unix/sysv/linux/powerpc/Versions (GLIBC_PRIVATE):
Remove __vdso_time.
* sysdeps/unix/sysv/linux/powerpc/init-first.c (__vdso_time): Delete.
(_libc_vdso_platform_setup): Donâ??t initialize __vdso_time.
* sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list: Remove entry
for time.
* sysdeps/posix/time.c
* sysdeps/unix/sysv/linux/time.c
* sysdeps/unix/sysv/linux/i386/time.c
* sysdeps/unix/sysv/linux/powerpc/time.c
* sysdeps/unix/sysv/linux/sparc/sparc64/time.c
* sysdeps/unix/sysv/linux/x86/time.c:
Delete file.
commit 458e752a5d89931459eedd8a19da11737ca2f64d
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 16:21:13 2019 -0400
Use clock_settime to implement settimeofday.
Unconditionally, on all ports, use clock_settime to implement
settimeofday. This is a little different from using clock_settime to
implement stime, because the vestigial â??set time zoneâ?? feature of
settimeofday complicates matters.
The only remaining uses of this feature that arenâ??t just bugs are
using it to inform the Linux kernel of the offset between the hardware
clock and UTC, on systems where the hardware clock doesnâ??t run in
UTC (usually because of dual-booting with Windows). They call
settimeofday with _only_ the timezone argument non-NULL. Therefore,
glibcâ??s new behavior is: callers of settimeofday must supply one and
only one of the two arguments. If both arguments are non-NULL, or
both arguments are NULL, the call fails and sets errno to EINVAL.
When only the timeval argument is supplied, settimeofday calls
__clock_settime(CLOCK_REALTIME), same as stime.
When only the timezone argument is supplied, settimeofday calls a new
internal function called __settimezone. On Linux, only, this function
will pass the timezone structure to the settimeofday system call. On
all other operating systems, and on Linux architectures that donâ??t
define __NR_settimeofday, __settimezone is a stub that always sets
errno to ENOSYS and returns -1.
Another complication is that the alpha-linux-gnu configuration has two
versions of settimeofday, GLIBC_2.0 and GLIBC_2.1, with the older
symbol using 32-bit time_t (yes, really). The older symbol is
reimplemented from scratch (with the same semantics); the newer symbol
uses the generic implementation with some #ifdeffage to get the
versioning right. Henceforth, __NR_osf_settimeofday will never be
used, and __NR_settimeofday only for the timezone feature.
There are no longer any internal callers of __settimeofday, so the
internal prototype is removed.
* time/settimeofday.c (settimeofday): No longer a stub
implementation. Call __clock_settime or __settimezone depending
on arguments. Optionally override the default symbol version for
settimeofday.
* include/sys/time.h: Remove prototype for __settimeofday.
Add prototype for __settimezone.
* sysdeps/unix/syscalls.list: Remove entry for settimeofday.
* time/settimezone.c: New file.
(__settimezone): New stub implementation.
* sysdeps/unix/sysv/linux/settimezone.c: New file.
(__settimezone): Implement using settimeofday system call,
if available.
* time/Makefile (routines): Add settimezone.
* sysdeps/unix/sysv/linux/alpha/syscalls.list:
Remove entries for settimeofday and osf_settimeofday.
* sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c
New file, defines settimeofday@GLIBC_2.0.
* sysdeps/unix/sysv/linux/alpha/settimeofday.c:
New file, defines settimeofday@@GLIBC_2.1.
commit da7859ec6faf7710c142dfee755978436048db7b
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 15:03:16 2019 -0400
Use clock_settime to implement stime.
Unconditionally, on all ports, use clock_settime to implement stime,
not settimeofday or a direct syscall.
Note that the former stub implementation of stime would return -1 with
errno set to EINVAL if passed a null pointer. With this change, it
instead unconditionally dereferences the pointer, so any hypothetical
callers that passed NULL will now segfault. I donâ??t think this will break
any non-contrived programs.
* time/stime.c (stime): No longer a stub implementation.
Call __clock_settime.
* sysdeps/unix/stime.c: Delete file.
* sysdeps/unix/sysv/linux/syscalls.list: Remove entry for stime.
* include/time.h: Add libc_hidden_proto for __clock_settime.
* rt/clock_settime.c, sysdeps/unix/sysv/linux/clock_settime.c:
Add libc_hidden_def for __clock_settime.
commit 2b46d373df083f3f4e9b5e763abc72ba6a42f264
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 21:10:11 2019 -0400
Donâ??t use the argument to time.
Unlike gettimeofday, I donâ??t think it makes sense to remove all the
internal uses of time. Its callers donâ??t care about sub-second
resolution and would be unnecessarily complicated if they had to
declare a struct timespec instead of just a time_t. However, a
handful of places were using the vestigial â??resultâ?? argument instead
of the return value, which is ever so slightly less efficient and also
looks weird. Correct this.
* misc/syslog.c (__vsyslog_internal)
* time/getdate.c (__getdate_r)
* time/tst_wcsftime.c (main):
Use return value of time, not its argument.
* string/strfry.c (strfry)
* sysdeps/mach/sleep.c (__sleep):
Remove unnecessary casts of NULL.