File procps-ng-3.3.8-bnc634071_procstat2.diff of Package procps.16210

--- proc/libprocps.sym
+++ proc/libprocps.sym	2014-05-16 10:01:38.446310070 +0000
@@ -57,6 +57,7 @@ global:
 	signal_name_to_number;
 	signal_number_to_name;
 	smp_num_cpus;
+	__smp_num_cpus;
 	sprint_uptime;
 	strtosig;
 	tty_to_dev;
--- proc/sysinfo.c
+++ proc/sysinfo.c	2013-05-29 11:26:47.797640941 +0000
@@ -37,7 +37,8 @@
 #include <netinet/in.h>  /* htons */
 #endif
 
-long smp_num_cpus;     /* number of CPUs */
+#undef smp_num_cpus
+long smp_num_cpus = -1;     /* number of CPUs */

 #define BAD_OPEN_MESSAGE					\
 "Error: /proc must be mounted\n"				\
@@ -1012,7 +1012,11 @@ out:
 
 ///////////////////////////////////////////////////////////////////////////
 
-void cpuinfo (void) {
+long __smp_num_cpus (void) {
+
+  if (smp_num_cpus != -1)
+    return(smp_num_cpus);
+
   // ought to count CPUs in /proc/stat instead of relying
   // on glibc, which foolishly tries to parse /proc/cpuinfo
   // note: that may have been the case but now /proc/stat
@@ -1024,7 +1029,11 @@ void cpuinfo (void) {
   // _SC_NPROCESSORS_CONF returns 2, resulting in HZ=512
   // _SC_NPROCESSORS_ONLN returns 1, which should work OK
 
-  smp_num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
-  if (smp_num_cpus<1)        /* SPARC glibc is buggy */
-    smp_num_cpus=1;
+  smp_num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+  if (smp_num_cpus<1)        /* SPARC glibc is buggy */
+    smp_num_cpus=1;
+
+  return smp_num_cpus;
 }
+
+void cpuinfo (void) { (void)__smp_num_cpus(); }
--- proc/sysinfo.h
+++ proc/sysinfo.h	2012-06-04 10:04:15.812509959 +0000
@@ -7,7 +7,8 @@
 EXTERN_C_BEGIN
 
 extern unsigned long long Hertz;   /* clock tick frequency */
-extern long smp_num_cpus;          /* number of CPUs */
+extern long __smp_num_cpus(void);  /* number of CPUs */
+#define smp_num_cpus __smp_num_cpus()
 extern int have_privs;             /* boolean, true if setuid or similar */
 
 #if 0
openSUSE Build Service is sponsored by