Git fork

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>

authored by

Brad Smith and committed by
Junio C Hamano
7f1a09db d50a5e89

+4 -4
+4 -4
thread-utils.c
··· 46 46 mib[0] = CTL_HW; 47 47 # ifdef HW_AVAILCPU 48 48 mib[1] = HW_AVAILCPU; 49 - len = sizeof(cpucount); 50 - if (!sysctl(mib, 2, &cpucount, &len, NULL, 0)) 51 - return cpucount; 52 - # endif /* HW_AVAILCPU */ 49 + # elif defined(HW_NCPUONLINE) 50 + mib[1] = HW_NCPUONLINE; 51 + # else 53 52 mib[1] = HW_NCPU; 53 + # endif /* HW_AVAILCPU */ 54 54 len = sizeof(cpucount); 55 55 if (!sysctl(mib, 2, &cpucount, &len, NULL, 0)) 56 56 return cpucount;