1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2025-06-07 00:51:40 +00:00

Use HW_NCPUONLINE for get_total_cpus on OpenBSD and NetBSD

This commit is contained in:
Brad Smith 2025-04-17 14:35:48 -04:00 committed by The Tumultuous Unicorn Of Darkness
parent 86c2bef72a
commit 4fe46c89d2

View file

@ -290,7 +290,11 @@ static bool set_cpu_affinity(logical_cpu_t logical_cpu)
static int get_total_cpus(void)
{
#ifdef HW_NCPUONLINE
int mib[2] = { CTL_HW, HW_NCPUONLINE };
#else
int mib[2] = { CTL_HW, HW_NCPU };
#endif
int ncpus;
size_t len = sizeof(ncpus);
if (sysctl(mib, 2, &ncpus, &len, (void *) 0, 0) != 0) return 1;