(pid: Option<Pid>, cpuset: &mut RawCpuSet)
| 478 | |
| 479 | #[inline] |
| 480 | pub(crate) fn sched_getaffinity(pid: Option<Pid>, cpuset: &mut RawCpuSet) -> io::Result<()> { |
| 481 | unsafe { |
| 482 | // The raw Linux syscall returns the size (in bytes) of the `cpumask_t` |
| 483 | // data type that is used internally by the kernel to represent the CPU |
| 484 | // set bit mask. |
| 485 | let size = ret_usize(syscall!( |
| 486 | __NR_sched_getaffinity, |
| 487 | c_int(Pid::as_raw(pid)), |
| 488 | size_of::<RawCpuSet, _>(), |
| 489 | by_mut(&mut cpuset.bits) |
| 490 | ))?; |
| 491 | let bytes = as_mut_ptr(cpuset).cast::<u8>(); |
| 492 | let rest = bytes.wrapping_add(size); |
| 493 | // Zero every byte in the cpuset not set by the kernel. |
| 494 | rest.write_bytes(0, core::mem::size_of::<RawCpuSet>() - size); |
| 495 | Ok(()) |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | #[inline] |
| 500 | pub(crate) fn sched_setaffinity(pid: Option<Pid>, cpuset: &RawCpuSet) -> io::Result<()> { |
nothing calls this directly
no test coverage detected