public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/12] Y2038 preparation: use clock_[gs]ettime to implement the other time-getting and -setting functions
@ 2019-08-20 13:22 Zack Weinberg
  2019-08-20 13:21 ` [PATCH 03/12] Don’t use the argument to time Zack Weinberg
                   ` (15 more replies)
  0 siblings, 16 replies; 74+ messages in thread
From: Zack Weinberg @ 2019-08-20 13:22 UTC (permalink / raw)
  To: libc-alpha
  Cc: Joseph Myers, Florian Weimer, Lukasz Majewski, Alistair Francis,
	Stepan Golosunov, Arnd Bergmann

This patchset aims to make the Y2038 project a little easier by
implementing the other time-getting and time-setting functions
(time, ftime, stime, gettimeofday, and settimeofday) in terms of
clock_gettime and clock_settime.  Internal uses of (__)gettimeofday
are also all changed to __clock_gettime.  Internal uses of time() are
mostly left alone, since time() is easier and clearer when you don’t
care about sub-second resolution and don’t need a struct timespec for
some other reason.

As a consequence, gettimeofday will no longer report crude timezone
information under any circumstances.  If its ‘tzp’ argument is not
NULL, it will write zeroes to both fields of the ‘struct timezone’,
even if the gettimeofday system call exists and would have produced
different output.  Similarly, ftime will always write zeroes to the
timezone and dstflag fields of ‘struct timeb’.  Joseph Myers raised an
objection to this change; I rebutted the objection, and he did not
reply; I do not think either of us will persuade the other, so I’m
formally asking for a third maintainer to make a decision.

settimeofday _will_ still call the settimeofday system call and pass
down a non-null ‘tzp’ argument if it receives one, but, if _both_ of
its arguments are non-null, it will fail and set errno to EINVAL.
Also, its invocation of a settimeofday system call goes through an
internal sysdep function called __settimezone.  On the Hurd this is an
unconditional ENOSYS stub, and on Linux it’s an ENOSYS stub when
__NR_settimeofday is not defined.

Relatedly, there is a macro-based hack to issue warnings when
gettimeofday is called with a ‘tzp’ argument that is not a
compile-time null pointer.  I think this is probably a better option
at this stage than various suggested alternatives (e.g. renaming the
fields of ‘struct timezone’, or removing it from sys/time.h
altogether) because the remaining valid uses of settimeofday with
non-null ‘tzp’ should still be able to use struct timezone.  The hack
is in a separate patch because, well, it’s a hack and I’m hoping
someone has a better implementation idea.  (I tried an inline function
instead of a macro, but it threw false positives all over the place on
‘gettimeofday (&tv, 0)’...)

This patchset also includes an overhaul of Linux/Alpha’s GLIBC_2.0
compatibility symbols for several system calls that consume or produce
struct timeval.  It appears that early releases of glibc and/or Linux
for Alpha attempted to achieve some degree of binary compatibility
with OSF/1, but this came at the expense of using 32-bit time_t inside
struct timeval.  Up till now, we were invoking compatibility system
calls from the compatibility symbols.  This patch changes them to wrap
the 64-bit implementations and convert between 32-bit and 64-bit
struct timeval in user space.  If a 64-bit tv_sec value returned by
the kernel is found to be greater than INT32_MAX, the caller will
receive a saturated 32-bit struct timeval, { INT32_MAX, 0 }, and the
function will return -1 with errno set to EOVERFLOW.  Because many of
these calls are assumed unable to fail, we make sure to write all the
fields of any output data structure even when this happens.  I did
this partially because it simplified conversion of gettimeofday to
call clock_gettime, and partially as a worked example of the semantics
that I think are probably best for the 32-bit time_t compatibility
symbols we’re going to have to add for many other architectures.
Comments on these semantics are requested.

This patchset also includes a partial revision of manual/time.texi.
clock_gettime and clock_settime are now documented, and the
obsolescent status of stime, settimeofday, and gettimeofday is
clearer.  I only documented CLOCK_REALTIME and CLOCK_MONOTONIC,
because most of the other clock constants are either extremely
Linux-specific or they have to do with measuring CPU time, and I
didn’t touch the measuring-CPU-time part of time.texi.  (That part
also deserves a rewrite, but I don’t know enough about the topic and
this patchset is already long enough.)

Finally, there is a case for demoting ftime and stime to compatibility
symbols and removing their public prototypes (for ftime, we would stop
installing <sys/timeb.h> altogether).  I tried to investigate how much
this might break, using codesearch.debian.net, but the identifiers
‘ftime’ and ‘stime’ turn out to be heavily used for unrelated
purposes, so I didn’t get anywhere.

Zack Weinberg (12):
  Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
  Change most internal uses of __gettimeofday to __clock_gettime.
  Don’t use the argument to time.
  Use clock_settime to implement stime.
  Use clock_settime to implement settimeofday.
  Use clock_gettime to implement time.
  Use clock_gettime to implement ftime.
  Use clock_gettime to implement gettimeofday.
  Finish move of clock_* functions to libc.
  Warn when gettimeofday is called with non-null tzp argument.
  Linux/Alpha: don’t use timeval32 system calls.
  Revise the documentation of ‘simple calendar time’.

 NEWS                                          |   53 +-
 include/sys/time.h                            |    7 +-
 include/time.h                                |    4 +-
 inet/deadline.c                               |    9 +-
 login/logout.c                                |    9 +-
 login/logwtmp.c                               |    7 +-
 manual/filesys.texi                           |    2 +-
 manual/llio.texi                              |   10 +-
 manual/threads.texi                           |    2 +-
 manual/time.texi                              | 1062 +++++++++--------
 misc/syslog.c                                 |    2 +-
 nis/nis_call.c                                |    4 +-
 nptl/pthread_join_common.c                    |    7 +-
 nptl/pthread_mutex_timedlock.c                |    7 +-
 nscd/nscd_helper.c                            |   24 +-
 resolv/gai_misc.c                             |    6 +-
 resolv/gai_suspend.c                          |    6 +-
 resolv/res_send.c                             |    6 +-
 rt/Makefile                                   |   15 +-
 rt/Versions                                   |    7 +-
 rt/clock-compat.c                             |   63 -
 string/strfry.c                               |    2 +-
 sunrpc/auth_des.c                             |   19 +-
 sunrpc/auth_unix.c                            |    9 +-
 sunrpc/create_xid.c                           |    6 +-
 sunrpc/svcauth_des.c                          |    7 +-
 support/support_test_main.c                   |   14 +-
 sysdeps/generic/memusage.h                    |   16 +-
 .../mach/{gettimeofday.c => clock_gettime.c}  |   25 +-
 .../hurd/{settimeofday.c => clock_settime.c}  |   27 +-
 sysdeps/mach/hurd/getitimer.c                 |    3 +-
 sysdeps/mach/hurd/i386/libc.abilist           |    1 -
 sysdeps/mach/hurd/i386/librt.abilist          |    5 -
 sysdeps/mach/hurd/setitimer.c                 |    3 +-
 sysdeps/mach/hurd/times.c                     |    6 +-
 sysdeps/mach/nanosleep.c                      |   33 +-
 sysdeps/mach/sleep.c                          |    4 +-
 sysdeps/mach/usleep.c                         |    5 -
 sysdeps/posix/gettimeofday.c                  |   67 --
 sysdeps/posix/tempname.c                      |    9 +-
 sysdeps/posix/time.c                          |   40 -
 sysdeps/pthread/aio_misc.c                    |    6 +-
 sysdeps/pthread/aio_suspend.c                 |    6 +-
 sysdeps/unix/clock_gettime.c                  |   64 -
 sysdeps/unix/make-syscalls.sh                 |    2 +-
 sysdeps/unix/syscalls.list                    |    2 -
 .../unix/sysv/linux/aarch64/gettimeofday.c    |   71 --
 sysdeps/unix/sysv/linux/aarch64/init-first.c  |    7 +-
 sysdeps/unix/sysv/linux/aarch64/libc-vdso.h   |    2 -
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |    1 -
 sysdeps/unix/sysv/linux/alpha/Makefile        |    2 +-
 sysdeps/unix/sysv/linux/alpha/Versions        |    1 -
 sysdeps/unix/sysv/linux/alpha/adjtime.c       |   70 +-
 .../linux/{time.c => alpha/gettimeofday.c}    |   31 +-
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |    2 -
 sysdeps/unix/sysv/linux/alpha/librt.abilist   |    5 -
 sysdeps/unix/sysv/linux/alpha/osf_adjtime.c   |  135 +++
 sysdeps/unix/sysv/linux/alpha/osf_getitimer.c |   48 +
 sysdeps/unix/sysv/linux/alpha/osf_getrusage.c |   44 +
 .../unix/sysv/linux/alpha/osf_gettimeofday.c  |   53 +
 sysdeps/unix/sysv/linux/alpha/osf_setitimer.c |   55 +
 .../unix/sysv/linux/alpha/osf_settimeofday.c  |   51 +
 .../ftime.c => sysv/linux/alpha/osf_utimes.c} |   34 +-
 .../linux/alpha/osf_wait4.c}                  |   51 +-
 sysdeps/unix/sysv/linux/alpha/settimeofday.c  |   22 +
 sysdeps/unix/sysv/linux/alpha/syscalls.list   |   13 +-
 sysdeps/unix/sysv/linux/alpha/tv32-compat.h   |  151 +++
 sysdeps/unix/sysv/linux/arm/init-first.c      |    7 +-
 sysdeps/unix/sysv/linux/arm/libc-vdso.h       |    2 -
 sysdeps/unix/sysv/linux/arm/libc.abilist      |    1 -
 sysdeps/unix/sysv/linux/arm/librt.abilist     |    5 -
 sysdeps/unix/sysv/linux/clock_settime.c       |    1 +
 sysdeps/unix/sysv/linux/csky/libc.abilist     |    1 -
 sysdeps/unix/sysv/linux/ftime.c               |    3 -
 sysdeps/unix/sysv/linux/gettimeofday.c        |   39 -
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |    1 -
 sysdeps/unix/sysv/linux/hppa/librt.abilist    |    5 -
 sysdeps/unix/sysv/linux/i386/gettimeofday.c   |   35 -
 sysdeps/unix/sysv/linux/i386/libc.abilist     |    1 -
 sysdeps/unix/sysv/linux/i386/librt.abilist    |    5 -
 sysdeps/unix/sysv/linux/i386/time.c           |   34 -
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |    1 -
 sysdeps/unix/sysv/linux/ia64/librt.abilist    |    5 -
 .../sysv/linux/m68k/coldfire/libc.abilist     |    1 -
 .../sysv/linux/m68k/coldfire/librt.abilist    |    5 -
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |    1 -
 .../unix/sysv/linux/m68k/m680x0/librt.abilist |    5 -
 .../unix/sysv/linux/microblaze/libc.abilist   |    1 -
 .../unix/sysv/linux/microblaze/librt.abilist  |    5 -
 sysdeps/unix/sysv/linux/mips/init-first.c     |    7 +-
 sysdeps/unix/sysv/linux/mips/libc-vdso.h      |    2 -
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |    1 -
 .../unix/sysv/linux/mips/mips32/librt.abilist |    5 -
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |    1 -
 .../unix/sysv/linux/mips/mips64/librt.abilist |    5 -
 .../sysv/linux/mips/mips64/n32/libc.abilist   |    1 -
 .../sysv/linux/mips/mips64/n64/libc.abilist   |    1 -
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |    1 -
 sysdeps/unix/sysv/linux/powerpc/Versions      |    1 -
 .../unix/sysv/linux/powerpc/gettimeofday.c    |   85 --
 sysdeps/unix/sysv/linux/powerpc/init-first.c  |   13 +-
 sysdeps/unix/sysv/linux/powerpc/libc-vdso.h   |    2 -
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |    1 -
 .../linux/powerpc/powerpc32/librt.abilist     |    5 -
 .../powerpc/powerpc32/nofpu/libc.abilist      |    1 -
 .../linux/powerpc/powerpc64/be/libc.abilist   |    1 -
 .../linux/powerpc/powerpc64/be/librt.abilist  |    5 -
 .../linux/powerpc/powerpc64/le/libc.abilist   |    1 -
 sysdeps/unix/sysv/linux/powerpc/time.c        |   84 --
 sysdeps/unix/sysv/linux/riscv/init-first.c    |   10 +-
 sysdeps/unix/sysv/linux/riscv/libc-vdso.h     |    2 -
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |    1 -
 sysdeps/unix/sysv/linux/s390/init-first.c     |    9 +-
 sysdeps/unix/sysv/linux/s390/libc-vdso.h      |    3 -
 .../unix/sysv/linux/s390/s390-32/libc.abilist |    1 -
 .../sysv/linux/s390/s390-32/librt.abilist     |    5 -
 .../unix/sysv/linux/s390/s390-64/libc.abilist |    1 -
 .../sysv/linux/s390/s390-64/librt.abilist     |    5 -
 sysdeps/unix/sysv/linux/settimezone.c         |   39 +
 sysdeps/unix/sysv/linux/sh/libc.abilist       |    1 -
 sysdeps/unix/sysv/linux/sh/librt.abilist      |    5 -
 sysdeps/unix/sysv/linux/sparc/init-first.c    |    8 +-
 sysdeps/unix/sysv/linux/sparc/libc-vdso.h     |    2 -
 .../sysv/linux/sparc/sparc32/libc.abilist     |    1 -
 .../sysv/linux/sparc/sparc32/librt.abilist    |    5 -
 .../sysv/linux/sparc/sparc64/libc.abilist     |    1 -
 .../sysv/linux/sparc/sparc64/librt.abilist    |    5 -
 sysdeps/unix/sysv/linux/sparc/sparc64/time.c  |    1 -
 sysdeps/unix/sysv/linux/syscalls.list         |    1 -
 sysdeps/unix/sysv/linux/x86/gettimeofday.c    |   61 -
 sysdeps/unix/sysv/linux/x86/time.c            |   59 -
 .../unix/sysv/linux/x86_64/64/libc.abilist    |    1 -
 .../unix/sysv/linux/x86_64/64/librt.abilist   |    5 -
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |    1 -
 .../unix/sysv/linux/x86_64/x32/librt.abilist  |    5 -
 .../unix/sysv/linux/x86_64/x32/syscalls.list  |    2 -
 time/Makefile                                 |    8 +-
 time/Versions                                 |    2 +-
 {rt => time}/clock_getcpuclockid.c            |    0
 {rt => time}/clock_getres.c                   |    0
 {rt => time}/clock_gettime.c                  |    0
 {rt => time}/clock_nanosleep.c                |    0
 {rt => time}/clock_settime.c                  |    1 +
 time/ftime.c                                  |   26 +-
 time/getdate.c                                |    2 +-
 time/gettimeofday.c                           |   30 +-
 time/settimeofday.c                           |   24 +-
 sysdeps/unix/stime.c => time/settimezone.c    |   23 +-
 time/stime.c                                  |   15 +-
 time/sys/time.h                               |   36 +-
 time/time.c                                   |   17 +-
 {rt => time}/tst-clock.c                      |    0
 {rt => time}/tst-clock2.c                     |    0
 {rt => time}/tst-clock_nanosleep.c            |    0
 {rt => time}/tst-cpuclock1.c                  |    0
 time/tst_wcsftime.c                           |    2 +-
 156 files changed, 1580 insertions(+), 1775 deletions(-)
 delete mode 100644 rt/clock-compat.c
 rename sysdeps/mach/{gettimeofday.c => clock_gettime.c} (67%)
 rename sysdeps/mach/hurd/{settimeofday.c => clock_settime.c} (71%)
 delete mode 100644 sysdeps/posix/gettimeofday.c
 delete mode 100644 sysdeps/posix/time.c
 delete mode 100644 sysdeps/unix/clock_gettime.c
 delete mode 100644 sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
 rename sysdeps/unix/sysv/linux/{time.c => alpha/gettimeofday.c} (64%)
 create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_adjtime.c
 create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_getitimer.c
 create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_getrusage.c
 create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c
 create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_setitimer.c
 create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c
 rename sysdeps/unix/{bsd/ftime.c => sysv/linux/alpha/osf_utimes.c} (60%)
 rename sysdeps/unix/{clock_settime.c => sysv/linux/alpha/osf_wait4.c} (55%)
 create mode 100644 sysdeps/unix/sysv/linux/alpha/settimeofday.c
 create mode 100644 sysdeps/unix/sysv/linux/alpha/tv32-compat.h
 delete mode 100644 sysdeps/unix/sysv/linux/ftime.c
 delete mode 100644 sysdeps/unix/sysv/linux/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/time.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/time.c
 create mode 100644 sysdeps/unix/sysv/linux/settimezone.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/time.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/time.c
 rename {rt => time}/clock_getcpuclockid.c (100%)
 rename {rt => time}/clock_getres.c (100%)
 rename {rt => time}/clock_gettime.c (100%)
 rename {rt => time}/clock_nanosleep.c (100%)
 rename {rt => time}/clock_settime.c (96%)
 rename sysdeps/unix/stime.c => time/settimezone.c (67%)
 rename {rt => time}/tst-clock.c (100%)
 rename {rt => time}/tst-clock2.c (100%)
 rename {rt => time}/tst-clock_nanosleep.c (100%)
 rename {rt => time}/tst-cpuclock1.c (100%)

-- 
2.23.0.rc1

^ permalink raw reply	[flat|nested] 74+ messages in thread

end of thread, other threads:[~2019-08-27 15:58 UTC | newest]

Thread overview: 74+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 13:22 [PATCH 00/12] Y2038 preparation: use clock_[gs]ettime to implement the other time-getting and -setting functions Zack Weinberg
2019-08-20 13:21 ` [PATCH 03/12] Don’t use the argument to time Zack Weinberg
2019-08-20 17:09   ` Rafal Luzynski
2019-08-20 17:21     ` Zack Weinberg
2019-08-20 17:36     ` Joseph Myers
2019-08-22  9:42       ` Rafal Luzynski
2019-08-22  9:49         ` Florian Weimer
2019-08-23 20:26           ` Spelling of contributor names (was: [PATCH 03/12] Don’t use the argument to time) Paul Eggert
2019-08-23 20:49             ` Joseph Myers
2019-08-23 20:51               ` Joseph Myers
2019-08-23 21:28                 ` Paul Eggert
2019-08-24  5:58                   ` Spelling of contributor names Florian Weimer
2019-08-25  0:56                     ` Paul Eggert
2019-08-27 15:58                       ` Joseph Myers
2019-08-23 22:07             ` Spelling of contributor names (was: [PATCH 03/12] Don’t use the argument to time) Rafal Luzynski
2019-08-23 22:31               ` Paul Eggert
2019-08-26 14:42             ` Spelling of contributor names Stefan Liebler
2019-08-20 18:08   ` [PATCH 03/12] Don’t use the argument to time Adhemerval Zanella
2019-08-21 12:29     ` Zack Weinberg
2019-08-22  9:37       ` Rafal Luzynski
2019-08-20 13:22 ` [PATCH 01/12] Remove implementations of clock_[gs]ettime using [gs]ettimeofday Zack Weinberg
2019-08-20 18:06   ` Adhemerval Zanella
2019-08-22 12:54     ` Zack Weinberg
2019-08-23 17:49       ` Adhemerval Zanella
2019-08-20 13:22 ` [PATCH 12/12] Revise the documentation of ‘simple calendar time’ Zack Weinberg
2019-08-20 18:50   ` Paul Eggert
2019-08-20 19:38     ` Joseph Myers
2019-08-20 19:55       ` Zack Weinberg
2019-08-20 20:19     ` Zack Weinberg
2019-08-20 20:23       ` Zack Weinberg
2019-08-20 13:22 ` [PATCH 02/12] Change most internal uses of __gettimeofday to __clock_gettime Zack Weinberg
2019-08-20 18:53   ` Paul Eggert
2019-08-22 12:55     ` Zack Weinberg
2019-08-20 20:56   ` Adhemerval Zanella
2019-08-21 21:09     ` Zack Weinberg
2019-08-23 18:39       ` Adhemerval Zanella
2019-08-20 13:22 ` [PATCH 04/12] Use clock_settime to implement stime Zack Weinberg
2019-08-21 15:10   ` Adhemerval Zanella
2019-08-22 12:57     ` Zack Weinberg
2019-08-20 13:22 ` [PATCH 05/12] Use clock_settime to implement settimeofday Zack Weinberg
2019-08-20 13:22 ` [PATCH 09/12] Finish move of clock_* functions to libc Zack Weinberg
2019-08-20 15:13   ` Joseph Myers
2019-08-20 15:19     ` Zack Weinberg
2019-08-20 15:21     ` Florian Weimer
2019-08-20 15:25       ` Zack Weinberg
2019-08-20 13:37 ` [PATCH 06/12] Use clock_gettime to implement time Zack Weinberg
2019-08-20 18:02   ` Adhemerval Zanella
2019-08-22 12:58     ` Zack Weinberg
2019-08-20 13:37 ` [PATCH 08/12] Use clock_gettime to implement gettimeofday Zack Weinberg
2019-08-20 15:24   ` Joseph Myers
2019-08-22 13:01     ` Zack Weinberg
2019-08-27 14:34       ` Arnd Bergmann
2019-08-20 17:51   ` Adhemerval Zanella
2019-08-20 13:37 ` [PATCH 07/12] Use clock_gettime to implement ftime Zack Weinberg
2019-08-21 15:18   ` Adhemerval Zanella
2019-08-22 12:59     ` Zack Weinberg
2019-08-20 13:37 ` [PATCH 11/12] Linux/Alpha: don’t use timeval32 system calls Zack Weinberg
2019-08-21 18:50   ` Adhemerval Zanella
2019-08-22 13:36     ` Zack Weinberg
2019-08-23 18:48       ` Adhemerval Zanella
2019-08-20 13:56 ` [PATCH 10/12] Warn when gettimeofday is called with non-null tzp argument Zack Weinberg
2019-08-20 18:52   ` Paul Eggert
2019-08-20 19:03     ` Zack Weinberg
2019-08-20 19:06       ` Paul Eggert
2019-08-21 15:30   ` Adhemerval Zanella
2019-08-21 16:03     ` Zack Weinberg
2019-08-21 16:10       ` Florian Weimer
2019-08-22 13:07         ` Zack Weinberg
2019-08-23 13:05           ` Florian Weimer
2019-08-20 15:10 ` [PATCH 00/12] Y2038 preparation: use clock_[gs]ettime to implement the other time-getting and -setting functions Joseph Myers
2019-08-20 15:21   ` Zack Weinberg
2019-08-20 18:47 ` Alistair Francis
2019-08-20 18:55 ` Paul Eggert
2019-08-21  8:00 ` Lukasz Majewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).