mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-10 05:46:48 +00:00
Add InAtomicMode: Debug
This commit is contained in:
parent
3472560c55
commit
ef81100958
@ -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 {
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user