File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
library/std/src/sys/thread Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
153153 target_os = "hurd" ,
154154 target_os = "linux" ,
155155 target_os = "aix" ,
156+ target_os = "freebsd" ,
156157 target_vendor = "apple" ,
157158 target_os = "cygwin" ,
158159 ) => {
@@ -163,9 +164,17 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
163164 #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
164165 {
165166 quota = cgroups:: quota( ) . max( 1 ) ;
166- let mut set: libc:: cpu_set_t = unsafe { mem:: zeroed( ) } ;
167+ }
168+
169+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "freebsd" ) ) ]
170+ {
171+ #[ cfg( not( target_os = "freebsd" ) ) ]
172+ type Cpuset = libc:: cpu_set_t;
173+ #[ cfg( target_os = "freebsd" ) ]
174+ type Cpuset = libc:: cpuset_t;
175+ let mut set: Cpuset = unsafe { mem:: zeroed( ) } ;
167176 unsafe {
168- if libc:: sched_getaffinity( 0 , size_of :: <libc :: cpu_set_t >( ) , & mut set) == 0 {
177+ if libc:: sched_getaffinity( 0 , mem :: size_of :: < Cpuset >( ) , & mut set) == 0 {
169178 let count = libc:: CPU_COUNT ( & set) as usize ;
170179 let count = count. min( quota) ;
171180
You can’t perform that action at this time.
0 commit comments