mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 22:53:28 +00:00
thread: implements available_concurrency on haiku
This commit is contained in:
parent
2b6ed3b675
commit
5d4048b66f
@ -338,8 +338,17 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> {
|
||||
}
|
||||
|
||||
Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) })
|
||||
} else if #[cfg(target_os = "haiku")] {
|
||||
let mut sinfo: libc::system_info = crate::mem::zeroed();
|
||||
let res = libc::get_system_info(&mut sinfo);
|
||||
|
||||
if res != libc::B_OK {
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
|
||||
Ok(unsafe { NonZeroUsize::new_unchecked(sinfo.cpu_count as usize) })
|
||||
} else {
|
||||
// FIXME: implement on vxWorks, Redox, Haiku, l4re
|
||||
// FIXME: implement on vxWorks, Redox, l4re
|
||||
Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform"))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user