diff options
author | phk <phk@FreeBSD.org> | 1999-12-08 10:02:12 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-12-08 10:02:12 +0000 |
commit | 69d6534e2aea10d15640d7ffe048e3fc4cc6dd09 (patch) | |
tree | 02f3964d745f8c385893233b9f09386c60b17efc /sys/kern/kern_clock.c | |
parent | 9437e16a29ffc2c3601997f535d63326a048df24 (diff) | |
download | FreeBSD-src-69d6534e2aea10d15640d7ffe048e3fc4cc6dd09.zip FreeBSD-src-69d6534e2aea10d15640d7ffe048e3fc4cc6dd09.tar.gz |
Make adjtime(2) adjust boottime so it doesn't cause non-monotonous
uptime.
Diffstat (limited to 'sys/kern/kern_clock.c')
-rw-r--r-- | sys/kern/kern_clock.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 55dcc5d..02fb48a 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -758,6 +758,7 @@ static void tco_forward(int force) { struct timecounter *tc, *tco; + struct timeval tvt; tco = timecounter; tc = sync_other_counter(); @@ -773,9 +774,17 @@ tco_forward(int force) if (tco->tc_poll_pps) tco->tc_poll_pps(tco); if (timedelta != 0) { - tc->tc_offset_nano += (u_int64_t)(tickdelta * 1000) << 32; + tvt = boottime; + tvt.tv_usec -= tickdelta; + if (tvt.tv_usec >= 1000000) { + tvt.tv_sec++; + tvt.tv_usec -= 1000000; + } else if (tvt.tv_usec < 0) { + tvt.tv_sec--; + tvt.tv_usec += 1000000; + } + boottime = tvt; timedelta -= tickdelta; - force++; } while (tc->tc_offset_nano >= 1000000000ULL << 32) { |