mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #17914: Remove OS-X special-case, and use the correct int type.
This commit is contained in:
parent
cc00e01fad
commit
d59087de5b
1 changed files with 6 additions and 9 deletions
|
@ -10324,12 +10324,12 @@ established.");
|
||||||
defined(__FreeBSD__) || \
|
defined(__FreeBSD__) || \
|
||||||
defined(__NetBSD__) || \
|
defined(__NetBSD__) || \
|
||||||
defined(__APPLE__)
|
defined(__APPLE__)
|
||||||
static long
|
static int
|
||||||
_bsd_cpu_count(void)
|
_bsd_cpu_count(void)
|
||||||
{
|
{
|
||||||
long ncpu = 0;
|
int ncpu = 0;
|
||||||
int mib[2];
|
int mib[2];
|
||||||
size_t len = sizeof(int);
|
size_t len = sizeof(ncpu);
|
||||||
|
|
||||||
mib[0] = CTL_HW;
|
mib[0] = CTL_HW;
|
||||||
mib[1] = HW_NCPU;
|
mib[1] = HW_NCPU;
|
||||||
|
@ -10343,7 +10343,7 @@ _bsd_cpu_count(void)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
posix_cpu_count(PyObject *self)
|
posix_cpu_count(PyObject *self)
|
||||||
{
|
{
|
||||||
long ncpu = 0;
|
int ncpu = 0;
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
GetSystemInfo(&sysinfo);
|
GetSystemInfo(&sysinfo);
|
||||||
|
@ -10352,14 +10352,11 @@ posix_cpu_count(PyObject *self)
|
||||||
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(__APPLE__)
|
|
||||||
size_t len = sizeof(int);
|
|
||||||
if (sysctlnametomib("hw.logicalcpu", &ncpu, &len, NULL, 0) != 0)
|
|
||||||
ncpu = _bsd_cpu_count();
|
|
||||||
#elif defined(__DragonFly__) || \
|
#elif defined(__DragonFly__) || \
|
||||||
defined(__OpenBSD__) || \
|
defined(__OpenBSD__) || \
|
||||||
defined(__FreeBSD__) || \
|
defined(__FreeBSD__) || \
|
||||||
defined(__NetBSD__)
|
defined(__NetBSD__) || \
|
||||||
|
defined(__APPLE__)
|
||||||
ncpu = _bsd_cpu_count();
|
ncpu = _bsd_cpu_count();
|
||||||
#endif
|
#endif
|
||||||
if (ncpu >= 1)
|
if (ncpu >= 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue