Skip to content

Commit

Permalink
Fix VxWorks available parallelism: Move nonzero::uncheked into unsafe…
Browse files Browse the repository at this point in the history
… block
  • Loading branch information
biabbas committed Aug 8, 2024
1 parent 2495418 commit c21ba97
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,11 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
fn vxCpuEnabledGet() -> libc::cpuset_t;
}

// always fetches a valid bitmask
let set = unsafe { vxCpuEnabledGet() };
Ok(NonZero::new_unchecked(set.count_ones() as usize))
unsafe{
// always fetches a valid bitmask
let set = vxCpuEnabledGet();
Ok(NonZero::new_unchecked(set.count_ones() as usize))
}
} else {
// FIXME: implement on Redox, l4re
Err(io::const_io_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform"))
Expand Down

0 comments on commit c21ba97

Please sign in to comment.