File: 08_procinfo_simplify_counting_CPUs.dpatch

package info (click to toggle)
procinfo 18-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 188 kB
  • ctags: 134
  • sloc: ansic: 1,226; sh: 419; perl: 81; makefile: 68
file content (31 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /bin/sh /usr/share/dpatch/dpatch-run
## 48_procinfo_simplify_counting_CPUs.dpatch by Florian Ernst <florian@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Simplify counting the CPUs, see bug#174645

@DPATCH@
diff -urNad procinfo-18~/procinfo.c procinfo-18/procinfo.c
--- procinfo-18~/procinfo.c	2005-11-22 15:40:52.000000000 +0100
+++ procinfo-18/procinfo.c	2005-11-22 15:41:49.000000000 +0100
@@ -947,19 +947,7 @@
     }
 
     /* Count number of CPUs */
-    cpuinfofp = myfopen (PROC_DIR "cpuinfo");
-    if (cpuinfofp) {
-	while (fgets (line, sizeof (line), cpuinfofp))
-	    if (!strncmp ("processor", line, 9))          /* intel */
-		nr_cpus++;
-	    else if (!strncmp ("ncpus ", line, 6))  /* sparc */
-		nr_cpus = atoi(line+19);
-	    else if (!strncmp ("cpus detected", line, 13)) /* alpha */
-		nr_cpus = atoi(line+27);
-	fclose (cpuinfofp);
-    }
-    if (nr_cpus == 0)
-	nr_cpus = 1;
+    nr_cpus = sysconf (_SC_NPROCESSORS_ONLN);
 
     /* Gets called from winsz(), but in case stdout is redirected: */
     version = make_version (versionfp);