File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
library/std/src/sys/pal/unix Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -455,8 +455,18 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
455455
456456 Ok ( NonZero :: new_unchecked( sinfo. cpu_count as usize ) )
457457 }
458+ } else if #[ cfg( target_os = "vxworks" ) ] {
459+ // Note: there is also `vxCpuConfiguredGet`, closer to _SC_NPROCESSORS_CONF
460+ // expectations than the actual cores availability.
461+ extern "C" {
462+ fn vxCpuEnabledGet( ) -> libc:: cpuset_t;
463+ }
464+
465+ // always fetches a valid bitmask
466+ let set = unsafe { vxCpuEnabledGet( ) } ;
467+ Ok ( NonZero :: new_unchecked( set. count_ones( ) as usize ) )
458468 } else {
459- // FIXME: implement on vxWorks, Redox, l4re
469+ // FIXME: implement on Redox, l4re
460470 Err ( io:: const_io_error!( io:: ErrorKind :: Unsupported , "Getting the number of hardware threads is not supported on the target platform" ) )
461471 }
462472 }
You can’t perform that action at this time.
0 commit comments