From bfccae0ab0138202db34b0c539f525634c21f1fe Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 8 Aug 2022 18:13:08 +0200 Subject: [PATCH] Remove all llvm_asm macros --- Cargo.toml | 3 --- build.rs | 16 ---------------- src/asm.rs | 14 ++++---------- src/interrupt.rs | 17 +++-------------- src/lib.rs | 3 +-- 5 files changed, 8 insertions(+), 45 deletions(-) delete mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index b9155e4..88a1285 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,6 +67,3 @@ cfg-if = "0.1.10" path = "macros/" version = "=0.3.4" optional = true - -[build-dependencies] -rustversion = "1.0" diff --git a/build.rs b/build.rs deleted file mode 100644 index 352e458..0000000 --- a/build.rs +++ /dev/null @@ -1,16 +0,0 @@ -fn main() { - println!("cargo:rerun-if-changed=build.rs"); - - maybe_enable_asm(); -} - -#[rustversion::before(1.59.0)] -fn maybe_enable_asm() { - // -} - -#[rustversion::since(1.59.0)] -fn maybe_enable_asm() { - // https://github.com/rust-lang/rust/pull/92816 - println!("cargo:rustc-cfg=avr_device_asm_macro"); -} diff --git a/src/asm.rs b/src/asm.rs index f859d89..629a26d 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -1,16 +1,14 @@ //! Assembly instructions -#[cfg(all(target_arch = "avr", avr_device_asm_macro))] +#[cfg(target_arch = "avr")] use core::arch::asm; /// No Operation #[inline(always)] pub fn nop() { cfg_if::cfg_if! { - if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] { + if #[cfg(target_arch = "avr")] { unsafe { asm!("nop") } - } else if #[cfg(target_arch = "avr")] { - unsafe { llvm_asm!("nop") } } else { unimplemented!() } @@ -21,10 +19,8 @@ pub fn nop() { #[inline(always)] pub fn sleep() { cfg_if::cfg_if! { - if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] { + if #[cfg(target_arch = "avr")] { unsafe { asm!("sleep") } - } else if #[cfg(target_arch = "avr")] { - unsafe { llvm_asm!("sleep") } } else { unimplemented!() } @@ -35,10 +31,8 @@ pub fn sleep() { #[inline(always)] pub fn wdr() { cfg_if::cfg_if! { - if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] { + if #[cfg(target_arch = "avr")] { unsafe { asm!("wdr") } - } else if #[cfg(target_arch = "avr")] { - unsafe { llvm_asm!("wdr") } } else { unimplemented!() } diff --git a/src/interrupt.rs b/src/interrupt.rs index 2f225a3..65b8c83 100644 --- a/src/interrupt.rs +++ b/src/interrupt.rs @@ -30,7 +30,7 @@ pub use bare_metal::{CriticalSection, Mutex, Nr}; -#[cfg(all(target_arch = "avr", avr_device_asm_macro))] +#[cfg(target_arch = "avr")] use core::arch::asm; #[inline] @@ -39,7 +39,7 @@ use core::arch::asm; /// Returns a bool, reflecting whether interrupts were enabled prior to calling this method. pub fn disable() -> bool { cfg_if::cfg_if! { - if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] { + if #[cfg(target_arch = "avr")] { // Store current state let sreg: u8; @@ -53,15 +53,6 @@ pub fn disable() -> bool { // Disable interrupts unsafe { asm!("cli") }; - sreg & 0x80 == 0x80 - } else if #[cfg(target_arch = "avr")] { - // Store current state - let sreg: u8; - unsafe { llvm_asm!("in $0,0x3F" :"=r"(sreg) ::: "volatile") }; - - // Disable interrupts - unsafe { llvm_asm!("cli" :::: "volatile") }; - sreg & 0x80 == 0x80 } else { unimplemented!() @@ -77,10 +68,8 @@ pub fn disable() -> bool { /// - Do not call this function inside an [crate::interrupt::free] critical section pub unsafe fn enable() { cfg_if::cfg_if! { - if #[cfg(all(target_arch = "avr", avr_device_asm_macro))] { + if #[cfg(target_arch = "avr")] { asm!("sei"); - } else if #[cfg(target_arch = "avr")] { - llvm_asm!("sei" :::: "volatile"); } else { unimplemented!() } diff --git a/src/lib.rs b/src/lib.rs index 69765a1..7c99a39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,8 +131,7 @@ //! * To enable the crate's runtime environment, use the `rt` feature. #![no_std] -#![cfg_attr(avr_device_asm_macro, feature(asm_experimental_arch))] -#![cfg_attr(not(avr_device_asm_macro), feature(llvm_asm))] +#![cfg_attr(target_arch = "avr", feature(asm_experimental_arch))] // for experimental AVR asm! macro. pub mod asm; pub mod interrupt; -- 2.49.0