From 70b1229f50f3de059681ee120ad4324ff6fb0605 Mon Sep 17 00:00:00 2001 From: pxin Date: Thu, 30 Jul 2020 15:09:00 +0800 Subject: [PATCH 01/10] add os.cpu_count() support for VxWorks RTOS --- .../next/Library/2020-07-30-14-56-58.bpo-41440.rju34k.rst | 1 + Modules/posixmodule.c | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2020-07-30-14-56-58.bpo-41440.rju34k.rst 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 00000000000000..fdccd170fc700b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-07-30-14-56-58.bpo-41440.rju34k.rst @@ -0,0 +1 @@ +Add os.cpu_count() support for VxWorks RTOS. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index efd99544f5a997..9a178fa7d5aad3 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -12607,6 +12607,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 = __builtin_popcount(vxCpuEnabledGet()); #elif defined(__DragonFly__) || \ defined(__OpenBSD__) || \ defined(__FreeBSD__) || \ From 42f7f57277b025fa06e74d80c27ea449979d8ac6 Mon Sep 17 00:00:00 2001 From: pxin Date: Thu, 30 Jul 2020 18:17:41 +0800 Subject: [PATCH 02/10] Rerun the CI From ff3166593c6069c64b13d621ad87eee2c34fb205 Mon Sep 17 00:00:00 2001 From: pxin Date: Fri, 31 Jul 2020 14:00:27 +0800 Subject: [PATCH 03/10] replace __builtin_popcount with _Py_popcount32 --- Modules/posixmodule.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 9a178fa7d5aad3..2bad8a14b8094f 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -32,6 +32,9 @@ # include #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() @@ -12608,7 +12611,7 @@ os_cpu_count_impl(PyObject *module) #elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) ncpu = sysconf(_SC_NPROCESSORS_ONLN); #elif defined(__VXWORKS__) - ncpu = __builtin_popcount(vxCpuEnabledGet()); + ncpu = _Py_popcount32(vxCpuEnabledGet()); #elif defined(__DragonFly__) || \ defined(__OpenBSD__) || \ defined(__FreeBSD__) || \ From 3c85faab72f2de92650569fb9fc92f3c9badfaf2 Mon Sep 17 00:00:00 2001 From: pxin Date: Fri, 31 Jul 2020 15:07:51 +0800 Subject: [PATCH 04/10] rerun the ci From 0f52c97ba19701767ac904f22b405a159e691799 Mon Sep 17 00:00:00 2001 From: pxinwr Date: Fri, 31 Jul 2020 15:44:40 +0800 Subject: [PATCH 05/10] Update Misc/NEWS.d/next/Library/2020-07-30-14-56-58.bpo-41440.rju34k.rst Co-authored-by: Dong-hee Na --- .../next/Library/2020-07-30-14-56-58.bpo-41440.rju34k.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index fdccd170fc700b..3ee1f656d1870c 100644 --- 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 @@ -1 +1 @@ -Add os.cpu_count() support for VxWorks RTOS. +Add :func:`os.cpu_count()` support for VxWorks RTOS. From 88e7ceacb9b4bc22207ec840afcc75408ca8ce5d Mon Sep 17 00:00:00 2001 From: pxin Date: Fri, 31 Jul 2020 15:58:39 +0800 Subject: [PATCH 06/10] update What's New --- Doc/whatsnew/3.10.rst | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 1865fa227534a5..ed77eba2836530 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -154,10 +154,7 @@ Removed Porting to Python 3.10 ====================== -This section lists previously described changes and other bugfixes -that may require changes to your code. - - +* Add :func:`os.cpu_count()` support for VxWorks RTOS. Build Changes ============= From 9249226b8d8d4e00d91f03fa78c4cdfbad494421 Mon Sep 17 00:00:00 2001 From: pxin Date: Sat, 1 Aug 2020 21:33:18 +0800 Subject: [PATCH 07/10] Revert "update What's New" This reverts commit 88e7ceacb9b4bc22207ec840afcc75408ca8ce5d. --- Doc/whatsnew/3.10.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index ed77eba2836530..1865fa227534a5 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -154,7 +154,10 @@ Removed Porting to Python 3.10 ====================== -* Add :func:`os.cpu_count()` support for VxWorks RTOS. +This section lists previously described changes and other bugfixes +that may require changes to your code. + + Build Changes ============= From 3c1c4bcdd7b84573e8dc55698401493dc89307c5 Mon Sep 17 00:00:00 2001 From: pxin Date: Sat, 1 Aug 2020 21:44:34 +0800 Subject: [PATCH 08/10] move changelog in whatsnew --- Doc/whatsnew/3.10.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 1865fa227534a5..43e30c2616975a 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -110,6 +110,11 @@ 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 ---------- From 2fc156847f550c345396d7aca0a368634b7c67a6 Mon Sep 17 00:00:00 2001 From: pxinwr Date: Tue, 4 Aug 2020 10:36:47 +0800 Subject: [PATCH 09/10] Update Modules/posixmodule.c Co-authored-by: Victor Stinner --- Modules/posixmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 2bad8a14b8094f..a6a4b9f012f009 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -33,7 +33,7 @@ #endif #ifdef __VXWORKS__ -#include "pycore_bitutils.h" // _Py_popcount32() +# include "pycore_bitutils.h" // _Py_popcount32() #endif #include "pycore_ceval.h" // _PyEval_ReInitThreads() #include "pycore_import.h" // _PyImport_ReInitLock() From f8766a7f285d35d88ed2631b2ce2f165fa4e0790 Mon Sep 17 00:00:00 2001 From: pxinwr Date: Tue, 4 Aug 2020 10:38:14 +0800 Subject: [PATCH 10/10] Polish Doc/whatsnew/3.10.rst Co-authored-by: Victor Stinner --- Doc/whatsnew/3.10.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 43e30c2616975a..d575e962c82631 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -111,7 +111,8 @@ Added the *root_dir* and *dir_fd* parameters in :func:`~glob.glob` and (Contributed by Serhiy Storchaka in :issue:`38144`.) os ----- +-- + Added :func:`os.cpu_count()` support for VxWorks RTOS. (Contributed by Peixing Xin in :issue:`41440`.)