aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2017-06-27 19:12:28 -0500
committerGravatar Jorge Aparicio <jorge@japaric.io> 2017-06-30 18:08:28 -0500
commit93c901d7489ceeea4624b680e96c3e8867a9f08a (patch)
treeb69a5bdc437ef15f8ef7ed91d63d89508ee8a48a
parentcb7a60a2b4059bd483df2841aab9db74305cd35e (diff)
downloadcortex-m-93c901d7489ceeea4624b680e96c3e8867a9f08a.tar.gz
cortex-m-93c901d7489ceeea4624b680e96c3e8867a9f08a.tar.zst
cortex-m-93c901d7489ceeea4624b680e96c3e8867a9f08a.zip
add compiler barriers to interrupt::free
-rw-r--r--src/interrupt.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/interrupt.rs b/src/interrupt.rs
index a6abcdd..95b5989 100644
--- a/src/interrupt.rs
+++ b/src/interrupt.rs
@@ -81,6 +81,10 @@ pub struct CriticalSection {
_0: (),
}
+macro_rules! barrier {
+ () => { asm!("" ::: "memory" : "volatile") }
+}
+
/// Execute closure `f` in an interrupt-free context.
///
/// This as also known as a "critical section".
@@ -93,7 +97,9 @@ where
// disable interrupts
disable();
+ unsafe { barrier!() }
let r = f(&CriticalSection { _0: () });
+ unsafe { barrier!() }
// If the interrupts were active before our `disable` call, then re-enable
// them. Otherwise, keep them disabled