Skip to content

Commit

Permalink
Remove all llvm_asm macros
Browse files Browse the repository at this point in the history
  • Loading branch information
mbuesch authored and Rahix committed Aug 9, 2022
1 parent 2e8d033 commit bfccae0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 45 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,3 @@ cfg-if = "0.1.10"
path = "macros/"
version = "=0.3.4"
optional = true

[build-dependencies]
rustversion = "1.0"
16 changes: 0 additions & 16 deletions build.rs

This file was deleted.

14 changes: 4 additions & 10 deletions src/asm.rs
Original file line number Diff line number Diff line change
@@ -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!()
}
Expand All @@ -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!()
}
Expand All @@ -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!()
}
Expand Down
17 changes: 3 additions & 14 deletions src/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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;

Expand All @@ -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!()
Expand All @@ -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!()
}
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bfccae0

Please sign in to comment.