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

This commit is contained in:
pxinwr 2020-08-07 13:21:52 +08:00 committed by GitHub
parent d9323a8c6e
commit 3405e05428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -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. :func:`~glob.iglob` which allow to specify the root directory for searching.
(Contributed by Serhiy Storchaka in :issue:`38144`.) (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 py_compile
---------- ----------

View File

@ -0,0 +1 @@
Add :func:`os.cpu_count()` support for VxWorks RTOS.

View File

@ -32,6 +32,9 @@
# include <windows.h> # include <windows.h>
#endif #endif
#ifdef __VXWORKS__
# include "pycore_bitutils.h" // _Py_popcount32()
#endif
#include "pycore_ceval.h" // _PyEval_ReInitThreads() #include "pycore_ceval.h" // _PyEval_ReInitThreads()
#include "pycore_import.h" // _PyImport_ReInitLock() #include "pycore_import.h" // _PyImport_ReInitLock()
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION() #include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
@ -12607,6 +12610,8 @@ os_cpu_count_impl(PyObject *module)
ncpu = mpctl(MPC_GETNUMSPUS, NULL, NULL); ncpu = mpctl(MPC_GETNUMSPUS, NULL, NULL);
#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) #elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
ncpu = sysconf(_SC_NPROCESSORS_ONLN); ncpu = sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(__VXWORKS__)
ncpu = _Py_popcount32(vxCpuEnabledGet());
#elif defined(__DragonFly__) || \ #elif defined(__DragonFly__) || \
defined(__OpenBSD__) || \ defined(__OpenBSD__) || \
defined(__FreeBSD__) || \ defined(__FreeBSD__) || \