diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux/alpha')
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/gettimeofday.c | 22 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c | 11 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/tv32-compat.h | 6 |
3 files changed, 36 insertions, 3 deletions
diff --git a/sysdeps/unix/sysv/linux/alpha/gettimeofday.c b/sysdeps/unix/sysv/linux/alpha/gettimeofday.c new file mode 100644 index 0000000000..262a3c2352 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/gettimeofday.c @@ -0,0 +1,22 @@ +/* gettimeofday -- Get the current time of day. Linux/Alpha/tv64 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 + <https://www.gnu.org/licenses/>. */ + +/* We can use the generic implementation, but we have to override its + default symbol version. */ +#define VERSION_gettimeofday GLIBC_2.1 +#include <time/gettimeofday.c> diff --git a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c index 59fc614523..4698c8a5db 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c @@ -20,6 +20,8 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +#include <string.h> +#include <time.h> #include <sys/time.h> #include <tv32-compat.h> @@ -30,10 +32,13 @@ int attribute_compat_text_section __gettimeofday_tv32 (struct timeval32 *restrict tv32, void *restrict tz) { - struct timeval tv; - __gettimeofday (&tv, tz); + if (__glibc_unlikely (tz != 0)) + memset (tz, 0, sizeof (struct timezone)); - *tv32 = valid_timeval64_to_timeval (tv); + struct timespec ts; + __clock_gettime (CLOCK_REALTIME, &ts); + + *tv32 = valid_timespec_to_timeval32 (ts); return 0; } diff --git a/sysdeps/unix/sysv/linux/alpha/tv32-compat.h b/sysdeps/unix/sysv/linux/alpha/tv32-compat.h index 5f86e66e08..0fbf284bb5 100644 --- a/sysdeps/unix/sysv/linux/alpha/tv32-compat.h +++ b/sysdeps/unix/sysv/linux/alpha/tv32-compat.h @@ -89,6 +89,12 @@ valid_timeval32_to_timespec (const struct timeval32 tv) return (struct timespec) { tv.tv_sec, tv.tv_usec * 1000 }; } +static inline struct timeval32 +valid_timespec_to_timeval32 (const struct timespec ts) +{ + return (struct timeval32) { (time_t) ts.tv_sec, ts.tv_nsec / 1000 }; +} + static inline void rusage64_to_rusage32 (struct rusage32 *restrict r32, const struct rusage *restrict r64) |