procps/procps-ng-3.3.10-bnc634071_procstat2.diff

62 lines
1.8 KiB
Diff

---
proc/libprocps.sym | 1 +
proc/sysinfo.c | 13 +++++++++++--
proc/sysinfo.h | 2 ++
3 files changed, 14 insertions(+), 2 deletions(-)
--- proc/libprocps.sym
+++ proc/libprocps.sym 2018-04-04 11:30:51.841725161 +0000
@@ -60,6 +60,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 2018-04-04 11:33:26.306886237 +0000
@@ -47,7 +47,8 @@
#endif
#include <elf.h>
-long smp_num_cpus; /* number of CPUs */
+#undef smp_num_cpus
+long smp_num_cpus=-1; /* number of CPUs */
long page_bytes; /* this architecture's page size */
#define BAD_OPEN_MESSAGE \
@@ -1166,7 +1167,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
@@ -1181,4 +1186,8 @@ void cpuinfo (void) {
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 2018-04-04 11:30:51.841725161 +0000
@@ -8,6 +8,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);
+#define smp_num_cpus __smp_num_cpus()
extern int have_privs; /* boolean, true if setuid or similar */
extern long page_bytes; /* this architecture's bytes per page */