From a3572979cb88b0ca5760b4a672f652250dadf3bb Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sat, 29 Aug 2020 02:17:35 +0200 Subject: Merge asm implementations --- src/interrupt.rs | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) (limited to 'src/interrupt.rs') diff --git a/src/interrupt.rs b/src/interrupt.rs index c5da48d..68719ec 100644 --- a/src/interrupt.rs +++ b/src/interrupt.rs @@ -26,25 +26,7 @@ pub unsafe trait InterruptNumber: Copy { /// Disables all interrupts #[inline] pub fn disable() { - match () { - #[cfg(all(cortex_m, feature = "inline-asm"))] - () => unsafe { - llvm_asm!("cpsid i" ::: "memory" : "volatile"); - }, - - #[cfg(all(cortex_m, not(feature = "inline-asm")))] - () => unsafe { - extern "C" { - fn __cpsid(); - } - - // XXX do we need a explicit compiler barrier here? - __cpsid(); - }, - - #[cfg(not(cortex_m))] - () => unimplemented!(), - } + call_asm!(__cpsid()); } /// Enables all the interrupts @@ -54,23 +36,7 @@ pub fn disable() { /// - Do not call this function inside an `interrupt::free` critical section #[inline] pub unsafe fn enable() { - match () { - #[cfg(all(cortex_m, feature = "inline-asm"))] - () => llvm_asm!("cpsie i" ::: "memory" : "volatile"), - - #[cfg(all(cortex_m, not(feature = "inline-asm")))] - () => { - extern "C" { - fn __cpsie(); - } - - // XXX do we need a explicit compiler barrier here? - __cpsie(); - } - - #[cfg(not(cortex_m))] - () => unimplemented!(), - } + call_asm!(__cpsie()); } /// Execute closure `f` in an interrupt-free context. -- cgit v1.2.3