From b4a1d0deb105df01f80dac1be7e282928a3963ea Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Fri, 26 Apr 2002 21:31:44 +0000 Subject: [PATCH] Hide the private parts of timecounter from a couple of places that don't really need to know the gory details. --- sys/kern/kern_ntptime.c | 6 ++---- sys/kern/kern_tc.c | 14 ++++++++++---- sys/kern/kern_time.c | 2 +- sys/sys/timetc.h | 1 + sys/sys/timex.h | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index 34771c20118..cd2db730342 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -436,13 +436,11 @@ done2: * simulation. */ void -ntp_update_second(struct timecounter *tcp) +ntp_update_second(int64_t *adjustment, time_t *newsec) { - u_int32_t *newsec; int tickrate; l_fp ftemp; /* 32/64-bit temporary */ - newsec = &tcp->tc_offset.sec; /* * On rollover of the second both the nanosecond and microsecond * clocks are updated and the state machine cranked as @@ -558,7 +556,7 @@ ntp_update_second(struct timecounter *tcp) L_LINT(ftemp, tickrate * 1000); L_ADD(time_adj, ftemp); } - tcp->tc_adjustment = time_adj; + *adjustment = time_adj; #ifdef PPS_SYNC if (pps_valid > 0) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index fe07aec9bc5..23c85cf0a97 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -312,6 +312,13 @@ tc_setclock(struct timespec *ts) tc_windup(); } +u_int32_t +tc_getfrequency(void) +{ + + return (timecounter->tc_frequency); +} + static void switch_timecounter(struct timecounter *newtc) { @@ -362,10 +369,9 @@ tc_windup(void) */ if (tco->tc_poll_pps) tco->tc_poll_pps(tco); - for (i = tc->tc_offset.sec - tco->tc_offset.sec; i > 0; i--) { - ntp_update_second(tc); /* XXX only needed if xntpd runs */ - tc_setscales(tc); - } + for (i = tc->tc_offset.sec - tco->tc_offset.sec; i > 0; i--) + ntp_update_second(&tc->tc_adjustment, &tc->tc_offset.sec); + tc_setscales(tc); bt = tc->tc_offset; bintime_add(&bt, &boottimebin); diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index fd862129861..645170ecda0 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -222,7 +222,7 @@ clock_getres(td, uap) error = 0; if (SCARG(uap, tp)) { ts.tv_sec = 0; - ts.tv_nsec = 1000000000 / timecounter->tc_frequency; + ts.tv_nsec = 1000000000 / tc_getfrequency(); error = copyout(&ts, SCARG(uap, tp), sizeof(ts)); } return (error); diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h index 5b212fe5c26..a35f6fb32cd 100644 --- a/sys/sys/timetc.h +++ b/sys/sys/timetc.h @@ -93,6 +93,7 @@ struct timecounter { #ifdef _KERNEL extern struct timecounter *volatile timecounter; +u_int32_t tc_getfrequency(void); void tc_init(struct timecounter *tc); void tc_setclock(struct timespec *ts); #endif /* !_KERNEL */ diff --git a/sys/sys/timex.h b/sys/sys/timex.h index 7cdeea00f42..a4379fea3f1 100644 --- a/sys/sys/timex.h +++ b/sys/sys/timex.h @@ -220,8 +220,8 @@ struct timex { #ifdef __FreeBSD__ #ifdef _KERNEL -struct timecounter; -void ntp_update_second(struct timecounter *tc); +struct timehands; +void ntp_update_second(int64_t *adjustment, time_t *newsec); #else /* !_KERNEL */ #include