diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-08-26 00:35:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-26 00:35:22 +0000 |
commit | aa3ee6bc0e246eaa65131dc99ccc6391a99c996c (patch) | |
tree | 90fd37295f4199be63bc51923528067ea9fa98cd /src | |
parent | 97d6b43bcbbc7de7cb5dd017017aea3ee35e248f (diff) | |
parent | 3dc163e780492fa7b2027460d062bc93adc22d77 (diff) | |
download | nix-aa3ee6bc0e246eaa65131dc99ccc6391a99c996c.zip |
Merge #1804
1804: Add sched_getaffinity and sched_setaffinity on FreeBSD r=asomers a=rtzoeller
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/sched.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/sched.rs b/src/sched.rs index e9a326e2..943ed6ec 100644 --- a/src/sched.rs +++ b/src/sched.rs @@ -142,10 +142,10 @@ mod sched_linux_like { } } -#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "linux"))] +#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] pub use self::sched_affinity::*; -#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "linux"))] +#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] mod sched_affinity { use crate::errno::Errno; use std::mem; @@ -157,10 +157,13 @@ mod sched_affinity { /// sched_getaffinity for example. /// /// This is a wrapper around `libc::cpu_set_t`. - #[repr(C)] + #[repr(transparent)] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct CpuSet { + #[cfg(not(target_os = "freebsd"))] cpu_set: libc::cpu_set_t, + #[cfg(target_os = "freebsd")] + cpu_set: libc::cpuset_t, } impl CpuSet { @@ -205,7 +208,12 @@ mod sched_affinity { /// Return the maximum number of CPU in CpuSet pub const fn count() -> usize { - 8 * mem::size_of::<libc::cpu_set_t>() + #[cfg(not(target_os = "freebsd"))] + let bytes = mem::size_of::<libc::cpu_set_t>(); + #[cfg(target_os = "freebsd")] + let bytes = mem::size_of::<libc::cpuset_t>(); + + 8 * bytes } } |