Determine hz and shift from sysconf(_SC_CLK_TCK) when available
This commit is contained in:
parent
9fd8f76fa0
commit
eca08a281c
1 changed files with 35 additions and 9 deletions
26
sys_linux.c
26
sys_linux.c
|
@ -872,6 +872,30 @@ guess_hz_and_shift_hz(int tick, int *hz, int *shift_hz)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
static int
|
||||
get_hz_and_shift_hz(int *hz, int *shift_hz)
|
||||
{
|
||||
#ifdef _SC_CLK_TCK
|
||||
if ((*hz = sysconf(_SC_CLK_TCK)) < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*hz == 100) {
|
||||
*shift_hz = 7;
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (*shift_hz = 1; (*hz >> *shift_hz) > 1; (*shift_hz)++)
|
||||
;
|
||||
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static int
|
||||
kernelvercmp(int major1, int minor1, int patch1,
|
||||
int major2, int minor2, int patch2)
|
||||
|
@ -900,6 +924,7 @@ get_version_specific_details(void)
|
|||
struct tmx_params tmx_params;
|
||||
struct utsname uts;
|
||||
|
||||
if (!get_hz_and_shift_hz(&hz, &shift_hz)) {
|
||||
TMX_ReadCurrentParams(&tmx_params);
|
||||
|
||||
guess_hz_and_shift_hz(tmx_params.tick, &hz, &shift_hz);
|
||||
|
@ -913,6 +938,7 @@ get_version_specific_details(void)
|
|||
tmx_params.tick, tmx_params.freq, tmx_params.dfreq, tmx_params.offset, hz, shift_hz);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
CNF_GetLinuxHz(&set_config_hz, &config_hz);
|
||||
if (set_config_hz) hz = config_hz;
|
||||
|
|
Loading…
Reference in a new issue