1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2025-07-02 14:04:15 +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
parent 86c2bef72a
commit 58692a8079

View file

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