This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC v3 05/23] sysdeps/timespec_get: Use clock_gettime64 if avaliable
- From: Alistair Francis <alistair dot francis at wdc dot com>
- To: libc-alpha at sourceware dot org
- Cc: arnd at arndb dot de, adhemerval dot zanella at linaro dot org, fweimer at redhat dot com, palmer at sifive dot com, macro at wdc dot com, zongbox at gmail dot com, alistair dot francis at wdc dot com, alistair23 at gmail dot com
- Date: Tue, 16 Jul 2019 17:08:54 -0700
- Subject: [RFC v3 05/23] sysdeps/timespec_get: Use clock_gettime64 if avaliable
- Ironport-sdr: KLwANiBuvC9iVQQd4PqrFchgck1F2OsfYuU609qnnofLAyEuDgJ1oXc0CkpvI8MKvcTZ08sdvp RRUpsLP9SMeGWgXyZ965DPGpksPDUzyt+ryfFiYH6ozyz/O6vnedTSWf8bb9GJdlAzVkLMysM0 Q4/kont825l/47yrggG2Y+fj3DlvhjdRC9w4C9pGtcEbKldH7BgoLJJcSdwtnGK5NmXqsZ1zp5 j3kWP6ye+QqU1t9oUBTl4ZKx02qsktf7PJj1hoJZAnJDhyetD59HSVt2qC8/B4A6XJ67Uai40Z +9M=
- Ironport-sdr: FKFhDpTqdT0/BeGNwjzI7heC1fQKjAc4dISQS3xLCnH04b3Xy+oI334fgLaKyiLIV6ILjunj9f nCFHtiCqi/GnAL7T1tCb4/9gSdCk180khI/lhzPHd17Xj00JeqMX7JSAGTZD6Pxbk06aTcpkjS WrIQ7sYl/Q77e4O5Hhei6GHmkgaYLNNcabvP/8ZaZ+OgnglKlPpJH34tWOdt4pN+TkvvCr2niw h9S07JAeLod8iyns2n2Jt52svZgT/0rgtdifhQhiVm9A3s6IcsmaAl337Bk+H11CJOjn558C4T OOitvPBUEOqhoxh8kBpTa9/I
- Ironport-sdr: JsvQtufBrxEKnc1ZyF2B66/N4hCh3eNTYSmcwZ53RiV/FgZBSs/wEnSzx2Vnh4Q881GYyNV1eB PtAvN7WL7a9wK7ixOvOszQHuhM1bL6Wpel/wSjQDs4FpaU4nDP68xwOaRLmo0p6EKgLX1CgCa2 9mM/ijThfGF3IgWjuoVEo92RpEgMD/kl7xF+qjNt6+nrFnfeofEBDe16PUF8hKqIFp9QTq0ZSn dxShnVMaE7Fgb50NFVpCJOTY5vSs0dTBvRSjmUN7HIGiCulpJ89Am2TLlbQMMGXs10RytCygRG NGo=
- References: <cover.1563321715.git.alistair.francis@wdc.com>
This will break other 32-bit targets
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
sysdeps/unix/sysv/linux/timespec_get.c | 37 +++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/timespec_get.c b/sysdeps/unix/sysv/linux/timespec_get.c
index 52080ddf08..78fa2aba1b 100644
--- a/sysdeps/unix/sysv/linux/timespec_get.c
+++ b/sysdeps/unix/sysv/linux/timespec_get.c
@@ -24,6 +24,36 @@
#endif
#include <sysdep-vdso.h>
+
+#if __WORDSIZE == 32
+int
+__timespec_get (struct timespec *ts, int base)
+{
+ int ret;
+
+#ifdef __NR_clock_gettime64
+ struct __timespec64 ts64;
+ ret = INTERNAL_VSYSCALL (clock_gettime64, err, 2, CLOCK_REALTIME, &ts64);
+
+ ts->tv_sec = ts64.tv_sec;
+ ts->tv_nsec = ts64.tv_nsec;
+
+ if (! in_time_t_range (ts->tv_sec))
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+#endif
+
+#ifndef __ASSUME_TIME64_SYSCALLS
+ ret = INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, ts);
+#endif
+
+ return ret;
+}
+
+#else
+
/* Set TS to calendar time based in time base BASE. */
int
timespec_get (struct timespec *ts, int base)
@@ -33,9 +63,13 @@ timespec_get (struct timespec *ts, int base)
int res;
INTERNAL_SYSCALL_DECL (err);
case TIME_UTC:
+#if __WORDSIZE == 32
+ res = __timespec_get (*ts, base);
+#else
res = INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, ts);
+#endif
if (INTERNAL_SYSCALL_ERROR_P (res, err))
- return 0;
+ return 0;
break;
default:
@@ -44,3 +78,4 @@ timespec_get (struct timespec *ts, int base)
return base;
}
+#endif
--
2.22.0