Avoid running HZ initialization twice by using priority for the constructors for excuting before main(). Add test on "Unknown HZ value!" Signed-off-by: Werner Fink <werner@xxxxxxx> diff --git a/proc/sig.c b/proc/sig.c index ea63397..a769a7e 100644 --- a/proc/sig.c +++ b/proc/sig.c @@ -231,7 +231,7 @@ void unix_print_signals(void){ } /* sanity check */ -static int init_signal_list(void) __attribute__((constructor)); +static int init_signal_list(void) __attribute__((constructor (103))); static int init_signal_list(void){ if(number_of_signals != 31){ fprintf(stderr, "WARNING: %d signals -- adjust and recompile.\n", number_of_signals); diff --git a/proc/sysinfo.c b/proc/sysinfo.c index 7ef68c5..876ddbf 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -158,6 +158,14 @@ static void old_Hertz_hack(void){ unsigned long long jiffies; unsigned h; char *restrict savelocale; + long hz; + +#ifdef _SC_CLK_TCK + if((hz = sysconf(_SC_CLK_TCK)) > 0){ + Hertz = hz; + return; + } +#endif savelocale = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); @@ -238,7 +246,7 @@ static int check_for_privs(void){ return !!rc; } -static void init_libproc(void) __attribute__((constructor)); +static void init_libproc(void) __attribute__((constructor (102))); static void init_libproc(void){ have_privs = check_for_privs(); // ought to count CPUs in /proc/stat instead of relying diff --git a/proc/version.c b/proc/version.c index 69bae4f..5e5ff70 100644 --- a/proc/version.c +++ b/proc/version.c @@ -33,7 +33,7 @@ void display_version(void) { int linux_version_code; -static void init_Linux_version(void) __attribute__((constructor)); +static void init_Linux_version(void) __attribute__((constructor (101))); static void init_Linux_version(void) { static struct utsname uts; int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */ -- 1.6.0.2