From 5daa40454b63c4eb04ab5caeb339eddc95c94bb1 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Thu, 20 Oct 2022 20:22:50 +0300 Subject: tuklib_cpucores: Use HW_NCPUONLINE on OpenBSD. On OpenBSD the number of cores online is often less than what HW_NCPU would return because OpenBSD disables simultaneous multi-threading (SMT) by default. Thanks to Christian Weisgerber. --- m4/tuklib_cpucores.m4 | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'm4/tuklib_cpucores.m4') diff --git a/m4/tuklib_cpucores.m4 b/m4/tuklib_cpucores.m4 index a2b09a72..c5cee23e 100644 --- a/m4/tuklib_cpucores.m4 +++ b/m4/tuklib_cpucores.m4 @@ -103,7 +103,12 @@ compile error int main(void) { +#ifdef HW_NCPUONLINE + /* This is preferred on OpenBSD, see tuklib_cpucores.c. */ + int name[2] = { CTL_HW, HW_NCPUONLINE }; +#else int name[2] = { CTL_HW, HW_NCPU }; +#endif int cpus; size_t cpus_size = sizeof(cpus); sysctl(name, 2, &cpus, &cpus_size, NULL, 0); -- cgit v1.2.3