summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorCharles-Francois Natali <cf.natali@gmail.com>2013-05-20 15:31:06 (GMT)
committerCharles-Francois Natali <cf.natali@gmail.com>2013-05-20 15:31:06 (GMT)
commitd59087de5bb115575ff80996879c64f830fc8b86 (patch)
tree514cf2e978c00bfa00ad2a24232f82b672206293 /Modules/posixmodule.c
parentcc00e01fadd8bcdf56ce7f6fe666cf91b97e435b (diff)
downloadcpython-d59087de5bb115575ff80996879c64f830fc8b86.zip
cpython-d59087de5bb115575ff80996879c64f830fc8b86.tar.gz
cpython-d59087de5bb115575ff80996879c64f830fc8b86.tar.bz2
Issue #17914: Remove OS-X special-case, and use the correct int type.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index c24e162..9455f85 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -10324,12 +10324,12 @@ established.");
defined(__FreeBSD__) || \
defined(__NetBSD__) || \
defined(__APPLE__)
-static long
+static int
_bsd_cpu_count(void)
{
- long ncpu = 0;
+ int ncpu = 0;
int mib[2];
- size_t len = sizeof(int);
+ size_t len = sizeof(ncpu);
mib[0] = CTL_HW;
mib[1] = HW_NCPU;
@@ -10343,7 +10343,7 @@ _bsd_cpu_count(void)
static PyObject *
posix_cpu_count(PyObject *self)
{
- long ncpu = 0;
+ int ncpu = 0;
#ifdef MS_WINDOWS
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
@@ -10352,14 +10352,11 @@ posix_cpu_count(PyObject *self)
ncpu = mpctl(MPC_GETNUMSPUS, NULL, NULL);
#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
ncpu = sysconf(_SC_NPROCESSORS_ONLN);
-#elif defined(__APPLE__)
- size_t len = sizeof(int);
- if (sysctlnametomib("hw.logicalcpu", &ncpu, &len, NULL, 0) != 0)
- ncpu = _bsd_cpu_count();
#elif defined(__DragonFly__) || \
defined(__OpenBSD__) || \
defined(__FreeBSD__) || \
- defined(__NetBSD__)
+ defined(__NetBSD__) || \
+ defined(__APPLE__)
ncpu = _bsd_cpu_count();
#endif
if (ncpu >= 1)