summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2006-06-14 19:52:07 +0000
committerotto <otto@openbsd.org>2006-06-14 19:52:07 +0000
commitda618e04b37ad9d1b7cc5a5d2d2e677343bead4e (patch)
tree400caaed8a062ca77ab20daeb9e890b0469d698c /sys/kern/kern_time.c
parentMissed a part of the kvm86 commit, if option KVM86 is defined it would be (diff)
downloadwireguard-openbsd-da618e04b37ad9d1b7cc5a5d2d2e677343bead4e.tar.xz
wireguard-openbsd-da618e04b37ad9d1b7cc5a5d2d2e677343bead4e.zip
Introducing adjfreq(2), to adjust the clock frequency.
Loosely based on dragonfly code. ok deraadt@
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 7bffe722027..efe209890c9 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.55 2006/06/04 18:47:33 otto Exp $ */
+/* $OpenBSD: kern_time.c,v 1.56 2006/06/14 19:52:07 otto Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -354,10 +354,42 @@ struct timeval adjtimedelta; /* unapplied time correction */
int tickdelta; /* current clock skew, us. per tick */
long timedelta; /* unapplied time correction, us. */
long bigadj = 1000000; /* use 10x skew above bigadj us. */
+int64_t ntp_tick_permanent;
+int64_t ntp_tick_acc;
#endif
/* ARGSUSED */
int
+sys_adjfreq(struct proc *p, void *v, register_t *retval)
+{
+ struct sys_adjfreq_args /* {
+ syscallarg(const int64_t *) freq;
+ syscallarg(int64_t *) oldfreq;
+ } */ *uap = v;
+ int error, s;
+ int64_t f;
+
+ if (SCARG(uap, oldfreq)) {
+ f = ntp_tick_permanent * hz;
+ if ((error = copyout((void *)&f, (void *)SCARG(uap, oldfreq),
+ sizeof(int64_t))))
+ return (error);
+ }
+ if (SCARG(uap, freq)) {
+ if ((error = suser(p, 0)))
+ return (error);
+ if ((error = copyin((void *)SCARG(uap, freq), (void *)&f,
+ sizeof(int64_t))))
+ return (error);
+ s = splclock();
+ ntp_tick_permanent = f / hz;
+ splx(s);
+ }
+ return (0);
+}
+
+/* ARGSUSED */
+int
sys_adjtime(struct proc *p, void *v, register_t *retval)
{
struct sys_adjtime_args /* {
@@ -450,6 +482,7 @@ out:
#endif
}
+
/*
* Get value of an interval timer. The process virtual and
* profiling virtual time timers are kept in the p_stats area, since