Skip to content

Commit

Permalink
thread: implements available_concurrency on haiku
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Sep 27, 2021
1 parent 2b6ed3b commit 5d4048b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion library/std/src/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}
Expand Down

0 comments on commit 5d4048b

Please sign in to comment.