Skip to content

Commit 2beccb3

Browse files
committed
Merge branch 'bs/online-cpus-bsd'
Update online_cpus() functrion on BSD variants. * bs/online-cpus-bsd: thread-utils.c: detect online CPU count on OpenBSD / NetBSD
2 parents d9a1e51 + 7f1a09d commit 2beccb3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

thread-utils.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ int online_cpus(void)
4646
mib[0] = CTL_HW;
4747
# ifdef HW_AVAILCPU
4848
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
5352
mib[1] = HW_NCPU;
53+
# endif /* HW_AVAILCPU */
5454
len = sizeof(cpucount);
5555
if (!sysctl(mib, 2, &cpucount, &len, NULL, 0))
5656
return cpucount;

0 commit comments

Comments
 (0)