diff options
-rw-r--r-- | sys/kern/kern_tc.c | 26 | ||||
-rw-r--r-- | sys/sys/time.h | 5 |
2 files changed, 29 insertions, 2 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index e8cc25b02d6..16cf1fa70b7 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_tc.c,v 1.80 2022/12/05 23:18:37 deraadt Exp $ */ +/* $OpenBSD: kern_tc.c,v 1.81 2022/12/13 17:30:36 cheloha Exp $ */ /* * Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org> @@ -295,6 +295,30 @@ nanoruntime(struct timespec *ts) } void +getbinruntime(struct bintime *bt) +{ + struct timehands *th; + u_int gen; + + do { + th = timehands; + gen = th->th_generation; + membar_consumer(); + bintimesub(&th->th_offset, &th->th_naptime, bt); + membar_consumer(); + } while (gen == 0 || gen != th->th_generation); +} + +uint64_t +getnsecruntime(void) +{ + struct bintime bt; + + getbinruntime(&bt); + return BINTIME_TO_NSEC(&bt); +} + +void bintime(struct bintime *bt) { struct timehands *th; diff --git a/sys/sys/time.h b/sys/sys/time.h index d4736c97cb6..20bfba4cbb8 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -1,4 +1,4 @@ -/* $OpenBSD: time.h,v 1.62 2022/07/23 22:58:51 cheloha Exp $ */ +/* $OpenBSD: time.h,v 1.63 2022/12/13 17:30:36 cheloha Exp $ */ /* $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $ */ /* @@ -318,6 +318,9 @@ void nanoboottime(struct timespec *); void binruntime(struct bintime *); void nanoruntime(struct timespec *); +void getbinruntime(struct bintime *); +uint64_t getnsecruntime(void); + time_t gettime(void); time_t getuptime(void); |