@@ -142,10 +142,10 @@ mod sched_linux_like {
142142 }
143143}
144144
145- #[ cfg( any( target_os = "android" , target_os = "dragonfly" , target_os = "linux" ) ) ]
145+ #[ cfg( any( target_os = "android" , target_os = "dragonfly" , target_os = "freebsd" , target_os = " linux") ) ]
146146pub use self :: sched_affinity:: * ;
147147
148- #[ cfg( any( target_os = "android" , target_os = "dragonfly" , target_os = "linux" ) ) ]
148+ #[ cfg( any( target_os = "android" , target_os = "dragonfly" , target_os = "freebsd" , target_os = " linux") ) ]
149149mod sched_affinity {
150150 use crate :: errno:: Errno ;
151151 use std:: mem;
@@ -157,10 +157,13 @@ mod sched_affinity {
157157 /// sched_getaffinity for example.
158158 ///
159159 /// This is a wrapper around `libc::cpu_set_t`.
160- #[ repr( C ) ]
160+ #[ repr( transparent ) ]
161161 #[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
162162 pub struct CpuSet {
163+ #[ cfg( not( target_os = "freebsd" ) ) ]
163164 cpu_set : libc:: cpu_set_t ,
165+ #[ cfg( target_os = "freebsd" ) ]
166+ cpu_set : libc:: cpuset_t ,
164167 }
165168
166169 impl CpuSet {
@@ -205,7 +208,12 @@ mod sched_affinity {
205208
206209 /// Return the maximum number of CPU in CpuSet
207210 pub const fn count ( ) -> usize {
208- 8 * mem:: size_of :: < libc:: cpu_set_t > ( )
211+ #[ cfg( not( target_os = "freebsd" ) ) ]
212+ let bytes = mem:: size_of :: < libc:: cpu_set_t > ( ) ;
213+ #[ cfg( target_os = "freebsd" ) ]
214+ let bytes = mem:: size_of :: < libc:: cpuset_t > ( ) ;
215+
216+ 8 * bytes
209217 }
210218 }
211219
0 commit comments