pub struct Cpumask(/* private fields */);Expand description
A CPU Mask.
Rust abstraction for the C struct cpumask.
§Invariants
A Cpumask instance always corresponds to a valid C struct cpumask.
The callers must ensure that the struct cpumask is valid for access and
remains valid for the lifetime of the returned reference.
§Examples
The following example demonstrates how to update a Cpumask.
use kernel::bindings;
use kernel::cpu::CpuId;
use kernel::cpumask::Cpumask;
fn set_clear_cpu(ptr: *mut bindings::cpumask, set_cpu: CpuId, clear_cpu: CpuId) {
// SAFETY: The `ptr` is valid for writing and remains valid for the lifetime of the
// returned reference.
let mask = unsafe { Cpumask::as_mut_ref(ptr) };
mask.set(set_cpu);
mask.clear(clear_cpu);
}Implementations§
Source§impl Cpumask
impl Cpumask
Sourcepub unsafe fn as_mut_ref<'a>(ptr: *mut cpumask) -> &'a mut Self
pub unsafe fn as_mut_ref<'a>(ptr: *mut cpumask) -> &'a mut Self
Creates a mutable reference to an existing struct cpumask pointer.
§Safety
The caller must ensure that ptr is valid for writing and remains valid for the lifetime
of the returned reference.
Sourcepub unsafe fn as_ref<'a>(ptr: *const cpumask) -> &'a Self
pub unsafe fn as_ref<'a>(ptr: *const cpumask) -> &'a Self
Creates a reference to an existing struct cpumask pointer.
§Safety
The caller must ensure that ptr is valid for reading and remains valid for the lifetime
of the returned reference.
Sourcepub fn set(&mut self, cpu: CpuId)
pub fn set(&mut self, cpu: CpuId)
Set cpu in the cpumask.
ATTENTION: Contrary to C, this Rust set() method is non-atomic.
This mismatches kernel naming convention and corresponds to the C
function __cpumask_set_cpu().
Sourcepub fn clear(&mut self, cpu: CpuId)
pub fn clear(&mut self, cpu: CpuId)
Clear cpu in the cpumask.
ATTENTION: Contrary to C, this Rust clear() method is non-atomic.
This mismatches kernel naming convention and corresponds to the C
function __cpumask_clear_cpu().
Sourcepub fn test(&self, cpu: CpuId) -> bool
pub fn test(&self, cpu: CpuId) -> bool
Test cpu in the cpumask.
Equivalent to the kernel’s cpumask_test_cpu API.
Sourcepub fn setall(&mut self)
pub fn setall(&mut self)
Set all CPUs in the cpumask.
Equivalent to the kernel’s cpumask_setall API.
Sourcepub fn empty(&self) -> bool
pub fn empty(&self) -> bool
Checks if cpumask is empty.
Equivalent to the kernel’s cpumask_empty API.
Sourcepub fn full(&self) -> bool
pub fn full(&self) -> bool
Checks if cpumask is full.
Equivalent to the kernel’s cpumask_full API.
Auto Trait Implementations§
impl !Freeze for Cpumask
impl !RefUnwindSafe for Cpumask
impl Send for Cpumask
impl !Sync for Cpumask
impl !Unpin for Cpumask
impl UnwindSafe for Cpumask
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
slot. Read more