Add InAtomicMode: Debug

This commit is contained in:
Zhang Junyang 2025-05-22 20:55:57 +08:00 committed by Tate, Hongliang Tian
parent 3472560c55
commit ef81100958
2 changed files with 7 additions and 6 deletions

View File

@ -50,17 +50,17 @@ pub fn might_sleep() {
/// ///
/// Key kernel primitives such as `SpinLock` and `Rcu` rely on /// Key kernel primitives such as `SpinLock` and `Rcu` rely on
/// [the atomic mode](crate::task::atomic_mode) for correctness or soundness. /// [the atomic mode](crate::task::atomic_mode) for correctness or soundness.
/// The existence of such a guard guarantees that /// The existence of such a guard guarantees that the current task is executing
/// the current task is executing in the atomic mode. /// in the atomic mode.
///
/// It requires [`core::fmt::Debug`] by default to make it easier to derive
/// [`Debug`] for types with `&dyn InAtomicMode`.
/// ///
/// # Safety /// # Safety
/// ///
/// The implementer must ensure that the atomic mode is maintained while /// The implementer must ensure that the atomic mode is maintained while
/// the guard type is alive. /// the guard type is alive.
/// pub unsafe trait InAtomicMode: core::fmt::Debug {}
/// [`DisabledLocalIrqGuard`]: crate::task::DisabledPreemptGuard
/// [`DisabledPreemptGuard`]: crate::trap::DisabledLocalIrqGuard
pub unsafe trait InAtomicMode {}
/// Abstracts any type from which one can obtain a reference to an atomic-mode guard. /// Abstracts any type from which one can obtain a reference to an atomic-mode guard.
pub trait AsAtomicModeGuard { pub trait AsAtomicModeGuard {

View File

@ -139,6 +139,7 @@ pub fn disable_local() -> DisabledLocalIrqGuard {
/// A guard for disabled local IRQs. /// A guard for disabled local IRQs.
#[clippy::has_significant_drop] #[clippy::has_significant_drop]
#[must_use] #[must_use]
#[derive(Debug)]
pub struct DisabledLocalIrqGuard { pub struct DisabledLocalIrqGuard {
was_enabled: bool, was_enabled: bool,
} }