Add the CLOCK_BOOTTIME clockid for use with clock_gettime(2)
authorcheloha <cheloha@openbsd.org>
Mon, 18 Dec 2017 05:51:53 +0000 (05:51 +0000)
committercheloha <cheloha@openbsd.org>
Mon, 18 Dec 2017 05:51:53 +0000 (05:51 +0000)
commitb50bd52298d27e598cd86594738b76dabd7f258a
tree27dbed125d8ac08f4d205b8cf8e902a9099262b9
parent28eeb9e1cbb72b5800aa282450ba52b6aed39e31
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@
lib/libc/sys/clock_gettime.2
sys/kern/kern_time.c
sys/sys/_time.h
usr.bin/top/display.c
usr.bin/w/w.c
usr.sbin/snmpd/mib.c