summaryrefslogtreecommitdiff
path: root/sys/kern/kern_tc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_tc.c')
-rw-r--r--sys/kern/kern_tc.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index eccf869c19c..565c24b206f 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_tc.c,v 1.38 2019/03/09 23:04:56 cheloha Exp $ */
+/* $OpenBSD: kern_tc.c,v 1.39 2019/03/10 21:16:15 cheloha Exp $ */
/*
* Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org>
@@ -116,6 +116,8 @@ static struct timecounter *timecounters = &dummy_timecounter;
volatile time_t time_second = 1;
volatile time_t time_uptime = 0;
+int64_t adjtimedelta; /* unapplied time correction (microseconds) */
+
struct bintime naptime;
static int timestepwarnings;
@@ -358,6 +360,12 @@ tc_setrealtimeclock(const struct timespec *ts)
timespec2bintime(ts, &bt);
bintime_sub(&bt, &bt2);
bintime_add(&bt2, &timehands->th_boottime);
+
+ /*
+ * Adjtime in progress is meaningless or harmful after
+ * setting the clock. Cancel adjtime and then set new time.
+ */
+ adjtimedelta = 0;
timehands->th_boottime = bt;
/* XXX fiddle all the little crinkly bits around the fiords... */
@@ -724,3 +732,12 @@ tc_adjfreq(int64_t *old, int64_t *new)
}
return 0;
}
+
+void
+tc_adjtime(int64_t *old, int64_t *new)
+{
+ if (old != NULL)
+ *old = adjtimedelta;
+ if (new != NULL)
+ adjtimedelta = *new;
+}