From bc10fe266d7a3fbae0235cee23d62f75877bf6c4 Mon Sep 17 00:00:00 2001 From: Conor Patrick Date: Sun, 18 Apr 2021 14:35:11 -0700 Subject: [PATCH] reclaim stack space used in init --- macros/src/codegen.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index cf728a7d3f..21db14389c 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -66,9 +66,17 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { #(#pre_init_stmts)* - #call_init + #[inline(never)] + fn __rtic_init_resources(f: F) where F: FnOnce() { + f(); + } - #(#post_init_stmts)* + // Wrap late_init_stmts in a function to ensure that stack space is reclaimed. + __rtic_init_resources(||{ + #call_init + + #(#post_init_stmts)* + }); #call_idle }