From 93c901d7489ceeea4624b680e96c3e8867a9f08a Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 27 Jun 2017 19:12:28 -0500 Subject: [PATCH] add compiler barriers to interrupt::free --- src/interrupt.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/interrupt.rs b/src/interrupt.rs index a6abcdd9..95b59891 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