Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fb1dac2

Browse files
committedAug 8, 2024
Fix VxWorks available parallelism: Move nonzero::uncheked into unsafe block
1 parent 9337f7a commit fb1dac2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,11 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
489489
fn vxCpuEnabledGet() -> libc::cpuset_t;
490490
}
491491

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

0 commit comments

Comments
 (0)
Please sign in to comment.