Add/Fix OpenBSD native_cpus (#2387)

* Add OpenBSD `native_cpus`

* update release notes

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
Zack Puhl
2025-08-11 17:10:09 -04:00
committed by GitHub
parent be98a01ed8
commit b73a44ec7d
4 changed files with 65 additions and 3 deletions

View File

@@ -50,6 +50,21 @@ fn uint native_cpu()
return count;
}
module std::thread::cpu @if(env::OPENBSD);
import std::os::openbsd;
import libc;
fn uint native_cpu()
{
uint ncpu;
usz len = uint.sizeof;
int[2] mib = { openbsd::CTL_HW, openbsd::HW_NCPU };
libc::sysctl(&mib, 2, &ncpu, &len, null, 0);
return max(1, ncpu);
}
module std::thread::cpu @if(env::LINUX);
import libc;
@@ -66,4 +81,4 @@ fn uint native_cpu()
SystemInfo info;
libc::get_system_info(&info);
return info.dwNumberOfProcessors;
}
}