diff options
author | 2017-06-27 19:12:28 -0500 | |
---|---|---|
committer | 2017-06-30 18:08:28 -0500 | |
commit | 93c901d7489ceeea4624b680e96c3e8867a9f08a (patch) | |
tree | b69a5bdc437ef15f8ef7ed91d63d89508ee8a48a | |
parent | cb7a60a2b4059bd483df2841aab9db74305cd35e (diff) | |
download | cortex-m-93c901d7489ceeea4624b680e96c3e8867a9f08a.tar.gz cortex-m-93c901d7489ceeea4624b680e96c3e8867a9f08a.tar.zst cortex-m-93c901d7489ceeea4624b680e96c3e8867a9f08a.zip |
add compiler barriers to interrupt::free
-rw-r--r-- | src/interrupt.rs | 6 |
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 |