mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
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.
This commit is contained in:
parent
08da44903f
commit
e0394a5c70
@ -22,29 +22,15 @@
|
|||||||
# RTEMS project's spec files.
|
# RTEMS project's spec files.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import multiprocessing
|
||||||
import pprint
|
import pprint
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
import execute
|
|
||||||
import path
|
import path
|
||||||
|
|
||||||
def load():
|
def load():
|
||||||
uname = os.uname()
|
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'):
|
if uname[4].startswith('arm'):
|
||||||
cpu = 'arm'
|
cpu = 'arm'
|
||||||
else:
|
else:
|
||||||
@ -52,7 +38,7 @@ def load():
|
|||||||
|
|
||||||
version = uname[2]
|
version = uname[2]
|
||||||
defines = {
|
defines = {
|
||||||
'_ncpus': ('none', 'none', ncpus),
|
'_ncpus': ('none', 'none', str(multiprocessing.cpu_count())),
|
||||||
'_os': ('none', 'none', 'linux'),
|
'_os': ('none', 'none', 'linux'),
|
||||||
'_host': ('triplet', 'required', cpu + '-linux-gnu'),
|
'_host': ('triplet', 'required', cpu + '-linux-gnu'),
|
||||||
'_host_vendor': ('none', 'none', 'gnu'),
|
'_host_vendor': ('none', 'none', 'gnu'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user