Skip to content

Commit f2feeb2

Browse files
committed
Tweaks to enable building and doctesting on host platform
1 parent db8bea2 commit f2feeb2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

cortex-m-rt/src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,14 @@
439439

440440
extern crate cortex_m_rt_macros as macros;
441441

442-
use core::arch::global_asm;
443442
use core::fmt;
444-
use core::sync::atomic::{self, Ordering};
443+
#[cfg(cortex_m)]
444+
use core::arch::global_asm;
445445

446446
// HardFault exceptions are bounced through this trampoline which grabs the stack pointer at
447447
// the time of the exception and passes it to th euser's HardFault handler in r0.
448448
// Depending on the stack mode in EXC_RETURN, fetches stack from either MSP or PSP.
449+
#[cfg(cortex_m)]
449450
global_asm!(
450451
".cfi_sections .debug_frame
451452
.section .HardFaultTrampoline, \"ax\"
@@ -468,6 +469,7 @@ global_asm!(
468469
);
469470

470471
/// Parse cfg attributes inside a global_asm call.
472+
#[cfg(cortex_m)]
471473
macro_rules! cfg_global_asm {
472474
{@inner, [$($x:tt)*], } => {
473475
global_asm!{$($x)*}
@@ -490,6 +492,7 @@ macro_rules! cfg_global_asm {
490492
// Calls an optional user-provided __pre_init and then initialises RAM.
491493
// If the target has an FPU, it is enabled.
492494
// Finally jumsp to the user main function.
495+
#[cfg(cortex_m)]
493496
cfg_global_asm! {
494497
".cfi_sections .debug_frame
495498
.section .Reset, \"ax\"
@@ -1048,12 +1051,14 @@ pub static __RESET_VECTOR: unsafe extern "C" fn() -> ! = Reset;
10481051
#[cfg_attr(cortex_m, link_section = ".HardFault.default")]
10491052
#[no_mangle]
10501053
pub unsafe extern "C" fn HardFault_(ef: &ExceptionFrame) -> ! {
1054+
#[allow(clippy::empty_loop)]
10511055
loop {}
10521056
}
10531057

10541058
#[doc(hidden)]
10551059
#[no_mangle]
10561060
pub unsafe extern "C" fn DefaultHandler_() -> ! {
1061+
#[allow(clippy::empty_loop)]
10571062
loop {}
10581063
}
10591064

src/peripheral/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
6060
use core::marker::PhantomData;
6161
use core::ops;
62-
63-
#[cfg(cortex_m)]
6462
use crate::interrupt;
6563

6664
#[cfg(cm7)]
@@ -164,7 +162,6 @@ static mut TAKEN: bool = false;
164162

165163
impl Peripherals {
166164
/// Returns all the core peripherals *once*
167-
#[cfg(cortex_m)]
168165
#[inline]
169166
pub fn take() -> Option<Self> {
170167
interrupt::free(|_| {

0 commit comments

Comments
 (0)