Skip to content

Commit 3f8307c

Browse files
committed
Mark pre_init as deprecated
1 parent c3d664b commit 3f8307c

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

cortex-m-rt/CHANGELOG.md

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

88
## [Unreleased]
99

10+
- Mark `pre_init` as deprecated
1011
- Add `set_msplim` feature to conditionally set the MSPLIM register at device
1112
reset ([#580]).
1213

cortex-m-rt/examples/pre_init.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
extern crate cortex_m_rt as rt;
88
extern crate panic_halt;
99

10-
use rt::{entry, pre_init};
10+
use rt::entry;
1111

12-
#[pre_init]
13-
unsafe fn disable_watchdog() {
14-
// Do what you need to disable the watchdog.
12+
// This function is called before the RAM is initialized.
13+
// For example, it can be used to disable the watchdog.
14+
core::arch::global_asm! {
15+
r#"
16+
__pre_init:
17+
// Do what you need to do before RAM is initialized.
18+
bx lr
19+
"#
1520
}
1621

1722
#[entry]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
628628
}
629629

630630
#[proc_macro_attribute]
631+
#[deprecated(note = "Use core::arch::global_asm! to define the __pre_init function instead")]
631632
pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
632633
let f = parse_macro_input!(input as ItemFn);
633634

cortex-m-rt/tests/compile-fail/pre-init-args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern crate panic_halt;
77
use cortex_m_rt::{entry, pre_init};
88

99
#[pre_init(foo)] //~ ERROR This attribute accepts no arguments
10+
//~^ WARNING Use core::arch::global_asm! to define the __pre_init function instead
1011
unsafe fn foo() {}
1112

1213
#[entry]

0 commit comments

Comments
 (0)