Rollup merge of #89462 - devnexen:haiku_thread_aff_build_fix, r=nagisa
haiku thread affinity build fix
This commit is contained in:
commit
a23d7f01d3
1 changed files with 10 additions and 6 deletions
|
@ -339,14 +339,18 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> {
|
||||||
|
|
||||||
Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) })
|
Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) })
|
||||||
} else if #[cfg(target_os = "haiku")] {
|
} else if #[cfg(target_os = "haiku")] {
|
||||||
let mut sinfo: libc::system_info = crate::mem::zeroed();
|
// system_info cpu_count field gets the static data set at boot time with `smp_set_num_cpus`
|
||||||
let res = libc::get_system_info(&mut sinfo);
|
// `get_system_info` calls then `smp_get_num_cpus`
|
||||||
|
unsafe {
|
||||||
|
let mut sinfo: libc::system_info = crate::mem::zeroed();
|
||||||
|
let res = libc::get_system_info(&mut sinfo);
|
||||||
|
|
||||||
if res != libc::B_OK {
|
if res != libc::B_OK {
|
||||||
return Err(io::Error::last_os_error());
|
return Err(io::Error::new_const(io::ErrorKind::NotFound, &"The number of hardware threads is not known for the target platform"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(NonZeroUsize::new_unchecked(sinfo.cpu_count as usize))
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(unsafe { NonZeroUsize::new_unchecked(sinfo.cpu_count as usize) })
|
|
||||||
} else {
|
} else {
|
||||||
// FIXME: implement on vxWorks, Redox, 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"))
|
Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue