diff options
author | 2017-06-25 10:56:49 -0500 | |
---|---|---|
committer | 2017-06-25 10:56:49 -0500 | |
commit | a81bb98141eb8b629da4bfde7109f75177d215af (patch) | |
tree | 580efc64a818e1705f2e0d69462c8008b3f419f0 /cortex-m-rt/src | |
parent | a2af5e27d0aeb3c507a1193b74dae24da2c17bda (diff) | |
download | cortex-m-a81bb98141eb8b629da4bfde7109f75177d215af.tar.gz cortex-m-a81bb98141eb8b629da4bfde7109f75177d215af.tar.zst cortex-m-a81bb98141eb8b629da4bfde7109f75177d215af.zip |
default panic! to abort, drop panic-* features, add panic_fmt! macro
Diffstat (limited to 'cortex-m-rt/src')
-rw-r--r-- | cortex-m-rt/src/lang_items.rs | 35 | ||||
-rw-r--r-- | cortex-m-rt/src/lib.rs | 7 |
2 files changed, 14 insertions, 28 deletions
diff --git a/cortex-m-rt/src/lang_items.rs b/cortex-m-rt/src/lang_items.rs index 7b3fa9d..b154b5f 100644 --- a/cortex-m-rt/src/lang_items.rs +++ b/cortex-m-rt/src/lang_items.rs @@ -6,32 +6,21 @@ unsafe extern "C" fn panic_fmt( _file: &'static str, _line: u32, ) -> ! { - match () { - #[cfg(feature = "panic-over-itm")] - () => { - use cortex_m::itm; - use cortex_m::peripheral::ITM; + ::core::intrinsics::abort() +} - let port = &(*ITM.get()).stim[0]; - iprint!(port, "panicked at '"); - itm::write_fmt(port, _args); - iprintln!(port, "', {}:{}", _file, _line); - } - #[cfg(feature = "panic-over-semihosting")] - () => { - hprint!("panicked at '"); - ::cortex_m_semihosting::io::write_fmt(_args); - hprintln!("', {}:{}", _file, _line); +#[macro_export] +macro_rules! panic_fmt { + ($f:expr) => { + #[export_name = "rust_begin_unwind"] + pub unsafe extern "C" fn _panic_fmt( + args: ::core::fmt::Arguments, + file: &'static str, + line: u32, + ) -> ! { + $f(args, file, line) } - #[cfg(not(any(feature = "panic-over-itm", - feature = "panic-over-semihosting")))] - () => {} } - - #[cfg(target_arch = "arm")] - asm!("bkpt" :::: "volatile"); - - loop {} } /// Lang item required to make the normal `main` work in applications diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs index fa87e6f..1908c50 100644 --- a/cortex-m-rt/src/lib.rs +++ b/cortex-m-rt/src/lib.rs @@ -149,18 +149,15 @@ #![deny(warnings)] #![feature(asm)] #![feature(compiler_builtins_lib)] +#![feature(core_intrinsics)] #![feature(lang_items)] #![feature(linkage)] #![feature(used)] #![no_std] -#[cfg(any(feature = "panic-over-itm", feature = "exceptions"))] -#[cfg_attr(feature = "panic-over-itm", macro_use)] +#[cfg(feature = "exceptions")] extern crate cortex_m; extern crate compiler_builtins; -#[cfg(feature = "panic-over-semihosting")] -#[macro_use] -extern crate cortex_m_semihosting; extern crate r0; mod lang_items; |