1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

bde made a number of suggested improvements to the code. This commit

represents the pruely stylistic changes and should have no net impact
on the rest of the code.

bde's more substantive changes will follow in a separate commit once
we've come to closure on them.

Submitted by: bde
This commit is contained in:
Warner Losh 2003-08-20 19:12:46 +00:00
parent 1c35e213f1
commit c1cccd1ea6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=119183

View File

@ -21,10 +21,10 @@ __FBSDID("$FreeBSD$");
#include <sys/timex.h> #include <sys/timex.h>
/* /*
* a large step happens on boot. This constant detects such * A large step happens on boot. This constant detects such steps.
* a steps. It is relatively small so that ntp_update_second gets called * It is relatively small so that ntp_update_second gets called enough
* enough in the typical 'missed a couple of seconds' case, but doesn't * in the typical 'missed a couple of seconds' case, but doesn't loop
* loop forever when the time step is large. * forever when the time step is large.
*/ */
#define LARGE_STEP 200 #define LARGE_STEP 200
@ -321,7 +321,7 @@ tc_getfrequency(void)
/* /*
* Step our concept of UTC. This is done by modifying our estimate of * Step our concept of UTC. This is done by modifying our estimate of
* when we booted. XXX: needs futher work. * when we booted. XXX: needs further work.
*/ */
void void
tc_setclock(struct timespec *ts) tc_setclock(struct timespec *ts)
@ -395,20 +395,16 @@ tc_windup(void)
tho->th_counter->tc_poll_pps(tho->th_counter); tho->th_counter->tc_poll_pps(tho->th_counter);
/* /*
* Compute the UTC time, before any leapsecond adjustments, are * Deal with NTP second processing. The for loop normally
* made. * iterates at most once, but in extreme situations it might
* keep NTP sane if timeouts are not run for several seconds.
* At boot, the time step can be large when the TOD hardware
* has been read, so on really large steps, we call
* ntp_update_second only twice. We need to call it twice in
* case we missed a leap second.
*/ */
bt = th->th_offset; bt = th->th_offset;
bintime_add(&bt, &boottimebin); bintime_add(&bt, &boottimebin);
/*
* Deal with NTP second processing. The for loop normally only
* iterates once, but in extreme situations it might keep NTP sane
* if timeouts are not run for several seconds. At boot, the
* time step can be large when the TOD hardware has been read, so
* on really large steps, we call ntp_update_second only twice.
* We need to call it twice in case we missed a leap second.
*/
i = bt.sec - tho->th_microtime.tv_sec; i = bt.sec - tho->th_microtime.tv_sec;
if (i > LARGE_STEP) if (i > LARGE_STEP)
i = 2; i = 2;
@ -418,6 +414,10 @@ tc_windup(void)
if (bt.sec != t) if (bt.sec != t)
boottimebin.sec += bt.sec - t; boottimebin.sec += bt.sec - t;
} }
/* Update the UTC timestamps used by the get*() functions. */
/* XXX shouldn't do this here. Should force non-`get' versions. */
bintime2timeval(&bt, &th->th_microtime);
bintime2timespec(&bt, &th->th_nanotime);
/* Now is a good time to change timecounters. */ /* Now is a good time to change timecounters. */
if (th->th_counter != timecounter) { if (th->th_counter != timecounter) {
@ -453,9 +453,6 @@ tc_windup(void)
scale /= th->th_counter->tc_frequency; scale /= th->th_counter->tc_frequency;
th->th_scale = scale * 2; th->th_scale = scale * 2;
bintime2timeval(&bt, &th->th_microtime);
bintime2timespec(&bt, &th->th_nanotime);
/* /*
* Now that the struct timehands is again consistent, set the new * Now that the struct timehands is again consistent, set the new
* generation number, making sure to not make it zero. * generation number, making sure to not make it zero.