Updated with Tizen:Base source codes
[external/procps.git] / packaging / unknown-hz-value-fix.patch
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
5
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.
10
11 Original author: <david.sugar@canonical.com>
12 Backported to meego by: Ameya Palande <ameya.palande@nokia.com>
13 ---
14  proc/sysinfo.c |    1 +
15  proc/version.c |    5 ++---
16  proc/version.h |    1 +
17  3 files changed, 4 insertions(+), 3 deletions(-)
18
19 diff --git a/proc/sysinfo.c b/proc/sysinfo.c
20 index 0ad7fba..793829f 100644
21 --- a/proc/sysinfo.c
22 +++ b/proc/sysinfo.c
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
30    //
31 diff --git a/proc/version.c b/proc/version.c
32 index 391b9bb..2049e15 100644
33 --- a/proc/version.c
34 +++ b/proc/version.c
35 @@ -35,11 +35,10 @@ void display_version(void) {
36  
37  int linux_version_code;
38  
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 */
44 -    
45 +
46      if (uname(&uts) == -1)     /* failure implies impending death */
47         exit(1);
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
51 --- a/proc/version.h
52 +++ b/proc/version.h
53 @@ -14,6 +14,7 @@
54  
55  EXTERN_C_BEGIN
56  
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 */
61 -- 
62 1.7.0.4
63