summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorpxinwr <peixing.xin@windriver.com>2020-08-07 05:21:52 (GMT)
committerGitHub <noreply@github.com>2020-08-07 05:21:52 (GMT)
commit3405e0542839cde94df9833b3809710a67a33c7c (patch)
tree73a358c9a7e54faac44540d384b85143cda56257 /Modules/posixmodule.c
parentd9323a8c6e07071a59dc4c910661db33236c01b2 (diff)
downloadcpython-3405e0542839cde94df9833b3809710a67a33c7c.zip
cpython-3405e0542839cde94df9833b3809710a67a33c7c.tar.gz
cpython-3405e0542839cde94df9833b3809710a67a33c7c.tar.bz2
bpo-41440: add os.cpu_count() support for VxWorks RTOS (GH-21685)
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index efd9954..a6a4b9f 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -32,6 +32,9 @@
# include <windows.h>
#endif
+#ifdef __VXWORKS__
+# include "pycore_bitutils.h" // _Py_popcount32()
+#endif
#include "pycore_ceval.h" // _PyEval_ReInitThreads()
#include "pycore_import.h" // _PyImport_ReInitLock()
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
@@ -12607,6 +12610,8 @@ os_cpu_count_impl(PyObject *module)
ncpu = mpctl(MPC_GETNUMSPUS, NULL, NULL);
#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
ncpu = sysconf(_SC_NPROCESSORS_ONLN);
+#elif defined(__VXWORKS__)
+ ncpu = _Py_popcount32(vxCpuEnabledGet());
#elif defined(__DragonFly__) || \
defined(__OpenBSD__) || \
defined(__FreeBSD__) || \