[rtems-source-builder commit] sb: Use multiprocessing.cpu_count()

Sebastian Huber sebh at rtems.org
Thu Mar 5 10:00:00 UTC 2020


Module:    rtems-source-builder
Branch:    master
Commit:    e0394a5c709ede13420dca0ea95b39157847c94c
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=e0394a5c709ede13420dca0ea95b39157847c94c

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Mar  5 10:36:08 2020 +0100

sb: Use multiprocessing.cpu_count()

The previous implementation does not work on some Linux distributions,
e.g. Debian on sparc64.  Use a standard function instead.

---

 source-builder/sb/linux.py | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/source-builder/sb/linux.py b/source-builder/sb/linux.py
index 43a6d1d..c3059a9 100644
--- a/source-builder/sb/linux.py
+++ b/source-builder/sb/linux.py
@@ -22,29 +22,15 @@
 # RTEMS project's spec files.
 #
 
+import multiprocessing
 import pprint
 import os
 
 import platform
-import execute
 import path
 
 def load():
     uname = os.uname()
-    smp_mflags = ''
-    processors = '/bin/grep processor /proc/cpuinfo'
-    e = execute.capture_execution()
-    exit_code, proc, output = e.shell(processors)
-    ncpus = 0
-    if exit_code == 0:
-        try:
-            for l in output.split('\n'):
-                count = l.split(':')[1].strip()
-                if int(count) > ncpus:
-                    ncpus = int(count)
-        except:
-            pass
-    ncpus = str(ncpus + 1)
     if uname[4].startswith('arm'):
         cpu = 'arm'
     else:
@@ -52,7 +38,7 @@ def load():
 
     version = uname[2]
     defines = {
-        '_ncpus':           ('none',    'none',     ncpus),
+        '_ncpus':           ('none',    'none',     str(multiprocessing.cpu_count())),
         '_os':              ('none',    'none',     'linux'),
         '_host':            ('triplet', 'required', cpu + '-linux-gnu'),
         '_host_vendor':     ('none',    'none',     'gnu'),



More information about the vc mailing list