This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC v4 05/24] sysdeps/clock_gettime: 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: Fri, 9 Aug 2019 18:00:00 -0700
- Subject: [RFC v4 05/24] sysdeps/clock_gettime: Use clock_gettime64 if avaliable
- Ironport-sdr: bJZahOpQtc/FTq62EMz/ZVgxj0LQKIP0btWp8OHWji2RopPDEdQ1T+slMG9udFLzKDw7j+jyE7 6u4QX3gubeXi5e1wv1iUkiv4HNZrMbvdJZbTj1YpSdb/SAS4VILeaBaeNGDw/WIRTJ3bpB34FW 0RcW+DUlKxBXcZFZWQfvtNJ+Pyg4AtU9xNhxrptXlbujGodMcIYFy7M+HNTIVjPX289QSX9yxG z3V/ttN0whlw/6zMk2X9nD6+8fiXQJvKAL6zSP1alqG0C3xR4tCzwXsh4nuBo52t2DSxBegQUF mnA=
- Ironport-sdr: JXSUpH/EgKI+VfValmhLzm656k1NgAJ133UKE5GdI3TWfjMFwUuPqp+SVbnQsoeAz1PMYS7Htu BW9KDOADJcVf7seZcKESIKYzxUakjIKCmUguGFnP2nkTj2Qf7XawU6fC2aymWFF/gY6ayp9VvT YSEQLQuUrvwf8Av0lFi/KzlTRgPOk5naTjPl/oDod+SuHlZiPutcbubhRlM0mLykWx/wRQ7CpA Np8AazXP3WcZjQT6Zhyl9pA7n3jfw6ZOg/TQKj9I8SnBU7GOY6j+ciyzF0s93DkYsTLnljm+on fnkAVDtjEiw6WBRWpE78FQan
- Ironport-sdr: RtcpbyiPFi+Vrc6S7ThJanQ0yR78lh48VrXjEKrcNQOnNAz9n2Nx8D7lIyeh9rBp+sQHTPwXHm BOOIggb2xRhewn1kwwSdGs+UsVOs//0MubS+ghSBYbjl3uoT9muyWLfKcXdVUvyAoRR8Doj+DF zIwk/0qc5uO9DJufOQ+wQvtENBe9NT8VclIDTzK0LzM3+ttGDVyC6sHruQHzUh32hLxuRSvvCq Gfbr7reIrD0/Z3KDo4IihxCCkOPkiLsFZqg9rZ+mmRHQjE2HwLguG9o/deQIjyv8CQlee5/3VC XIo=
- References: <cover.1565398513.git.alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
sysdeps/unix/sysv/linux/clock_gettime.c | 62 ++++++++++++++++++++++++-
1 file changed, 61 insertions(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c
index 5fc47fb7dc7..c090797e461 100644
--- a/sysdeps/unix/sysv/linux/clock_gettime.c
+++ b/sysdeps/unix/sysv/linux/clock_gettime.c
@@ -27,10 +27,70 @@
#include <sysdep-vdso.h>
/* Get current value of CLOCK and store it in TP. */
+
int
__clock_gettime (clockid_t clock_id, struct timespec *tp)
{
- return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp);
+
+#ifdef __ASSUME_TIME64_SYSCALLS
+ return INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp);
+#else
+ int ret;
+# ifdef __NR_clock_gettime64
+# if __TIMESIZE == 64
+ ret = INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp);
+
+ if (ret == 0 || errno != ENOSYS)
+ {
+ return ret;
+ }
+# else
+ struct __timespec64 tp64;
+ ret = INLINE_VSYSCALL (clock_gettime64, 2, clock_id, &tp64);
+
+ if (ret == 0 || errno != ENOSYS)
+ {
+ tp->tv_sec = tp64.tv_sec;
+ tp->tv_nsec = tp64.tv_nsec;
+ if (! in_time_t_range (tp->tv_sec))
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+
+ return 0;
+ }
+# endif /* __TIMESIZE == 64 */
+# endif /* __NR_clock_gettime64 */
+# if __TIMESIZE == 64
+ struct timespec ts32;
+
+ if (! in_time_t_range (tp->tv_sec))
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+
+ ret = INLINE_VSYSCALL (clock_gettime, 2, clock_id, &ts32);
+
+ if (ret == 0 || errno != ENOSYS)
+ {
+ tp->tv_sec = ts32.tv_sec;
+ tp->tv_nsec = ts32.tv_nsec;
+ if (! in_time_t_range (tp->tv_sec))
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+
+ return 0;
+ }
+ return ret;
+# else
+ return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp);
+# endif /* __TIMESIZE == 64 */
+#endif /* __ASSUME_TIME64_SYSCALLS */
}
+
weak_alias (__clock_gettime, clock_gettime)
libc_hidden_def (__clock_gettime)
--
2.22.0