summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorCharles-Francois Natali <cf.natali@gmail.com>2013-05-20 15:40:32 (GMT)
committerCharles-Francois Natali <cf.natali@gmail.com>2013-05-20 15:40:32 (GMT)
commit7c4f8dacf45b9c327cdd075f5ee17087151c7f3b (patch)
treeda49de2a6c4d9a26c572a385999c0c33de85cf23 /Modules/posixmodule.c
parentd59087de5bb115575ff80996879c64f830fc8b86 (diff)
downloadcpython-7c4f8dacf45b9c327cdd075f5ee17087151c7f3b.zip
cpython-7c4f8dacf45b9c327cdd075f5ee17087151c7f3b.tar.gz
cpython-7c4f8dacf45b9c327cdd075f5ee17087151c7f3b.tar.bz2
Issue #17914: We can now inline _bsd_cpu_count().
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 9455f85..5772854 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -10319,27 +10319,6 @@ PyDoc_STRVAR(posix_cpu_count__doc__,
Return the number of CPUs in the system, or None if this value cannot be\n\
established.");
-#if defined(__DragonFly__) || \
- defined(__OpenBSD__) || \
- defined(__FreeBSD__) || \
- defined(__NetBSD__) || \
- defined(__APPLE__)
-static int
-_bsd_cpu_count(void)
-{
- int ncpu = 0;
- int mib[2];
- size_t len = sizeof(ncpu);
-
- mib[0] = CTL_HW;
- mib[1] = HW_NCPU;
- if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == 0)
- return ncpu;
- else
- return 0;
-}
-#endif
-
static PyObject *
posix_cpu_count(PyObject *self)
{
@@ -10357,7 +10336,12 @@ posix_cpu_count(PyObject *self)
defined(__FreeBSD__) || \
defined(__NetBSD__) || \
defined(__APPLE__)
- ncpu = _bsd_cpu_count();
+ int mib[2];
+ size_t len = sizeof(ncpu);
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+ if (sysctl(mib, 2, &ncpu, &len, NULL, 0) != 0)
+ ncpu = 0;
#endif
if (ncpu >= 1)
return PyLong_FromLong(ncpu);