summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Görig <jgorig@redhat.com>2011-01-19 12:50:26 +0100
committerJan Görig <jgorig@redhat.com>2011-01-19 12:50:26 +0100
commit8fde4af11d06b6af7fc52974a63464c9d9c13695 (patch)
tree00c16ca9a085683d947852850584cdefe86655de
parent4736dad559f2ab0f1caa8231de7d766f4ada029d (diff)
downloadprocps-ng-8fde4af11d06b6af7fc52974a63464c9d9c13695.tar.gz
Call libproc constructors in strict order
Having one constructor depend on another means if the order is reversed you get a different result. Patched based on idea by Tom Evans. Added new code to old_Hertz_hack by Werner Fink <werner@suse.de> Bug-Debian: http://bugs.debian.org/460331 Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=632236 Reviewed-by: Jan Görig <jgorig@redhat.com>
-rw-r--r--proc/sysinfo.c9
-rw-r--r--proc/version.c3
-rw-r--r--proc/version.h1
3 files changed, 11 insertions, 2 deletions
diff --git a/proc/sysinfo.c b/proc/sysinfo.c
index 7ef68c5..34f70ec 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");
@@ -241,6 +249,7 @@ static int check_for_privs(void){
static void init_libproc(void) __attribute__((constructor));
static void init_libproc(void){
have_privs = check_for_privs();
+ init_Linux_version(); /* Must be called before we check code */
// ought to count CPUs in /proc/stat instead of relying
// on glibc, which foolishly tries to parse /proc/cpuinfo
//
diff --git a/proc/version.c b/proc/version.c
index 69bae4f..0c3a48f 100644
--- a/proc/version.c
+++ b/proc/version.c
@@ -33,8 +33,7 @@ void display_version(void) {
int linux_version_code;
-static void init_Linux_version(void) __attribute__((constructor));
-static void init_Linux_version(void) {
+void init_Linux_version(void) {
static struct utsname uts;
int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
diff --git a/proc/version.h b/proc/version.h
index 3769b84..04a75e9 100644
--- a/proc/version.h
+++ b/proc/version.h
@@ -14,6 +14,7 @@
EXTERN_C_BEGIN
+void init_Linux_version(void); /* Get Linux version */
extern void display_version(void); /* display suite version */
extern const char procps_version[]; /* global buf for suite version */