File tree 1 file changed +18
-1
lines changed 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 {
919
919
#[ cfg( any( target_os = "freebsd" ,
920
920
target_os = "dragonfly" ,
921
921
target_os = "bitrig" ,
922
- target_os = "openbsd" ,
923
922
target_os = "netbsd" ) ) ]
924
923
fn num_cpus ( ) -> usize {
925
924
let mut cpus: libc:: c_uint = 0 ;
@@ -946,6 +945,24 @@ fn get_concurrency() -> usize {
946
945
}
947
946
cpus as usize
948
947
}
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
+ }
949
966
}
950
967
951
968
pub fn filter_tests ( opts : & TestOpts , tests : Vec < TestDescAndFn > ) -> Vec < TestDescAndFn > {
You can’t perform that action at this time.
0 commit comments