sys: remove shift_hz

It's not used for anything since commit e147f2f1.
This commit is contained in:
Miroslav Lichvar 2014-12-09 17:58:42 +01:00
parent eadabfe890
commit c4d57f0e3d

View file

@ -212,16 +212,14 @@ set_sync_status(int synchronised, double est_error, double max_error)
* Also, the bounds checking inside the kernel's adjtimex system call enforces * Also, the bounds checking inside the kernel's adjtimex system call enforces
* a +/- 10% movement of tick away from the nominal value 1e6/USER_HZ. */ * a +/- 10% movement of tick away from the nominal value 1e6/USER_HZ. */
static void static int
guess_hz_and_shift_hz(int tick, int *hz, int *shift_hz) guess_hz(int tick)
{ {
int i, tick_lo, tick_hi, ihz; int i, tick_lo, tick_hi, ihz;
double tick_nominal; double tick_nominal;
/* Pick off the hz=100 case first */ /* Pick off the hz=100 case first */
if (tick >= 9000 && tick <= 11000) { if (tick >= 9000 && tick <= 11000) {
*hz = 100; return 100;
*shift_hz = 7;
return;
} }
for (i=4; i<16; i++) { /* surely 16 .. 32768 is a wide enough range? */ for (i=4; i<16; i++) { /* surely 16 .. 32768 is a wide enough range? */
@ -231,36 +229,26 @@ guess_hz_and_shift_hz(int tick, int *hz, int *shift_hz)
tick_hi = (int)(0.5 + tick_nominal*4.0/3.0); tick_hi = (int)(0.5 + tick_nominal*4.0/3.0);
if (tick_lo < tick && tick <= tick_hi) { if (tick_lo < tick && tick <= tick_hi) {
*hz = ihz; return ihz;
*shift_hz = i;
return;
} }
} }
/* oh dear. doomed. */ /* oh dear. doomed. */
*hz = 0; return 0;
*shift_hz = 0;
} }
/* ================================================== */ /* ================================================== */
static int static int
get_hz_and_shift_hz(int *hz, int *shift_hz) get_hz(void)
{ {
#ifdef _SC_CLK_TCK #ifdef _SC_CLK_TCK
if ((*hz = sysconf(_SC_CLK_TCK)) < 1) { int hz;
if ((hz = sysconf(_SC_CLK_TCK)) < 1)
return 0; return 0;
}
if (*hz == 100) { return hz;
*shift_hz = 7;
return 1;
}
for (*shift_hz = 1; (*hz >> *shift_hz) > 1; (*shift_hz)++)
;
return 1;
#else #else
return 0; return 0;
#endif #endif
@ -287,20 +275,20 @@ static void
get_version_specific_details(void) get_version_specific_details(void)
{ {
int major, minor, patch; int major, minor, patch;
int shift_hz;
long tick; long tick;
double freq; double freq;
struct utsname uts; struct utsname uts;
if (!get_hz_and_shift_hz(&hz, &shift_hz)) { hz = get_hz();
if (!hz) {
if (TMX_GetFrequency(&freq, &tick) < 0) if (TMX_GetFrequency(&freq, &tick) < 0)
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed"); LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
guess_hz_and_shift_hz(tick, &hz, &shift_hz); hz = guess_hz(tick);
if (!shift_hz) { if (!hz)
LOG_FATAL(LOGF_SysLinux, "Can't determine hz from tick %ld", tick); LOG_FATAL(LOGF_SysLinux, "Can't determine hz from tick %ld", tick);
}
} }
dhz = (double) hz; dhz = (double) hz;