diff options
author | kib <kib@FreeBSD.org> | 2016-09-16 10:04:28 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2016-09-16 10:04:28 +0000 |
commit | dddfacf75a4db48e5a557d2ca395fcf246f37b70 (patch) | |
tree | ea58970436c8250f3ddf63bd4caeee598547c297 /lib/libc/sys | |
parent | 4a1f75f05099b39074e0485603c771634cb71527 (diff) | |
download | FreeBSD-src-dddfacf75a4db48e5a557d2ca395fcf246f37b70.zip FreeBSD-src-dddfacf75a4db48e5a557d2ca395fcf246f37b70.tar.gz |
MFC r304285:
Implement userspace gettimeofday(2) with HPET timecounter.
Diffstat (limited to 'lib/libc/sys')
-rw-r--r-- | lib/libc/sys/__vdso_gettimeofday.c | 23 | ||||
-rw-r--r-- | lib/libc/sys/trivial-vdso_tc.c | 6 |
2 files changed, 19 insertions, 10 deletions
diff --git a/lib/libc/sys/__vdso_gettimeofday.c b/lib/libc/sys/__vdso_gettimeofday.c index b3527fa..0368b97 100644 --- a/lib/libc/sys/__vdso_gettimeofday.c +++ b/lib/libc/sys/__vdso_gettimeofday.c @@ -34,12 +34,16 @@ __FBSDID("$FreeBSD$"); #include <machine/atomic.h> #include "libc_private.h" -static u_int -tc_delta(const struct vdso_timehands *th) +static int +tc_delta(const struct vdso_timehands *th, u_int *delta) { + int error; + u_int tc; - return ((__vdso_gettc(th) - th->th_offset_count) & - th->th_counter_mask); + error = __vdso_gettc(th, &tc); + if (error == 0) + *delta = (tc - th->th_offset_count) & th->th_counter_mask; + return (error); } /* @@ -56,6 +60,8 @@ binuptime(struct bintime *bt, struct vdso_timekeep *tk, int abs) { struct vdso_timehands *th; uint32_t curr, gen; + u_int delta; + int error; do { if (!tk->tk_enabled) @@ -63,11 +69,14 @@ binuptime(struct bintime *bt, struct vdso_timekeep *tk, int abs) curr = atomic_load_acq_32(&tk->tk_current); th = &tk->tk_th[curr]; - if (th->th_algo != VDSO_TH_ALGO_1) - return (ENOSYS); gen = atomic_load_acq_32(&th->th_gen); *bt = th->th_offset; - bintime_addx(bt, th->th_scale * tc_delta(th)); + error = tc_delta(th, &delta); + if (error == EAGAIN) + continue; + if (error != 0) + return (error); + bintime_addx(bt, th->th_scale * delta); if (abs) bintime_add(bt, &th->th_boottime); diff --git a/lib/libc/sys/trivial-vdso_tc.c b/lib/libc/sys/trivial-vdso_tc.c index b99bbc4..ce0c144 100644 --- a/lib/libc/sys/trivial-vdso_tc.c +++ b/lib/libc/sys/trivial-vdso_tc.c @@ -32,11 +32,11 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #pragma weak __vdso_gettc -u_int -__vdso_gettc(const struct vdso_timehands *th) +int +__vdso_gettc(const struct vdso_timehands *th, u_int *tc) { - return (0); + return (ENOSYS); } #pragma weak __vdso_gettimekeep |