Ticket #414: 121

File 121, 1.4 KB (added by dlove, 9 years ago)
Line 
1--- daemons/common/procfs.c.orig        2006-03-10 07:03:19.000000000 +0100
2+++ daemons/common/procfs.c     2007-09-25 16:56:42.000000000 +0200
3@@ -69,6 +69,11 @@
4 #  include <sys/procfs.h>   
5 #endif
6 
7+/*
8+ * HZ now no longer visible in userspace
9+ * should use sysconf(_SC_CLK_TCK) instead (from <unistd.h>)
10+ * olesen 2007-09-25
11+ */
12 #if defined(LINUX)
13 #include <sys/param.h>          /* for HZ (jiffies -> seconds ) */
14 #endif
15@@ -740,9 +745,14 @@
16       {
17          double utime, stime;
18 #if defined(LINUX)
19+# ifdef HZ
20          utime = ((double)pr.pr_utime)/HZ;
21          stime = ((double)pr.pr_stime)/HZ;
22 #else
23+         utime = ((double)pr.pr_utime)/sysconf(_SC_CLK_TCK);
24+         stime = ((double)pr.pr_stime)/sysconf(_SC_CLK_TCK);
25+# endif
26+#else
27          utime = pr.pr_utime.tv_sec + pr.pr_utime.tv_nsec*1E-9;
28          stime = pr.pr_stime.tv_sec + pr.pr_stime.tv_nsec*1E-9;
29 #endif
30@@ -761,8 +771,13 @@
31 
32    proc_elem->proc.pd_pid    = pr.pr_pid;
33 #if defined(LINUX)
34+# ifdef HZ
35    proc_elem->proc.pd_utime  = ((double)pr.pr_utime)/HZ;
36    proc_elem->proc.pd_stime  = ((double)pr.pr_stime)/HZ;
37+# else
38+   proc_elem->proc.pd_utime  = ((double)pr.pr_utime)/sysconf(_SC_CLK_TCK);
39+   proc_elem->proc.pd_stime  = ((double)pr.pr_stime)/sysconf(_SC_CLK_TCK);
40+# endif
41    /* could retrieve uid/gid using stat() on stat file */
42    proc_elem->vmem           = pr.pr_vsize;
43 #else