aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/util.rs
diff options
context:
space:
mode:
authorGravatar Per Lindgren <per.lindgren@ltu.se> 2020-06-13 00:19:01 +0200
committerGravatar Per Lindgren <per.lindgren@ltu.se> 2020-06-13 00:19:01 +0200
commitc360ffaad8a2349a8bb210c2de2eed40d1765fd7 (patch)
tree99e056d2cec6ed5dad921f80b8876840669d90ec /macros/src/codegen/util.rs
parent3c208003f564c7f256435d1b3845bd1269a8f506 (diff)
downloadrtic-c360ffaad8a2349a8bb210c2de2eed40d1765fd7.tar.gz
rtic-c360ffaad8a2349a8bb210c2de2eed40d1765fd7.tar.zst
rtic-c360ffaad8a2349a8bb210c2de2eed40d1765fd7.zip
wip2
Diffstat (limited to 'macros/src/codegen/util.rs')
-rw-r--r--macros/src/codegen/util.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs
index 68aca5d1..d8d05453 100644
--- a/macros/src/codegen/util.rs
+++ b/macros/src/codegen/util.rs
@@ -71,13 +71,17 @@ pub fn impl_mutex(
#cfg_core
impl<'a> rtic::Mutex for #path<'a> {
type T = #ty;
-
#[inline(always)]
fn lock<R>(&mut self, f: impl FnOnce(&mut #ty) -> R) -> R {
/// Priority ceiling
const CEILING: u8 = #ceiling;
- unsafe {
+ if unsafe { self.get_locked() } {
+ panic!("Resource locked in sequential context");
+ };
+ unsafe { self.set_locked(true); }
+
+ let r = unsafe {
rtic::export::lock(
#ptr,
#priority,
@@ -85,7 +89,9 @@ pub fn impl_mutex(
#device::NVIC_PRIO_BITS,
f,
)
- }
+ };
+ unsafe { self.set_locked(false); }
+ r
}
}
)