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:
parent
86c2bef72a
commit
58692a8079
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)
|
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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue