Lines Matching defs:ptr
15 use core::ptr::{self, NonNull};
39 /// fn set_clear_cpu(ptr: *mut bindings::cpumask, set_cpu: CpuId, clear_cpu: CpuId) {
40 /// // SAFETY: The `ptr` is valid for writing and remains valid for the lifetime of the
42 /// let mask = unsafe { Cpumask::as_mut_ref(ptr) };
56 /// The caller must ensure that `ptr` is valid for writing and remains valid for the lifetime
58 pub unsafe fn as_mut_ref<'a>(ptr: *mut bindings::cpumask) -> &'a mut Self {
61 // INVARIANT: The caller ensures that `ptr` is valid for writing and remains valid for the
63 unsafe { &mut *ptr.cast() }
70 /// The caller must ensure that `ptr` is valid for reading and remains valid for the lifetime
72 pub unsafe fn as_ref<'a>(ptr: *const bindings::cpumask) -> &'a Self {
75 // INVARIANT: The caller ensures that `ptr` is valid for reading and remains valid for the
77 unsafe { &*ptr.cast() }
218 ptr: NonNull<Cpumask>,
228 ptr: {
229 let mut ptr: *mut bindings::cpumask = ptr::null_mut();
231 // SAFETY: It is safe to call this method as the reference to `ptr` is valid.
235 unsafe { bindings::zalloc_cpumask_var(&mut ptr, _flags.as_raw()) };
236 NonNull::new(ptr.cast()).ok_or(AllocError)?
253 ptr: {
254 let mut ptr: *mut bindings::cpumask = ptr::null_mut();
256 // SAFETY: It is safe to call this method as the reference to `ptr` is valid.
260 unsafe { bindings::alloc_cpumask_var(&mut ptr, _flags.as_raw()) };
261 NonNull::new(ptr.cast()).ok_or(AllocError)?
272 /// The caller must ensure that `ptr` is valid for writing and remains valid for the lifetime
274 pub unsafe fn from_raw_mut<'a>(ptr: *mut bindings::cpumask_var_t) -> &'a mut Self {
277 // INVARIANT: The caller ensures that `ptr` is valid for writing and remains valid for the
279 unsafe { &mut *ptr.cast() }
286 /// The caller must ensure that `ptr` is valid for reading and remains valid for the lifetime
288 pub unsafe fn from_raw<'a>(ptr: *const bindings::cpumask_var_t) -> &'a Self {
291 // INVARIANT: The caller ensures that `ptr` is valid for reading and remains valid for the
293 unsafe { &*ptr.cast() }
313 unsafe { &*self.ptr.as_ptr() }
326 unsafe { self.ptr.as_mut() }