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:
parent
86c2bef72a
commit
4fe46c89d2
1 changed files with 4 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue