summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_tc.c15
-rw-r--r--sys/kern/kern_time.c16
2 files changed, 26 insertions, 5 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 52094aa620c..2a7d7d3efee 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $OpenBSD: kern_tc.c,v 1.5 2005/05/03 11:10:56 hshoexer Exp $
+ * $OpenBSD: kern_tc.c,v 1.6 2006/10/30 20:19:33 otto Exp $
* $FreeBSD: src/sys/kern/kern_tc.c,v 1.148 2003/03/18 08:45:23 phk Exp $
*/
@@ -600,5 +600,18 @@ ntp_update_second(int64_t *adjust, time_t *sec)
adj.tv_usec = MAX(-500, adjtimedelta.tv_usec - 1000000);
timersub(&adjtimedelta, &adj, &adjtimedelta);
*adjust = ((int64_t)adj.tv_usec * 1000) << 32;
+ *adjust += timecounter->tc_freq_adj;
+}
+
+int
+tc_adjfreq(int64_t *old, int64_t *new)
+{
+ if (old != NULL) {
+ *old = timecounter->tc_freq_adj;
+ }
+ if (new != NULL) {
+ timecounter->tc_freq_adj = *new;
+ }
+ return 0;
}
#endif /* __HAVE_TIMECOUNTER */
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 3f1e10b57dd..a0933e65577 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.59 2006/06/29 19:52:47 kettenis Exp $ */
+/* $OpenBSD: kern_time.c,v 1.60 2006/10/30 20:19:33 otto Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -389,9 +389,17 @@ sys_adjfreq(struct proc *p, void *v, register_t *retval)
}
#else
if (SCARG(uap, oldfreq)) {
- f = 0;
- if ((error = copyout((void *)&f, (void *)SCARG(uap, oldfreq),
- sizeof(int64_t))))
+ if ((error = tc_adjfreq(&f, NULL)) != 0)
+ return (error);
+ if ((error = copyout(&f, SCARG(uap, oldfreq), sizeof(f))) != 0)
+ return (error);
+ }
+ if (SCARG(uap, freq)) {
+ if ((error = suser(p, 0)))
+ return (error);
+ if ((error = copyin(SCARG(uap, freq), &f, sizeof(f))) != 0)
+ return (error);
+ if ((error = tc_adjfreq(NULL, &f)) != 0)
return (error);
}
#endif