]> git.ipfire.org Git - thirdparty/glibc.git/commit
Remove access to legacy time zone support in gettimeofday etc. zack/gtod-no-timezone
authorZack Weinberg <zackw@panix.com>
Sat, 27 Jul 2019 23:26:23 +0000 (19:26 -0400)
committerZack Weinberg <zackw@panix.com>
Sun, 28 Jul 2019 00:14:35 +0000 (20:14 -0400)
commit3f649995a112b91754b49b7fff389385ce55f54f
tree3999bdce24cbfc67c223f3610ba6dd92d59d0994
parent50ce3eae5ba304650459d4441d7d246a7cefc26f
Remove access to legacy time zone support in gettimeofday etc.

gettimeofday and ftime are not quite fully implementable on systems
that only provide a primitive equivalent to clock_gettime, because
they can also report information about a system-wide time zone.  This
mechanism has been deprecated for many years because it can only be
configured on a system-wide basis, and because it only supports the
simplest kinds of daylight-savings rules, but we’ve supported it on a
best-effort basis until now.  This patch removes our support for it:

 * The type 'struct timezone' is still declared as a complete type in
   <sys/time.h>, but code that uses its fields (tz_minuteswest and
   tz_dsttime) will not compile.

 * Similarly, code that uses the 'timezone' and 'dstflag' fields of
   struct timeb will not compile anymore.  (This is a willful
   violation of the older iterations of XPG that included
   sys/timeb.h; the relevant conformance tests are XFAILed.)

 * Old binaries that pass a non-NULL 'tzp' pointer to gettimeofday
   will always receive a 'struct timezone' whose tz_minuteswest and
   tz_dsttime fields are zero (as if the system were operating on UTC).

 * Similarly, old binaries that call ftime will always receive a
   'struct timeb' whose timezone and dstflag fields are zero.

 * If the 'tzp' argument to settimeofday is not NULL, the call will fail
   and set errno to ENOSYS.  (This was already the case on the Hurd.)

 * glibc will always pass a second argument of NULL when invoking a
   kernel-provided gettimeofday.

 * On Alpha, the compat symbols gettimeofday@GLIBC_2.0 and
   settimeofday@GLIBC_2.0 (which used 32-bit time_t) now convert
   their arguments and call system primitives that use 64-bit time_t,
   instead of invoking legacy “osf” system calls.

ChangeLog:

* time/sys/time.h (struct timezone): Remove tz_minuteswest
and tz_dsttime fields; replace with padding to preserve the size.
* time/sys/timeb.h (struct timeb): Remove timezone and dstflag
fields; replace with padding to preserve the size.
* conform/Makefile: XFAIL tests because struct timeb is no longer
fully conformant with Unix98.

* sysdeps/posix/gettimeofday.c
* sysdeps/unix/sysv/linux/gettimeofday.c
* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
* sysdeps/unix/sysv/linux/x86/gettimeofday.c
(gettimeofday): When ‘tz’ argument is not NULL, just clear it.
Always pass a null pointer as the second argument to a
gettimeofday (v)syscall.

* sysdeps/unix/bsd/ftime.c: Unconditionally clear the memory that
was formerly the ‘timezone’ and ‘dstflag’ fields of struct timeb.

* sysdeps/unix/syscalls.list: Remove entry for settimeofday.
* sysdeps/unix/settimeofday.c: New file.
(settimeofday): Fail with ENOSYS if ‘tz’ argument is not NULL.

* sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove entries for
        osf_gettimeofday, osf_settimeofday, and settimeofday.
* sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c:
New file.  Call the 64-bit gettimeofday, then convert to a
32-bit struct timeval.  On overflow, saturate the struct timeval
and fail with EOVERFLOW.
* sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c: New file.
        Convert to a 64-bit struct timeval and call 64-bit settimeofday.
        Fail with ENOSYS if ‘tz’ argument is not NULL.

* sunrpc/auth_des.c, sunrpc/auth_unix.c
* sysdeps/posix/time.c, sysdeps/unix/stime.c:
Remove unnecessary casts of NULL.

* sysdeps/unix/sysv/linux/powerpc/time.c (time_syscall):
Use (void *)0 instead of NULL when passing a null pointer
as an untyped argument.

* manual/time.texi: Remove documentation of fields of
struct timezone.  Revise text to further emphasize that
the second argument to gettimeofday/settimeofday should
always be a null pointer.
24 files changed:
NEWS
conform/Makefile
manual/time.texi
sunrpc/auth_des.c
sunrpc/auth_unix.c
sunrpc/create_xid.c
sunrpc/svcauth_des.c
sysdeps/mach/gettimeofday.c
sysdeps/posix/gettimeofday.c
sysdeps/posix/time.c
sysdeps/unix/bsd/ftime.c
sysdeps/unix/settimeofday.c [new file with mode: 0644]
sysdeps/unix/stime.c
sysdeps/unix/syscalls.list
sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/alpha/syscalls.list
sysdeps/unix/sysv/linux/gettimeofday.c
sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
sysdeps/unix/sysv/linux/powerpc/time.c
sysdeps/unix/sysv/linux/x86/gettimeofday.c
time/sys/time.h
time/sys/timeb.h