This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
[glibc/azanella/y2038-preliminaries] Make second argument of gettimeofday as 'void *'
- From: Adhemerval Zanella <azanella at sourceware dot org>
- To: glibc-cvs at sourceware dot org
- Date: 25 Oct 2019 11:26:19 -0000
- Subject: [glibc/azanella/y2038-preliminaries] Make second argument of gettimeofday as 'void *'
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8860ddfdac37caa8a781c93c0530b550e16705c7
commit 8860ddfdac37caa8a781c93c0530b550e16705c7
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Aug 19 13:51:25 2019 -0400
Make second argument of gettimeofday as 'void *'
Also make the public prototype of gettimeofday declare its second
argument with type "void *" unconditionally, consistent with POSIX.
It is also consistent with POSIX.
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diff:
---
include/sys/time.h | 2 +-
sysdeps/unix/sysv/linux/aarch64/gettimeofday.c | 4 ++--
sysdeps/unix/sysv/linux/powerpc/gettimeofday.c | 4 ++--
sysdeps/unix/sysv/linux/x86/gettimeofday.c | 4 ++--
time/gettimeofday.c | 4 ++--
time/sys/time.h | 23 ++++++++++++-----------
6 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/include/sys/time.h b/include/sys/time.h
index 2bf4297..a461295 100644
--- a/include/sys/time.h
+++ b/include/sys/time.h
@@ -21,7 +21,7 @@
# ifndef _ISOMAC
extern int __gettimeofday (struct timeval *__tv,
- struct timezone *__tz);
+ void *__tz);
extern int __settimezone (const struct timezone *__tz)
attribute_hidden;
extern int __adjtime (const struct timeval *__delta,
diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
index 075af3d..7e772e0 100644
--- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
@@ -31,7 +31,7 @@
/* Used as a fallback in the ifunc resolver if VDSO is not available
and for libc.so internal __gettimeofday calls. */
static int
-__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
+__gettimeofday_vsyscall (struct timeval *restrict tv, void *restrict tz)
{
if (__glibc_unlikely (tz != 0))
memset (tz, 0, sizeof *tz);
@@ -50,7 +50,7 @@ libc_ifunc (__gettimeofday,
#else
int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
+__gettimeofday (struct timeval *restrict tv, void *restrict tz)
{
return __gettimeofday_vsyscall (tv, tz);
}
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
index 02486de..18d8f7c 100644
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
@@ -24,7 +24,7 @@
#include <sysdep-vdso.h>
static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
+__gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz)
{
if (__glibc_unlikely (tz != 0))
memset (tz, 0, sizeof *tz);
@@ -46,7 +46,7 @@ libc_ifunc (__gettimeofday,
: (void *) __gettimeofday_syscall);
#else
int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
+__gettimeofday (struct timeval *restrict tv, void *restrict tz)
{
return __gettimeofday_syscall (tv, tz);
}
diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c
index cb20e35..190127d 100644
--- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/x86/gettimeofday.c
@@ -25,7 +25,7 @@
#include <sysdep-vdso.h>
static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
+__gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz)
{
if (__glibc_unlikely (tz != 0))
memset (tz, 0, sizeof *tz);
@@ -45,7 +45,7 @@ libc_ifunc (__gettimeofday,
#else
int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
+__gettimeofday (struct timeval *restrict tv, void *restrict tz)
{
return __gettimeofday_syscall (tv, tz);
}
diff --git a/time/gettimeofday.c b/time/gettimeofday.c
index e8055b3..ddaf46f 100644
--- a/time/gettimeofday.c
+++ b/time/gettimeofday.c
@@ -23,10 +23,10 @@
If *TZ is not NULL, clear it.
Returns 0 on success, -1 on errors. */
int
-___gettimeofday (struct timeval *tv, struct timezone *tz)
+___gettimeofday (struct timeval *restrict tv, void *restrict tz)
{
if (__glibc_unlikely (tz != 0))
- memset (tz, 0, sizeof *tz);
+ memset (tz, 0, sizeof (struct timezone));
struct timespec ts;
if (__clock_gettime (CLOCK_REALTIME, &ts))
diff --git a/time/sys/time.h b/time/sys/time.h
index f8c946f..0473dae 100644
--- a/time/sys/time.h
+++ b/time/sys/time.h
@@ -54,23 +54,24 @@ struct timezone
int tz_minuteswest; /* Minutes west of GMT. */
int tz_dsttime; /* Nonzero if DST is ever in effect. */
};
-
-typedef struct timezone *__restrict __timezone_ptr_t;
-#else
-typedef void *__restrict __timezone_ptr_t;
#endif
-/* Get the current time of day and timezone information,
- putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
- Returns 0 on success, -1 on errors.
- NOTE: This form of timezone information is obsolete.
- Use the functions and variables declared in <time.h> instead. */
+/* Get the current time of day, putting it into *TV.
+ If TZ is not null, *TZ must be a struct timezone, and both fields
+ will be set to zero.
+ Calling this function with a non-null TZ is obsolete;
+ use localtime etc. instead.
+ This function itself is semi-obsolete;
+ most callers should use time or clock_gettime instead. */
extern int gettimeofday (struct timeval *__restrict __tv,
- __timezone_ptr_t __tz) __THROW __nonnull ((1));
+ void *__restrict __tz) __THROW __nonnull ((1));
#ifdef __USE_MISC
/* Set the current time of day and timezone information.
- This call is restricted to the super-user. */
+ This call is restricted to the super-user.
+ Setting the timezone in this way is obsolete, but we don't yet
+ warn about it because it still has some uses for which there is
+ no alternative. */
extern int settimeofday (const struct timeval *__tv,
const struct timezone *__tz)
__THROW;