aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-04-08 11:15:24 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-10-24 12:53:27 +0200
commit09cb6964e2e03b5fe49e336c800b00354f2c3901 (patch)
treee9235e65e0addc38d1ab891157e7ef0ff5fab38f /nptl
parent94811042d73239d35b9d4bf7592c62ccc65ce633 (diff)
downloadglibc-09cb6964e2e03b5fe49e336c800b00354f2c3901.zip
glibc-09cb6964e2e03b5fe49e336c800b00354f2c3901.tar.gz
glibc-09cb6964e2e03b5fe49e336c800b00354f2c3901.tar.bz2
Y2038: add function __clock_gettime64
* include/time.h: Declare __clock_gettime64(). * ntpl/pthread_clock_gettime.c: Add __pthread_clock_gettime64(). * ntpl/pthread_clock_gettime.c: Make __pthread_clock_gettime() a wrapper around __pthread_clock_gettime64(). * sysdeps/unix/clock_gettime.c (hp_timing_gettime): Use struct __timespec64. * sysdeps/unix/clock_gettime.c (realtime_gettime): Likewise. * sysdeps/unix/clock_gettime.c: Add __clock_gettime64(). * sysdeps/unix/clock_gettime.c: Make __clock_gettime() a wrapper around __clock_gettime64(). * sysdeps/unix/sysv/linux/clock_gettime.c: Add 64-bit-time syscall support.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/pthread_clock_gettime.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/nptl/pthread_clock_gettime.c b/nptl/pthread_clock_gettime.c
index 6bc75cf..508821b 100644
--- a/nptl/pthread_clock_gettime.c
+++ b/nptl/pthread_clock_gettime.c
@@ -18,13 +18,14 @@
#include <errno.h>
#include <stdlib.h>
#include <time.h>
+#include <bits/types/struct_timespec64.h>
#include "pthreadP.h"
#if HP_TIMING_AVAIL
int
-__pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
- struct timespec *tp)
+__pthread_clock_gettime64 (clockid_t clock_id, hp_timing_t freq,
+ struct __timespec64 *tp)
{
hp_timing_t tsc;
@@ -64,4 +65,36 @@ __pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
return 0;
}
+
+int
+__pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
+ struct timespec *tp)
+{
+ struct __timespec64 ts64;
+ int res;
+
+ if (tp == NULL)
+ {
+ __set_errno(EINVAL);
+ res = -1;
+ }
+ else
+ {
+ int res = __pthread_clock_gettime64 (clock_id, freq, &ts64);
+ if (res == 0)
+ {
+ if (fits_in_time_t (ts64.tv_time))
+ {
+ tp->tv_sec = ts64.tv_sec;
+ tp->tv_nsec = ts64.tv_nsec;
+ }
+ else
+ {
+ set_errno(EOVERFLOW);
+ res = -1;
+ }
+ }
+ }
+ return res;
+}
#endif