Skip to content

Commit 5d4048b

Browse files
committed
thread: implements available_concurrency on haiku
1 parent 2b6ed3b commit 5d4048b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

library/std/src/sys/unix/thread.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,17 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> {
338338
}
339339

340340
Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) })
341+
} else if #[cfg(target_os = "haiku")] {
342+
let mut sinfo: libc::system_info = crate::mem::zeroed();
343+
let res = libc::get_system_info(&mut sinfo);
344+
345+
if res != libc::B_OK {
346+
return Err(io::Error::last_os_error());
347+
}
348+
349+
Ok(unsafe { NonZeroUsize::new_unchecked(sinfo.cpu_count as usize) })
341350
} else {
342-
// FIXME: implement on vxWorks, Redox, Haiku, l4re
351+
// FIXME: implement on vxWorks, Redox, l4re
343352
Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform"))
344353
}
345354
}

0 commit comments

Comments
 (0)