Merge pull request #10 from knurling-rs/harden

add stack overflow protection
This commit is contained in:
Jorge Aparicio
2020-09-25 15:24:13 +00:00
committed by GitHub
2 changed files with 26 additions and 0 deletions
+1
View File
@@ -2,6 +2,7 @@
# TODO(2) replace `$CHIP` with your chip's name (see `probe-run --list-chips` output) # TODO(2) replace `$CHIP` with your chip's name (see `probe-run --list-chips` output)
runner = "probe-run --chip $CHIP --defmt" runner = "probe-run --chip $CHIP --defmt"
rustflags = [ rustflags = [
"-C", "linker=flip-link",
"-C", "link-arg=-Tlink.x", "-C", "link-arg=-Tlink.x",
"-C", "link-arg=-Tdefmt.x", "-C", "link-arg=-Tdefmt.x",
] ]
+25
View File
@@ -0,0 +1,25 @@
#![no_main]
#![no_std]
use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
#[cortex_m_rt::entry]
fn main() -> ! {
ack(10, 10);
{{crate_name}}::exit()
}
fn ack(m: u32, n: u32) -> u32 {
defmt::info!("ack(m={:u32}, n={:u32})", m, n);
let mut big = [2; 512];
if m == 0 {
n + 1
} else {
big[100] += 1;
if n == 0 {
ack(m - 1, 1)
} else {
ack(m - 1, ack(m, n - 1))
}
}
}