diff options
author | 2021-11-03 08:45:53 +0000 | |
---|---|---|
committer | 2021-11-03 08:45:53 +0000 | |
commit | 7155b55ac8ff4e5f8860bd6f81c39d31756af633 (patch) | |
tree | 82d4de23a49ece531207b2ac065e371bb9fd20f1 /macros/src/codegen/post_init.rs | |
parent | b25d775771f7ecc4fdfc5a2faaeb52e63cc344c9 (diff) | |
parent | 9e24fcbbd90609a25b9d985f9292900b476fe5ea (diff) | |
download | rtic-7155b55ac8ff4e5f8860bd6f81c39d31756af633.tar.gz rtic-7155b55ac8ff4e5f8860bd6f81c39d31756af633.tar.zst rtic-7155b55ac8ff4e5f8860bd6f81c39d31756af633.zip |
Merge #548
548: Fixed aliasing issue due to RacyCell implementation r=perlindgren a=korken89
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Co-authored-by: Per Lindgren <per.lindgren@ltu.se>
Diffstat (limited to 'macros/src/codegen/post_init.rs')
-rw-r--r-- | macros/src/codegen/post_init.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs index 5624b20a..07fbd03c 100644 --- a/macros/src/codegen/post_init.rs +++ b/macros/src/codegen/post_init.rs @@ -19,10 +19,9 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> { // We include the cfgs #(#cfgs)* // Resource is a RacyCell<MaybeUninit<T>> - // - `get_mut_unchecked` to obtain `MaybeUninit<T>` - // - `as_mut_ptr` to obtain a raw pointer to `MaybeUninit<T>` + // - `get_mut` to obtain a raw pointer to `MaybeUninit<T>` // - `write` the defined value for the late resource T - #mangled_name.get_mut_unchecked().as_mut_ptr().write(shared_resources.#name); + #mangled_name.get_mut().write(core::mem::MaybeUninit::new(shared_resources.#name)); )); } } @@ -37,10 +36,9 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> { // We include the cfgs #(#cfgs)* // Resource is a RacyCell<MaybeUninit<T>> - // - `get_mut_unchecked` to obtain `MaybeUninit<T>` - // - `as_mut_ptr` to obtain a raw pointer to `MaybeUninit<T>` + // - `get_mut` to obtain a raw pointer to `MaybeUninit<T>` // - `write` the defined value for the late resource T - #mangled_name.get_mut_unchecked().as_mut_ptr().write(local_resources.#name); + #mangled_name.get_mut().write(core::mem::MaybeUninit::new(local_resources.#name)); )); } } @@ -58,7 +56,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> { // Store the monotonic let name = util::monotonic_ident(&monotonic.to_string()); - stmts.push(quote!(*#name.get_mut_unchecked() = Some(monotonics.#idx);)); + stmts.push(quote!(#name.get_mut().write(Some(monotonics.#idx));)); } // Enable the interrupts -- this completes the `init`-ialization phase |