[Python-checkins] bpo-41440: add os.cpu_count() support for VxWorks RTOS (GH-21685)

pxinwr webhook-mailer at python.org
Fri Aug 7 01:22:01 EDT 2020


https://github.com/python/cpython/commit/3405e0542839cde94df9833b3809710a67a33c7c
commit: 3405e0542839cde94df9833b3809710a67a33c7c
branch: master
author: pxinwr <peixing.xin at windriver.com>
committer: GitHub <noreply at github.com>
date: 2020-08-07T14:21:52+09:00
summary:

bpo-41440: add os.cpu_count() support for VxWorks RTOS (GH-21685)

files:
A Misc/NEWS.d/next/Library/2020-07-30-14-56-58.bpo-41440.rju34k.rst
M Doc/whatsnew/3.10.rst
M Modules/posixmodule.c

diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index ec0343f2ce71e..62bb1438416e6 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -120,6 +120,12 @@ Added the *root_dir* and *dir_fd* parameters in :func:`~glob.glob` and
 :func:`~glob.iglob` which allow to specify the root directory for searching.
 (Contributed by Serhiy Storchaka in :issue:`38144`.)
 
+os
+--
+
+Added :func:`os.cpu_count()` support for VxWorks RTOS.
+(Contributed by Peixing Xin in :issue:`41440`.)
+
 py_compile
 ----------
 
diff --git a/Misc/NEWS.d/next/Library/2020-07-30-14-56-58.bpo-41440.rju34k.rst b/Misc/NEWS.d/next/Library/2020-07-30-14-56-58.bpo-41440.rju34k.rst
new file mode 100644
index 0000000000000..3ee1f656d1870
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-07-30-14-56-58.bpo-41440.rju34k.rst
@@ -0,0 +1 @@
+Add :func:`os.cpu_count()` support for VxWorks RTOS.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index efd99544f5a99..a6a4b9f012f00 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__)   || \



More information about the Python-checkins mailing list