mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user