Lines Matching +full:cpu +full:- +full:cfg
1 // SPDX-License-Identifier: GPL-2.0
3 //! CPU Mask abstractions.
9 cpu::CpuId,
14 #[cfg(CONFIG_CPUMASK_OFFSTACK)]
17 #[cfg(not(CONFIG_CPUMASK_OFFSTACK))]
22 /// A CPU Mask.
39 /// use kernel::cpu::CpuId;
61 pub unsafe fn as_mut_ref<'a>(ptr: *mut bindings::cpumask) -> &'a mut Self { in as_mut_ref()
75 pub unsafe fn as_ref<'a>(ptr: *const bindings::cpumask) -> &'a Self { in as_ref()
84 pub fn as_raw(&self) -> *mut bindings::cpumask { in as_raw()
89 /// Set `cpu` in the cpumask.
91 /// ATTENTION: Contrary to C, this Rust `set()` method is non-atomic.
95 pub fn set(&mut self, cpu: CpuId) { in set()
97 unsafe { bindings::__cpumask_set_cpu(u32::from(cpu), self.as_raw()) }; in set()
100 /// Clear `cpu` in the cpumask.
102 /// ATTENTION: Contrary to C, this Rust `clear()` method is non-atomic.
106 pub fn clear(&mut self, cpu: CpuId) { in clear()
109 unsafe { bindings::__cpumask_clear_cpu(i32::from(cpu), self.as_raw()) }; in clear()
112 /// Test `cpu` in the cpumask.
116 pub fn test(&self, cpu: CpuId) -> bool { in test()
118 unsafe { bindings::cpumask_test_cpu(i32::from(cpu), self.as_raw()) } in test()
134 pub fn empty(&self) -> bool { in empty()
143 pub fn full(&self) -> bool { in full()
152 pub fn weight(&self) -> u32 { in weight()
167 /// A CPU Mask pointer.
183 /// use kernel::cpu::CpuId;
192 /// if let Some(cpu) = cpu2 {
193 /// mask.set(cpu);
194 /// assert!(mask.test(cpu));
199 /// if let Some(cpu) = cpu3 {
200 /// mask.set(cpu);
201 /// assert!(mask.test(cpu));
209 /// if let Some(cpu) = cpu2 {
210 /// assert!(mask2.test(cpu));
213 /// if let Some(cpu) = cpu3 {
214 /// assert!(mask2.test(cpu));
219 #[cfg(CONFIG_CPUMASK_OFFSTACK)]
221 #[cfg(not(CONFIG_CPUMASK_OFFSTACK))]
226 /// Creates a zero-initialized instance of the [`CpumaskVar`].
227 pub fn new_zero(_flags: Flags) -> Result<Self, AllocError> { in new_zero()
229 #[cfg(CONFIG_CPUMASK_OFFSTACK)] in new_zero()
241 #[cfg(not(CONFIG_CPUMASK_OFFSTACK))] in new_zero()
242 // SAFETY: FFI type is valid to be zero-initialized. in new_zero()
255 pub unsafe fn new(_flags: Flags) -> Result<Self, AllocError> { in new()
257 #[cfg(CONFIG_CPUMASK_OFFSTACK)] in new()
268 #[cfg(not(CONFIG_CPUMASK_OFFSTACK))] in new()
282 pub unsafe fn as_mut_ref<'a>(ptr: *mut bindings::cpumask_var_t) -> &'a mut Self { in as_mut_ref()
296 pub unsafe fn as_ref<'a>(ptr: *const bindings::cpumask_var_t) -> &'a Self { in as_ref()
305 pub fn try_clone(cpumask: &Cpumask) -> Result<Self> { in try_clone()
318 #[cfg(CONFIG_CPUMASK_OFFSTACK)]
319 fn deref(&self) -> &Self::Target { in deref()
324 #[cfg(not(CONFIG_CPUMASK_OFFSTACK))]
325 fn deref(&self) -> &Self::Target { in deref()
331 #[cfg(CONFIG_CPUMASK_OFFSTACK)]
332 fn deref_mut(&mut self) -> &mut Cpumask { in deref_mut()
337 #[cfg(not(CONFIG_CPUMASK_OFFSTACK))]
338 fn deref_mut(&mut self) -> &mut Cpumask { in deref_mut()
345 #[cfg(CONFIG_CPUMASK_OFFSTACK)] in drop()