File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -919,7 +919,6 @@ fn get_concurrency() -> usize {
919919 #[ cfg( any( target_os = "freebsd" ,
920920 target_os = "dragonfly" ,
921921 target_os = "bitrig" ,
922- target_os = "openbsd" ,
923922 target_os = "netbsd" ) ) ]
924923 fn num_cpus ( ) -> usize {
925924 let mut cpus: libc:: c_uint = 0 ;
@@ -946,6 +945,24 @@ fn get_concurrency() -> usize {
946945 }
947946 cpus as usize
948947 }
948+
949+ #[ cfg( target_os = "openbsd" ) ]
950+ fn num_cpus ( ) -> usize {
951+ let mut cpus: libc:: c_uint = 0 ;
952+ let mut cpus_size = std:: mem:: size_of_val ( & cpus) ;
953+ let mut mib = [ libc:: CTL_HW , libc:: HW_NCPU , 0 , 0 ] ;
954+
955+ unsafe {
956+ libc:: sysctl ( mib. as_mut_ptr ( ) , 2 ,
957+ & mut cpus as * mut _ as * mut _ ,
958+ & mut cpus_size as * mut _ as * mut _ ,
959+ 0 as * mut _ , 0 ) ;
960+ }
961+ if cpus < 1 {
962+ cpus = 1 ;
963+ }
964+ cpus as usize
965+ }
949966}
950967
951968pub fn filter_tests ( opts : & TestOpts , tests : Vec < TestDescAndFn > ) -> Vec < TestDescAndFn > {
You can’t perform that action at this time.
0 commit comments