add a compiler fence before exiting

the rtt-target implementation is light on compiler fences so the compiler could
be doing unwanted reordering of memory operations. At least patch up a place
where these orderings may result in an observable change of behavior
This commit is contained in:
Jorge Aparicio 2020-06-24 17:20:42 +02:00
parent 9c1e496ef5
commit 80cb2caa09

View file

@ -6,7 +6,7 @@
use core::{ use core::{
ops, ops,
sync::atomic::{AtomicU32, Ordering}, sync::atomic::{self, AtomicU32, Ordering},
time::Duration, time::Duration,
}; };
@ -302,6 +302,8 @@ fn RTC0() {
/// Cargo runner /// Cargo runner
pub fn exit() -> ! { pub fn exit() -> ! {
log::info!("`dk::exit() called; exiting ...`"); log::info!("`dk::exit() called; exiting ...`");
// force any pending memory operation to complete before the BKPT instruction that follows
atomic::compiler_fence(Ordering::SeqCst);
loop { loop {
asm::bkpt() asm::bkpt()
} }