File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 1
1
//! Enabling and disabling interrupts
2
2
3
3
use core:: arch:: asm;
4
+ use core:: sync:: atomic:: { compiler_fence, Ordering } ;
4
5
5
6
/// Returns whether interrupts are enabled.
6
7
#[ inline]
@@ -15,6 +16,8 @@ pub fn are_enabled() -> bool {
15
16
/// This is a wrapper around the `sti` instruction.
16
17
#[ inline]
17
18
pub fn enable ( ) {
19
+ // Prevent earlier writes to be moved beyond this point
20
+ compiler_fence ( Ordering :: Release ) ;
18
21
unsafe {
19
22
asm ! ( "sti" , options( nomem, nostack) ) ;
20
23
}
@@ -25,6 +28,8 @@ pub fn enable() {
25
28
/// This is a wrapper around the `cli` instruction.
26
29
#[ inline]
27
30
pub fn disable ( ) {
31
+ // Prevent future writes to be moved before this point.
32
+ compiler_fence ( Ordering :: Acquire ) ;
28
33
unsafe {
29
34
asm ! ( "cli" , options( nomem, nostack) ) ;
30
35
}
You can’t perform that action at this time.
0 commit comments