diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/mach/gettimeofday.c | 4 | ||||
-rw-r--r-- | sysdeps/posix/gettimeofday.c | 31 | ||||
-rw-r--r-- | sysdeps/posix/time.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/bsd/ftime.c | 10 | ||||
-rw-r--r-- | sysdeps/unix/settimeofday.c | 36 | ||||
-rw-r--r-- | sysdeps/unix/stime.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/syscalls.list | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/aarch64/gettimeofday.c | 8 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c | 62 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c | 51 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/syscalls.list | 3 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/gettimeofday.c | 5 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/gettimeofday.c | 13 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/time.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86/gettimeofday.c | 8 |
15 files changed, 190 insertions, 48 deletions
diff --git a/sysdeps/mach/gettimeofday.c b/sysdeps/mach/gettimeofday.c index 8d0dfbb7dc..f8c9b7ce3f 100644 --- a/sysdeps/mach/gettimeofday.c +++ b/sysdeps/mach/gettimeofday.c @@ -28,8 +28,8 @@ __gettimeofday (struct timeval *tv, struct timezone *tz) { kern_return_t err; - if (tz != NULL) - *tz = (struct timezone){0, 0}; /* XXX */ + if (tz) + memset (tz, 0, sizeof (struct timezone)); if (err = __host_get_time (__mach_host_self (), (time_value_t *) tv)) { diff --git a/sysdeps/posix/gettimeofday.c b/sysdeps/posix/gettimeofday.c index 6ba625e13e..f5c462e11b 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 e1b3bc8d4c..2f7f7a6f3c 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; diff --git a/sysdeps/unix/bsd/ftime.c b/sysdeps/unix/bsd/ftime.c index 3a1c6e9b01..32ce84e662 100644 --- a/sysdeps/unix/bsd/ftime.c +++ b/sysdeps/unix/bsd/ftime.c @@ -17,14 +17,14 @@ #include <sys/timeb.h> #include <sys/time.h> +#include <string.h> int ftime (struct timeb *timebuf) { struct timeval tv; - struct timezone tz; - if (__gettimeofday (&tv, &tz) < 0) + if (__gettimeofday (&tv, 0) < 0) return -1; timebuf->time = tv.tv_sec; @@ -34,7 +34,9 @@ ftime (struct timeb *timebuf) ++timebuf->time; timebuf->millitm = 0; } - timebuf->timezone = tz.tz_minuteswest; - timebuf->dstflag = tz.tz_dsttime; + + memset (timebuf->__preserve_historic_size, 0, + sizeof timebuf->__preserve_historic_size); + return 0; } diff --git a/sysdeps/unix/settimeofday.c b/sysdeps/unix/settimeofday.c new file mode 100644 index 0000000000..741493b470 --- /dev/null +++ b/sysdeps/unix/settimeofday.c @@ -0,0 +1,36 @@ +/* settimeofday -- Set the current time of day. Unix version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <sys/time.h> +#include <sysdep.h> +#include <libc-symbols.h> + +/* Set the current time of day and timezone information. + This call is restricted to the super-user. */ +int +__settimeofday (const struct timeval *tv, const struct timezone *tz) +{ + if (tz) + { + __set_errno (ENOSYS); + return -1; + } + return INLINE_SYSCALL_CALL (settimeofday, tv, (void *)0); +} +weak_alias (__settimeofday, settimeofday); diff --git a/sysdeps/unix/stime.c b/sysdeps/unix/stime.c index b0809be400..554b3efa60 100644 --- a/sysdeps/unix/stime.c +++ b/sysdeps/unix/stime.c @@ -35,5 +35,5 @@ stime (const time_t *when) tv.tv_sec = *when; tv.tv_usec = 0; - return __settimeofday (&tv, (struct timezone *) 0); + return __settimeofday (&tv, 0); } diff --git a/sysdeps/unix/syscalls.list b/sysdeps/unix/syscalls.list index 61e5360b4d..5fedd5733d 100644 --- a/sysdeps/unix/syscalls.list +++ b/sysdeps/unix/syscalls.list @@ -76,7 +76,6 @@ setreuid - setreuid i:ii __setreuid setreuid setrlimit - setrlimit i:ip __setrlimit setrlimit setsid - setsid i: __setsid setsid setsockopt - setsockopt i:iiibn setsockopt __setsockopt -settimeofday - settimeofday i:PP __settimeofday settimeofday setuid - setuid i:i __setuid setuid shutdown - shutdown i:ii shutdown sigaction - sigaction i:ipp __sigaction sigaction diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c index 9180b50bf7..47330e2f83 100644 --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c @@ -35,7 +35,9 @@ static int __gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz) { - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + if (tz) + memset (tz, 0, sizeof (struct timezone)); + return INLINE_VSYSCALL (gettimeofday, 2, tv, (void *)0); } /* PREPARE_VERSION_KNOWN will need an __LP64__ ifdef when ILP32 support @@ -61,7 +63,9 @@ __hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday, int __gettimeofday (struct timeval *tv, struct timezone *tz) { - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); + if (tz) + memset (tz, 0, sizeof (struct timezone)); + return INLINE_SYSCALL (gettimeofday, 2, tv, (void *)0); } libc_hidden_def (__gettimeofday) diff --git a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c new file mode 100644 index 0000000000..8e57727887 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c @@ -0,0 +1,62 @@ +/* gettimeofday -- Get the current time of day. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <limits.h> +#include <sys/time.h> +#include <sysdep.h> +#include <shlib-compat.h> + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +struct timeval32 +{ + int tv_sec, tv_usec; +}; + +/* Get the current time of day and timezone information. */ +int +attribute_compat_text_section +__gettimeofday_tv32 (struct timeval32 *tv32, + struct timezone *tz) +{ + struct timeval tv64; + if (__gettimeofday (&tv64, tz)) + return -1; + + /* The tv_sec field of a 64-bit struct timeval will overflow the + range representable by 'int' at 2038-01-19 03:14:07 +0000. */ + if (tv64.tv_sec > (time_t)INT_MAX) + { + tv32.tv_sec = INT_MAX; + tv32.tv_usec = 0; + __set_errno (EOVERFLOW); + return -1; + } + tv32.tv_sec = (int)tv64.tv_sec; + + /* The tv_usec field of a 64-bit struct timeval may be a 64-bit + type, but it never contains a value outside the range [0, 999999], + so this cast is guaranteed not to lose information. */ + tv32.tv_usec = (int)tv64.tv_usec; + + return 0; +} + +compat_symbol (libc, __gettimeofday_tv32, gettimeofday, GLIBC_2_0); +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c new file mode 100644 index 0000000000..2ab2f8163d --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c @@ -0,0 +1,51 @@ +/* settimeofday -- Set the current time of day. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <sys/time.h> +#include <sysdep.h> +#include <shlib-compat.h> + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +struct timeval32 +{ + int tv_sec, tv_usec; +}; + +/* Set the current time of day and timezone information. + This call is restricted to the super-user. */ +int +attribute_compat_text_section +__settimeofday_tv32 (const struct timeval32 *tv32, + const struct timezone *tz) +{ + if (tz) + { + __set_errno (ENOSYS); + return -1; + } + + struct timeval tv64; + tv64.tv_sec = tv32.tv_sec; + tv64.tv_usec = tv32.tv_usec; + return INLINE_SYSCALL_CALL (settimeofday, tv, (void *)0); +} + +compat_symbol (libc, __settimeofday_tv32, settimeofday, GLIBC_2_0); +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list index 12cd021b60..8244f941b8 100644 --- a/sysdeps/unix/sysv/linux/alpha/syscalls.list +++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list @@ -23,8 +23,6 @@ pciconfig_write EXTRA pciconfig_write 5 pciconfig_write pciconfig_iobase EXTRA pciconfig_iobase 3 __pciconfig_iobase pciconfig_iobase # support old timeval32 entry points -osf_gettimeofday - osf_gettimeofday 2 __gettimeofday_tv32 __gettimeofday@GLIBC_2.0 gettimeofday@GLIBC_2.0 -osf_settimeofday - osf_settimeofday 2 __settimeofday_tv32 settimeofday@GLIBC_2.0 osf_getitimer - osf_getitimer 2 __getitimer_tv32 getitimer@GLIBC_2.0 osf_setitimer - osf_setitimer 3 __setitimer_tv32 setitimer@GLIBC_2.0 osf_utimes - osf_utimes 2 __utimes_tv32 utimes@GLIBC_2.0 @@ -33,7 +31,6 @@ osf_wait4 - osf_wait4 4 __wait4_tv32 wait4@GLIBC_2.0 # support new timeval64 entry points gettimeofday - gettimeofday 2 __GI___gettimeofday gettimeofday@@GLIBC_2.1 __gettimeofday@@GLIBC_2.1 -settimeofday - settimeofday 2 __settimeofday settimeofday@@GLIBC_2.1 getitimer - getitimer 2 __getitimer getitimer@@GLIBC_2.1 setitimer - setitimer 3 __setitimer setitimer@@GLIBC_2.1 utimes - utimes 2 __utimes utimes@@GLIBC_2.1 diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c index a74f03825a..3509ca9530 100644 --- a/sysdeps/unix/sysv/linux/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/gettimeofday.c @@ -18,6 +18,7 @@ #include <errno.h> #include <sys/time.h> +#include <string.h> #undef __gettimeofday @@ -32,7 +33,9 @@ int __gettimeofday (struct timeval *tv, struct timezone *tz) { - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + if (tz) + memset (tz, 0, sizeof (struct timezone)); + return INLINE_VSYSCALL (gettimeofday, 2, tv, (void *)0); } libc_hidden_def (__gettimeofday) weak_alias (__gettimeofday, gettimeofday) diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c index 463b678ad9..e798a80ee0 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -22,6 +22,7 @@ #endif #include <sys/time.h> +#include <string.h> #ifdef SHARED @@ -35,7 +36,9 @@ int __gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz) { - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + if (tz) + memset (tz, 0, sizeof (struct timezone)); + return INLINE_VSYSCALL (gettimeofday, 2, tv, (void *)0); } /* __GI___gettimeofday is defined as hidden and for ppc32 it enables the @@ -54,7 +57,9 @@ __gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz) static int __gettimeofday_syscall (struct timeval *tv, struct timezone *tz) { - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); + if (tz) + memset (tz, 0, sizeof (struct timezone)); + return INLINE_SYSCALL (gettimeofday, 2, tv, (void *)0); } # define INIT_ARCH() \ @@ -76,7 +81,9 @@ libc_hidden_def (__gettimeofday) int __gettimeofday (struct timeval *tv, struct timezone *tz) { - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); + if (tz) + memset (tz, 0, sizeof (struct timezone)); + return INLINE_SYSCALL (gettimeofday, 2, tv, (void *)0); } libc_hidden_def (__gettimeofday) diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c index cb3e8b9a73..42b0d2d562 100644 --- a/sysdeps/unix/sysv/linux/powerpc/time.c +++ b/sysdeps/unix/sysv/linux/powerpc/time.c @@ -56,7 +56,7 @@ time_syscall (time_t *t) struct timeval tv; time_t result; - if (INLINE_VSYSCALL (gettimeofday, 2, &tv, NULL) < 0) + if (INLINE_VSYSCALL (gettimeofday, 2, &tv, (void *)0) < 0) result = (time_t) -1; else result = (time_t) tv.tv_sec; diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c index 8886ccd707..58a8763ef9 100644 --- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/x86/gettimeofday.c @@ -26,7 +26,9 @@ static int __gettimeofday_syscall (struct timeval *tv, struct timezone *tz) { - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); + if (tz) + memset (tz, 0, sizeof (struct timezone)); + return INLINE_SYSCALL (gettimeofday, 2, tv, (void *)0); } # ifndef __gettimeofday_type @@ -52,7 +54,9 @@ libc_hidden_def (__gettimeofday) int __gettimeofday (struct timeval *tv, struct timezone *tz) { - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); + if (tz) + memset (tz, 0, sizeof (struct timezone)); + return INLINE_SYSCALL (gettimeofday, 2, tv, (void *)0); } libc_hidden_def (__gettimeofday) |