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::{
ops,
sync::atomic::{AtomicU32, Ordering},
sync::atomic::{self, AtomicU32, Ordering},
time::Duration,
};
@ -302,6 +302,8 @@ fn RTC0() {
/// Cargo runner
pub fn exit() -> ! {
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 {
asm::bkpt()
}