Lines Matching +full:0 +full:xa

23 /// `self.xa` is always an initialized and valid [`bindings::xarray`] whose entries are either
32 /// let xa = KBox::pin_init(XArray::new(AllocKind::Alloc1), GFP_KERNEL)?;
34 /// let dead = KBox::new(0xdead, GFP_KERNEL)?;
35 /// let beef = KBox::new(0xbeef, GFP_KERNEL)?;
37 /// let mut guard = xa.lock();
39 /// assert_eq!(guard.get(0), None);
41 /// assert_eq!(guard.store(0, dead, GFP_KERNEL)?.as_deref(), None);
42 /// assert_eq!(guard.get(0).copied(), Some(0xdead));
44 /// *guard.get_mut(0).unwrap() = 0xffff;
45 /// assert_eq!(guard.get(0).copied(), Some(0xffff));
47 /// assert_eq!(guard.store(0, beef, GFP_KERNEL)?.as_deref().copied(), Some(0xffff));
48 /// assert_eq!(guard.get(0).copied(), Some(0xbeef));
50 /// guard.remove(0);
51 /// assert_eq!(guard.get(0), None);
58 xa: Opaque<bindings::xarray>, field
74 // SAFETY: `self.xa` is always valid by the type invariant. in drop()
75 unsafe { bindings::xa_destroy(self.xa.get()) }; in drop()
81 /// Consider the first element to be at index 0.
95 // SAFETY: `xa` is valid while the closure is called. in new()
97 // INVARIANT: `xa` is initialized here to an empty, valid [`bindings::xarray`]. in new()
98 xa <- Opaque::ffi_init(|xa| unsafe { in new()
99 bindings::xa_init_flags(xa, flags) in new()
106 let mut index = 0; in iter()
108 // SAFETY: `self.xa` is always valid by the type invariant. in iter()
110 bindings::xa_find(self.xa.get(), &mut index, usize::MAX, bindings::XA_PRESENT) in iter()
113 // SAFETY: `self.xa` is always valid by the type invariant. in iter()
115 bindings::xa_find_after(self.xa.get(), &mut index, usize::MAX, bindings::XA_PRESENT) in iter()
123 // SAFETY: `self.xa` is always valid by the type invariant. in try_lock()
124 if (unsafe { bindings::xa_trylock(self.xa.get()) } != 0) { in try_lock()
126 xa: self, in try_lock()
136 // SAFETY: `self.xa` is always valid by the type invariant. in lock()
137 unsafe { bindings::xa_lock(self.xa.get()) }; in lock()
140 xa: self, in lock()
151 xa: &'a XArray<T>, field
158 // - `self.xa.xa` is always valid by the type invariant. in drop()
160 unsafe { bindings::xa_unlock(self.xa.xa.get()) }; in drop()
185 // SAFETY: `self.xa.xa` is always valid by the type invariant. in load()
186 let ptr = unsafe { bindings::xa_load(self.xa.xa.get(), index) }; in load()
210 // - `self.xa.xa` is always valid by the type invariant. in remove()
212 let ptr = unsafe { bindings::__xa_erase(self.xa.xa.get(), index) }.cast(); in remove()
242 // - `self.xa.xa` is always valid by the type invariant. in store()
246 unsafe { bindings::__xa_store(self.xa.xa.get(), index, new, gfp.as_raw()) } in store()
252 if errno != 0 { in store()