Skip to content

Commit 338d00c

Browse files
bors[bot]japaric
andcommitted
Merge #103
103: v0.6.0 r=therealprof a=japaric this also adds compile-fail soundness tests and patches a soundness issue in `#[entry]` commit required to release a new (minor) version r? @rust-embedded/cortex-m (anyone) Co-authored-by: Jorge Aparicio <[email protected]>
2 parents 7854e96 + 5fd25ff commit 338d00c

File tree

5 files changed

+67
-5
lines changed

5 files changed

+67
-5
lines changed

cortex-m-rt/CHANGELOG.md

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

88
## [Unreleased]
99

10+
## [v0.6.0] - 2018-09-06
11+
12+
### Changed
13+
14+
- [breaking-change] the `entry!`, `pre_init!` and `exception!` macros have been
15+
replaced with attributes: `#[entry]`, `#[pre_init]` and `#[exception]`,
16+
respectively. This also changes the toolchain requirement to 1.30-beta or
17+
newer.
18+
1019
## [v0.5.3] - 2018-08-27
1120

1221
### Changed

cortex-m-rt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ keywords = ["arm", "cortex-m", "runtime", "startup"]
88
license = "MIT OR Apache-2.0"
99
name = "cortex-m-rt"
1010
repository = "https://github.com/japaric/cortex-m-rt"
11-
version = "0.5.3"
11+
version = "0.6.0"
1212

1313
[dependencies]
1414
r0 = "0.2.1"

cortex-m-rt/macros/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
9999

100100
// XXX should we blacklist other attributes?
101101
let attrs = f.attrs;
102-
let ident = f.ident;
102+
let hash = random_ident();
103103
let (statics, stmts) = extract_static_muts(f.block.stmts);
104104

105105
let vars = statics
@@ -123,11 +123,9 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
123123
}).collect::<Vec<_>>();
124124

125125
quote!(
126-
// TODO(forbid) see tests/compile-fail/entry-hidden.rs
127-
// #[forbid(dead_code)]
128126
#[export_name = "main"]
129127
#(#attrs)*
130-
pub fn #ident() -> ! {
128+
pub fn #hash() -> ! {
131129
#(#vars)*
132130

133131
#(#stmts)*
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#![no_main]
2+
#![no_std]
3+
4+
extern crate cortex_m_rt;
5+
extern crate panic_semihosting;
6+
7+
use cortex_m_rt::{entry, exception};
8+
9+
#[entry]
10+
fn foo() -> ! {
11+
static mut COUNT: u64 = 0;
12+
13+
loop {
14+
if *COUNT % 2 == 0 {
15+
*COUNT += 1;
16+
} else {
17+
*COUNT *= 2;
18+
}
19+
}
20+
}
21+
22+
#[exception]
23+
fn SysTick() {
24+
// If this was allowed it would lead to a data race as `SysTick` can preempt `foo`
25+
foo(); //~ ERROR cannot find function `foo` in this scope
26+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#![no_main]
2+
#![no_std]
3+
4+
extern crate cortex_m_rt;
5+
extern crate panic_semihosting;
6+
7+
use cortex_m_rt::{entry, exception};
8+
9+
#[entry]
10+
fn foo() -> ! {
11+
loop {}
12+
}
13+
14+
#[exception]
15+
fn SysTick() {
16+
static mut COUNT: u64 = 0;
17+
18+
if *COUNT % 2 == 0 {
19+
*COUNT += 1;
20+
} else {
21+
*COUNT *= 2;
22+
}
23+
}
24+
25+
#[exception]
26+
fn SVCall() {
27+
// If this was allowed it would lead to a data race as `SVCall` could preempt `SysTick`
28+
SysTick(); //~ ERROR cannot find function `SysTick` in this scope
29+
}

0 commit comments

Comments
 (0)