File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -462,8 +462,18 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
462462
463463 Ok ( NonZero :: new_unchecked( sinfo. cpu_count as usize ) )
464464 }
465+ } else if #[ cfg( target_os = "vxworks" ) ] {
466+ // Note: there is also `vxCpuConfiguredGet`, closer to _SC_NPROCESSORS_CONF
467+ // expectations than the actual cores availability.
468+ extern "C" {
469+ fn vxCpuEnabledGet( ) -> libc:: cpuset_t;
470+ }
471+
472+ // always fetches a valid bitmask
473+ let set = unsafe { vxCpuEnabledGet( ) } ;
474+ Ok ( NonZero :: new_unchecked( set. count_ones( ) as usize ) )
465475 } else {
466- // FIXME: implement on vxWorks, Redox, l4re
476+ // FIXME: implement on Redox, l4re
467477 Err ( io:: const_io_error!( io:: ErrorKind :: Unsupported , "Getting the number of hardware threads is not supported on the target platform" ) )
468478 }
469479 }
You can’t perform that action at this time.
0 commit comments