diff options
author | Zack Weinberg <zackw@panix.com> | 2019-07-27 19:26:23 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2019-07-27 20:14:35 -0400 |
commit | 3f649995a112b91754b49b7fff389385ce55f54f (patch) | |
tree | 3999bdce24cbfc67c223f3610ba6dd92d59d0994 /sysdeps/posix | |
parent | 50ce3eae5ba304650459d4441d7d246a7cefc26f (diff) | |
download | glibc-zack/gtod-no-timezone.zip glibc-zack/gtod-no-timezone.tar.gz glibc-zack/gtod-no-timezone.tar.bz2 |
Remove access to legacy time zone support in gettimeofday etc.zack/gtod-no-timezone
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.
Diffstat (limited to 'sysdeps/posix')
-rw-r--r-- | sysdeps/posix/gettimeofday.c | 31 | ||||
-rw-r--r-- | sysdeps/posix/time.c | 2 |
2 files changed, 5 insertions, 28 deletions
diff --git a/sysdeps/posix/gettimeofday.c b/sysdeps/posix/gettimeofday.c index 6ba625e..f5c462e 100644 --- a/sysdeps/posix/gettimeofday.c +++ b/sysdeps/posix/gettimeofday.c @@ -31,34 +31,11 @@ __gettimeofday (struct timeval *tv, struct timezone *tz) return -1; } - tv->tv_sec = (long int) time ((time_t *) NULL); - tv->tv_usec = 0L; + if (tz) + memset (tz, 0, sizeof (struct timezone)); - if (tz != NULL) - { - const time_t timer = tv->tv_sec; - struct tm tm; - const struct tm *tmp; - - const long int save_timezone = __timezone; - const long int save_daylight = __daylight; - char *save_tzname[2]; - save_tzname[0] = __tzname[0]; - save_tzname[1] = __tzname[1]; - - tmp = localtime_r (&timer, &tm); - - tz->tz_minuteswest = __timezone / 60; - tz->tz_dsttime = __daylight; - - __timezone = save_timezone; - __daylight = save_daylight; - __tzname[0] = save_tzname[0]; - __tzname[1] = save_tzname[1]; - - if (tmp == NULL) - return -1; - } + tv->tv_usec = 0; + tv->tv_sec = time (0); return 0; } diff --git a/sysdeps/posix/time.c b/sysdeps/posix/time.c index e1b3bc8..2f7f7a6 100644 --- a/sysdeps/posix/time.c +++ b/sysdeps/posix/time.c @@ -28,7 +28,7 @@ time (time_t *t) struct timeval tv; time_t result; - if (__gettimeofday (&tv, (struct timezone *) NULL)) + if (__gettimeofday (&tv, 0)) result = (time_t) -1; else result = (time_t) tv.tv_sec; |