Skip to content
This repository was archived by the owner on Nov 14, 2020. It is now read-only.

Commit 0538608

Browse files
committed
#[lang = "panic_fmt"] -> #[panic_implementation]
1 parent 13510cb commit 0538608

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
## [v0.2.0] - 2018-06-04
11+
12+
### Changed
13+
14+
- [breaking-change] moved from the, now removed, `panic_fmt` lang item to the
15+
`#[panic_implementation]` attribute.
16+
1017
## [v0.1.1] - 2018-05-11
1118

1219
### Changed
@@ -20,5 +27,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2027

2128
Initial release
2229

23-
[Unreleased]: https://github.com/japaric/panic-itm/compare/v0.1.1...HEAD
30+
[Unreleased]: https://github.com/japaric/panic-itm/compare/v0.2.0...HEAD
31+
[v0.2.0]: https://github.com/japaric/panic-itm/compare/v0.1.1...v0.2.0
2432
[v0.1.1]: https://github.com/japaric/panic-itm/compare/v0.1.0...v0.1.1

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ keywords = ["panic-impl", "panic", "ITM", "ARM", "Cortex-M"]
66
license = "MIT OR Apache-2.0"
77
name = "panic-itm"
88
repository = "https://github.com/japaric/panic-itm"
9-
version = "0.1.1"
9+
version = "0.2.0"
1010

1111
[dependencies]
12-
aligned = "0.2.0"
1312
cortex-m = "0.5.0"

src/lib.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,25 @@
3030
3131
#![deny(missing_docs)]
3232
#![deny(warnings)]
33-
#![feature(lang_items)]
33+
#![feature(panic_implementation)]
3434
#![no_std]
3535

36-
extern crate aligned;
3736
#[macro_use]
3837
extern crate cortex_m;
3938

40-
use aligned::Aligned;
39+
use core::panic::PanicInfo;
40+
4141
use cortex_m::peripheral::ITM;
42-
use cortex_m::{interrupt, itm};
43-
44-
#[lang = "panic_fmt"]
45-
unsafe extern "C" fn panic_fmt(
46-
args: core::fmt::Arguments,
47-
file: &'static str,
48-
line: u32,
49-
col: u32,
50-
) -> ! {
42+
use cortex_m::interrupt;
43+
44+
#[panic_implementation]
45+
fn panic(info: &PanicInfo) -> ! {
5146
interrupt::disable();
5247

53-
let itm = &mut *ITM::ptr();
48+
let itm = unsafe { &mut *ITM::ptr() };
5449
let stim = &mut itm.stim[0];
5550

56-
itm::write_aligned(stim, &Aligned(*b"panicked at '"));
57-
itm::write_fmt(stim, args);
58-
itm::write_aligned(stim, &Aligned(*b"', "));
59-
itm::write_str(stim, file);
60-
iprintln!(stim, ":{}:{}", line, col);
51+
iprintln!(stim, "{}", info);
6152

6253
loop {}
6354
}

0 commit comments

Comments
 (0)