ax_kspin/lib.rs
1#![cfg_attr(not(test), no_std)]
2#![doc = include_str!("../README.md")]
3
4#[cfg(any(test, doctest))]
5extern crate std;
6
7mod base;
8#[cfg(feature = "lockdep")]
9mod lockdep;
10
11use ax_kernel_guard::{NoOp, NoPreempt, NoPreemptIrqSave};
12
13pub use self::base::{BaseSpinLock, BaseSpinLockGuard};
14
15/// A spin lock that disables kernel preemption while trying to lock, and
16/// re-enables it after unlocking.
17///
18/// It must be used in the local IRQ-disabled context, or never be used in
19/// interrupt handlers.
20pub type SpinNoPreempt<T> = BaseSpinLock<NoPreempt, T>;
21
22/// A guard that provides mutable data access for [`SpinNoPreempt`].
23pub type SpinNoPreemptGuard<'a, T> = BaseSpinLockGuard<'a, NoPreempt, T>;
24
25/// A spin lock that disables kernel preemption and local IRQs while trying to
26/// lock, and re-enables it after unlocking.
27///
28/// It can be used in the IRQ-enabled context.
29pub type SpinNoIrq<T> = BaseSpinLock<NoPreemptIrqSave, T>;
30
31/// A guard that provides mutable data access for [`SpinNoIrq`].
32pub type SpinNoIrqGuard<'a, T> = BaseSpinLockGuard<'a, NoPreemptIrqSave, T>;
33
34/// A raw spin lock that does nothing while trying to lock.
35///
36/// It must be used in the preemption-disabled and local IRQ-disabled context,
37/// or never be used in interrupt handlers.
38pub type SpinRaw<T> = BaseSpinLock<NoOp, T>;
39
40/// A guard that provides mutable data access for [`SpinRaw`].
41pub type SpinRawGuard<'a, T> = BaseSpinLockGuard<'a, NoOp, T>;