1 From 8e8a824533643de4a4a221358a8c5ae7d4e9e474 Mon Sep 17 00:00:00 2001
2 From: Ameya Palande <ameya.palande@nokia.com>
3 Date: Wed, 28 Jul 2010 14:41:24 +0300
4 Subject: [PATCH] unknown hz value fix
6 Fixes linux version detection. This relied on a side-effect of the elf loader
7 and previously hoped that constructors would be called in a certain order.
8 That behavior was undefined and hence unreliable. For newer kernels, an elf
9 note is now checked to extract HZ tick count.
11 Original author: <david.sugar@canonical.com>
12 Backported to meego by: Ameya Palande <ameya.palande@nokia.com>
15 proc/version.c | 5 ++---
17 3 files changed, 4 insertions(+), 3 deletions(-)
19 diff --git a/proc/sysinfo.c b/proc/sysinfo.c
20 index 0ad7fba..793829f 100644
23 @@ -212,6 +212,7 @@ static int check_for_privs(void){
24 static void init_libproc(void) __attribute__((constructor));
25 static void init_libproc(void){
26 have_privs = check_for_privs();
27 + init_Linux_version(); // make sure we have version before continuing...
28 // ought to count CPUs in /proc/stat instead of relying
29 // on glibc, which foolishly tries to parse /proc/cpuinfo
31 diff --git a/proc/version.c b/proc/version.c
32 index 391b9bb..2049e15 100644
35 @@ -35,11 +35,10 @@ void display_version(void) {
37 int linux_version_code;
39 -static void init_Linux_version(void) __attribute__((constructor));
40 -static void init_Linux_version(void) {
41 +void init_Linux_version(void) {
42 static struct utsname uts;
43 int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
46 if (uname(&uts) == -1) /* failure implies impending death */
48 if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
49 diff --git a/proc/version.h b/proc/version.h
50 index 492d251..28c9b49 100644
57 +extern void init_Linux_version(void); /* initialize linux version */
58 extern void display_version(void); /* display suite version */
59 extern const char procps_version[]; /* global buf for suite version */
60 extern const char procps_number_version[]; /* global buf for suite number version */