summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2013-10-06 01:27:49 +0000
committerguenther <guenther@openbsd.org>2013-10-06 01:27:49 +0000
commite206ca2e95145f116d06a0b130e6c30106e6c835 (patch)
treee879c5cfe966c130496cfc17873f412cc4532599 /sys/kern/kern_time.c
parentBack out POLLHUP change until a problem with xterm hanging on close (diff)
downloadwireguard-openbsd-e206ca2e95145f116d06a0b130e6c30106e6c835.tar.xz
wireguard-openbsd-e206ca2e95145f116d06a0b130e6c30106e6c835.zip
Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, so
that mlarkin@ can fix programs that report rates-over-uptime. ok kettenis@ manpage corrections jmc@ (which I've probably broken again)
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index cb700263911..3e5ca31ef7a 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.82 2013/09/14 01:35:01 guenther Exp $ */
+/* $OpenBSD: kern_time.c,v 1.83 2013/10/06 01:27:50 guenther Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -111,12 +111,18 @@ settime(struct timespec *ts)
int
clock_gettime(struct proc *p, clockid_t clock_id, struct timespec *tp)
{
+ struct bintime bt;
struct proc *q;
switch (clock_id) {
case CLOCK_REALTIME:
nanotime(tp);
break;
+ case CLOCK_UPTIME:
+ binuptime(&bt);
+ bintime_sub(&bt, &naptime);
+ bintime2timespec(&bt, tp);
+ break;
case CLOCK_MONOTONIC:
nanouptime(tp);
break;
@@ -217,6 +223,7 @@ sys_clock_getres(struct proc *p, void *v, register_t *retval)
switch (clock_id) {
case CLOCK_REALTIME:
case CLOCK_MONOTONIC:
+ case CLOCK_UPTIME:
case CLOCK_PROCESS_CPUTIME_ID:
case CLOCK_THREAD_CPUTIME_ID:
ts.tv_sec = 0;