thread-utils.c: detect online CPU count on OpenBSD / NetBSD
OpenBSD / NetBSD use HW_NCPUONLINE to detect the online CPU count. OpenBSD ships with SMT disabled on X86 systems so HW_NCPU would provide double the number of CPUs as opposed to the proper online count. Signed-off-by: Brad Smith <brad@comstyle.com> Reviewed-by: Collin Funk <collin.funk1@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
d50a5e8939
commit
7f1a09dbb6
@@ -46,11 +46,11 @@ int online_cpus(void)
|
|||||||
mib[0] = CTL_HW;
|
mib[0] = CTL_HW;
|
||||||
# ifdef HW_AVAILCPU
|
# ifdef HW_AVAILCPU
|
||||||
mib[1] = HW_AVAILCPU;
|
mib[1] = HW_AVAILCPU;
|
||||||
len = sizeof(cpucount);
|
# elif defined(HW_NCPUONLINE)
|
||||||
if (!sysctl(mib, 2, &cpucount, &len, NULL, 0))
|
mib[1] = HW_NCPUONLINE;
|
||||||
return cpucount;
|
# else
|
||||||
# endif /* HW_AVAILCPU */
|
|
||||||
mib[1] = HW_NCPU;
|
mib[1] = HW_NCPU;
|
||||||
|
# endif /* HW_AVAILCPU */
|
||||||
len = sizeof(cpucount);
|
len = sizeof(cpucount);
|
||||||
if (!sysctl(mib, 2, &cpucount, &len, NULL, 0))
|
if (!sysctl(mib, 2, &cpucount, &len, NULL, 0))
|
||||||
return cpucount;
|
return cpucount;
|
||||||
|
|||||||
Reference in New Issue
Block a user