File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -339,14 +339,18 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> {
339339
340340 Ok ( unsafe { NonZeroUsize :: new_unchecked( cpus as usize ) } )
341341 } 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) ;
342+ // system_info cpu_count field gets the static data set at boot time with `smp_set_num_cpus`
343+ // `get_system_info` calls then `smp_get_num_cpus`
344+ unsafe {
345+ let mut sinfo: libc:: system_info = crate :: mem:: zeroed( ) ;
346+ let res = libc:: get_system_info( & mut sinfo) ;
344347
345- if res != libc:: B_OK {
346- return Err ( io:: Error :: last_os_error ( ) ) ;
347- }
348+ if res != libc:: B_OK {
349+ return Err ( io:: Error :: new_const ( io :: ErrorKind :: NotFound , & "The number of hardware threads is not known for the target platform" ) ) ;
350+ }
348351
349- Ok ( unsafe { NonZeroUsize :: new_unchecked( sinfo. cpu_count as usize ) } )
352+ Ok ( NonZeroUsize :: new_unchecked( sinfo. cpu_count as usize ) )
353+ }
350354 } else {
351355 // FIXME: implement on vxWorks, Redox, l4re
352356 Err ( io:: Error :: new_const( io:: ErrorKind :: Unsupported , & "Getting the number of hardware threads is not supported on the target platform" ) )
You can’t perform that action at this time.
0 commit comments