Skip to content

Commit

Permalink
turn interrupt::{enable,disable} into compiler barriers
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric committed Jun 30, 2017
1 parent 93c901d commit a396a68
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn disable() {
asm!("cpsid i"
:
:
:
: "memory"
: "volatile");
},
#[cfg(not(target_arch = "arm"))]
Expand All @@ -66,7 +66,7 @@ pub unsafe fn enable() {
asm!("cpsie i"
:
:
:
: "memory"
: "volatile");
}
#[cfg(not(target_arch = "arm"))]
Expand All @@ -81,10 +81,6 @@ 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".
Expand All @@ -97,9 +93,7 @@ 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
Expand Down

0 comments on commit a396a68

Please sign in to comment.