aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 95aa8ba..7cd0ff6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -105,7 +105,9 @@ where
lock_check(ceiling);
let old_basepri = basepri::read();
basepri_max::write(ceiling);
+ compiler_barrier();
let ret = f(&*res, ptr::read(0 as *const _));
+ compiler_barrier();
basepri::write(old_basepri);
ret
}
@@ -121,11 +123,23 @@ where
lock_check(ceiling);
let old_basepri = basepri::read();
basepri_max::write(ceiling);
+ compiler_barrier();
let ret = f(&mut *res, ptr::read(0 as *const _));
+ compiler_barrier();
basepri::write(old_basepri);
ret
}
+fn compiler_barrier() {
+ unsafe {
+ asm!(""
+ :
+ :
+ : "memory"
+ : "volatile");
+ }
+}
+
/// A peripheral as a resource
pub struct ResourceP<P, Ceiling>
where