diff options
author | 2019-02-15 23:39:28 +0000 | |
---|---|---|
committer | 2019-02-15 23:39:28 +0000 | |
commit | c91b14bcd49f05ea40617dbd3166afa63234cb91 (patch) | |
tree | 1a7c65d4a68619966e4a133dd165de7a3ec64c6b /src | |
parent | fdba26525c4a190d0275dd3b5f3a154fa189a799 (diff) | |
parent | e5e54ee8f1b7afca614f642ee064a7f00a1f8548 (diff) | |
download | rtic-c91b14bcd49f05ea40617dbd3166afa63234cb91.tar.gz rtic-c91b14bcd49f05ea40617dbd3166afa63234cb91.tar.zst rtic-c91b14bcd49f05ea40617dbd3166afa63234cb91.zip |
Merge #151
151: make builds reproducible r=japaric a=japaric
This is a rebased and augmented version of #132. With this PR both dev and release builds that do not use the owned-singleton stuff become reproducible. (I haven't really bothered to make owned-singleton reproducible since [lifo] is way more ergonomic than [alloc-singleton] and will eventually make its way into heapless).
[lifo]: https://github.com/japaric/lifo
[alloc-singleton]: https://crates.io/crates/alloc-singleton
Thanks @hugwijst for doing the bulk of the work!
closes #132
Co-authored-by: Hugo van der Wijst <hvanderwijst@tesla.com>
Co-authored-by: Hugo van der Wijst <hugo@wij.st>
Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/export.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/export.rs b/src/export.rs index ed40b621..6eae65f2 100644 --- a/src/export.rs +++ b/src/export.rs @@ -39,6 +39,31 @@ 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 +127,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 +160,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, |