diff options
author | 2020-06-13 00:19:01 +0200 | |
---|---|---|
committer | 2020-06-13 00:19:01 +0200 | |
commit | c360ffaad8a2349a8bb210c2de2eed40d1765fd7 (patch) | |
tree | 99e056d2cec6ed5dad921f80b8876840669d90ec /macros/src/codegen/util.rs | |
parent | 3c208003f564c7f256435d1b3845bd1269a8f506 (diff) | |
download | rtic-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.rs | 12 |
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 } } ) |