1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/// Strategy for disabling and restoring **local (per-CPU) interrupts**.
///
/// Implement this trait to tell the allocator how to disabling interrupts around a
/// lock's critical section, so the locked allocators are safe to call from interrupt
/// context.
///
/// [`disable`](InterruptControl::disable) must **save the prior state and then
/// disable**, returning that state; [`restore`](InterruptControl::restore) must put
/// it back. Saving the prior state (rather than unconditionally re-enabling) is
/// what makes nesting correct: an inner lock taken while an outer lock already
/// disabled interrupts will, on release, restore "still disabled", and only the
/// outermost release re-enables.
///
/// # Safety
///
/// `restore` is `unsafe`: it changes the CPU interrupt-enable state and must be
/// called exactly once, with the [`State`](InterruptControl::State) returned by the
/// matching `disable`, after the critical section. `disable`/`restore` need to be
/// faithful inverses.
pub unsafe
/// The default [`InterruptControl`]: a no-op. Interrupts are never touched, so it
/// is **not safe to call from an interrupt handler**.
;
// SAFETY: a no-op is a trivially faithful inverse of itself; `restore` changes no
// machine state.
unsafe