aboutsummaryrefslogtreecommitdiff
path: root/src/export.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2019-02-16 00:22:00 +0100
committerGravatar Jorge Aparicio <jorge@japaric.io> 2019-02-16 00:25:48 +0100
commit2b8e743f35a69b9b09a4de4c346eb9015c6b45ea (patch)
tree3e13dd99d74b7da1c6cab345cb678299af2d0e93 /src/export.rs
parentcf05dc2c4b2bb702be4807867610dfedcc02d6f2 (diff)
downloadrtic-2b8e743f35a69b9b09a4de4c346eb9015c6b45ea.tar.gz
rtic-2b8e743f35a69b9b09a4de4c346eb9015c6b45ea.tar.zst
rtic-2b8e743f35a69b9b09a4de4c346eb9015c6b45ea.zip
make debug builds reproducible
Diffstat (limited to 'src/export.rs')
-rw-r--r--src/export.rs27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/export.rs b/src/export.rs
index ed40b621..0d746614 100644
--- a/src/export.rs
+++ b/src/export.rs
@@ -39,6 +39,29 @@ where
f();
}
+// Newtype over `Cell` that forbids mutation through a shared reference
+pub struct Priority {
+ inner: Cell<u8>,
+}
+
+impl Priority {
+ #[inline(always)]
+ pub unsafe fn new(value: u8) -> Self {
+ Priority { inner: Cell::new(value)}
+ }
+
+ // these two methods are used by claim (see below) but can't be used from the RTFM application
+ #[inline(always)]
+ fn set(&self, value: u8) {
+ self.inner.set(value)
+ }
+
+ #[inline(always)]
+ fn get(&self) -> u8 {
+ self.inner.get()
+ }
+}
+
// TODO(MaybeUninit) Until core::mem::MaybeUninit is stabilized we use our own (inefficient)
// implementation
pub struct MaybeUninit<T> {
@@ -102,7 +125,7 @@ where
#[inline(always)]
pub unsafe fn claim<T, R, F>(
ptr: *mut T,
- priority: &Cell<u8>,
+ priority: &Priority,
ceiling: u8,
nvic_prio_bits: u8,
f: F,
@@ -135,7 +158,7 @@ where
#[inline(always)]
pub unsafe fn claim<T, R, F>(
ptr: *mut T,
- priority: &Cell<u8>,
+ priority: &Priority,
ceiling: u8,
_nvic_prio_bits: u8,
f: F,