• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![allow(non_snake_case)]
2 
3 use super::super::c;
4 use super::types::{RawCpuSet, CPU_SETSIZE};
5 
6 #[inline]
CPU_SET(cpu: usize, cpuset: &mut RawCpuSet)7 pub(crate) fn CPU_SET(cpu: usize, cpuset: &mut RawCpuSet) {
8     assert!(
9         cpu < CPU_SETSIZE,
10         "cpu out of bounds: the cpu max is {} but the cpu is {}",
11         CPU_SETSIZE,
12         cpu
13     );
14     unsafe { c::CPU_SET(cpu, cpuset) }
15 }
16 
17 #[inline]
CPU_ZERO(cpuset: &mut RawCpuSet)18 pub(crate) fn CPU_ZERO(cpuset: &mut RawCpuSet) {
19     unsafe { c::CPU_ZERO(cpuset) }
20 }
21 
22 #[inline]
CPU_CLR(cpu: usize, cpuset: &mut RawCpuSet)23 pub(crate) fn CPU_CLR(cpu: usize, cpuset: &mut RawCpuSet) {
24     assert!(
25         cpu < CPU_SETSIZE,
26         "cpu out of bounds: the cpu max is {} but the cpu is {}",
27         CPU_SETSIZE,
28         cpu
29     );
30     unsafe { c::CPU_CLR(cpu, cpuset) }
31 }
32 
33 #[inline]
CPU_ISSET(cpu: usize, cpuset: &RawCpuSet) -> bool34 pub(crate) fn CPU_ISSET(cpu: usize, cpuset: &RawCpuSet) -> bool {
35     assert!(
36         cpu < CPU_SETSIZE,
37         "cpu out of bounds: the cpu max is {} but the cpu is {}",
38         CPU_SETSIZE,
39         cpu
40     );
41     unsafe { c::CPU_ISSET(cpu, cpuset) }
42 }
43 
44 #[cfg(any(target_os = "android", target_os = "linux"))]
45 #[inline]
CPU_COUNT(cpuset: &RawCpuSet) -> u3246 pub(crate) fn CPU_COUNT(cpuset: &RawCpuSet) -> u32 {
47     use core::convert::TryInto;
48     unsafe { c::CPU_COUNT(cpuset).try_into().unwrap() }
49 }
50