Skip to content

Commit 3405e05

Browse files
authored
bpo-41440: add os.cpu_count() support for VxWorks RTOS (GH-21685)
1 parent d9323a8 commit 3405e05

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

Doc/whatsnew/3.10.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ Added the *root_dir* and *dir_fd* parameters in :func:`~glob.glob` and
120120
:func:`~glob.iglob` which allow to specify the root directory for searching.
121121
(Contributed by Serhiy Storchaka in :issue:`38144`.)
122122

123+
os
124+
--
125+
126+
Added :func:`os.cpu_count()` support for VxWorks RTOS.
127+
(Contributed by Peixing Xin in :issue:`41440`.)
128+
123129
py_compile
124130
----------
125131

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add :func:`os.cpu_count()` support for VxWorks RTOS.

Modules/posixmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
# include <windows.h>
3333
#endif
3434

35+
#ifdef __VXWORKS__
36+
# include "pycore_bitutils.h" // _Py_popcount32()
37+
#endif
3538
#include "pycore_ceval.h" // _PyEval_ReInitThreads()
3639
#include "pycore_import.h" // _PyImport_ReInitLock()
3740
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
@@ -12607,6 +12610,8 @@ os_cpu_count_impl(PyObject *module)
1260712610
ncpu = mpctl(MPC_GETNUMSPUS, NULL, NULL);
1260812611
#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
1260912612
ncpu = sysconf(_SC_NPROCESSORS_ONLN);
12613+
#elif defined(__VXWORKS__)
12614+
ncpu = _Py_popcount32(vxCpuEnabledGet());
1261012615
#elif defined(__DragonFly__) || \
1261112616
defined(__OpenBSD__) || \
1261212617
defined(__FreeBSD__) || \

0 commit comments

Comments
 (0)