summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2017-12-18 05:51:54 +0000
committercheloha <cheloha@cvs.openbsd.org>2017-12-18 05:51:54 +0000
commit8e394bb0e5f25c84775150ebb5389670cae488c7 (patch)
treee2716e9835a7872f76ef5fcfa82893972f1624c4 /sys/kern
parent8fd06186df470fde0080330a0b2f5829bf0c6a1d (diff)
Add the CLOCK_BOOTTIME clockid for use with clock_gettime(2)
and put it to use in userspace in lieu of the kern.boottime sysctl. Its absolute value is the time that has elapsed since the system booted, i.e., the system uptime. Use in top(1), w(1), and snmpd(8) eliminates a race with settimeofday(2), adjtime(2), etc. inherent to deriving the system uptime via the kern.boottime sysctl. Product of a great deal of discussion/revision with jca@, tb@, and guenther@. ok tb@ jca@ guenther@ dlg@ mlarkin@ tom@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_time.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 8193c4eda43..61a9b559e5c 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.99 2017/01/24 00:58:55 mpi Exp $ */
+/* $OpenBSD: kern_time.c,v 1.100 2017/12/18 05:51:53 cheloha Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -124,6 +124,7 @@ clock_gettime(struct proc *p, clockid_t clock_id, struct timespec *tp)
bintime2timespec(&bt, tp);
break;
case CLOCK_MONOTONIC:
+ case CLOCK_BOOTTIME:
nanouptime(tp);
break;
case CLOCK_PROCESS_CPUTIME_ID:
@@ -223,6 +224,7 @@ sys_clock_getres(struct proc *p, void *v, register_t *retval)
switch (clock_id) {
case CLOCK_REALTIME:
case CLOCK_MONOTONIC:
+ case CLOCK_BOOTTIME:
case CLOCK_UPTIME:
case CLOCK_PROCESS_CPUTIME_ID:
case CLOCK_THREAD_CPUTIME_ID: