From 2b8e743f35a69b9b09a4de4c346eb9015c6b45ea Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 16 Feb 2019 00:22:00 +0100 Subject: make debug builds reproducible --- src/export.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/export.rs b/src/export.rs index ed40b62..0d74661 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, +} + +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 { @@ -102,7 +125,7 @@ where #[inline(always)] pub unsafe fn claim( ptr: *mut T, - priority: &Cell, + priority: &Priority, ceiling: u8, nvic_prio_bits: u8, f: F, @@ -135,7 +158,7 @@ where #[inline(always)] pub unsafe fn claim( ptr: *mut T, - priority: &Cell, + priority: &Priority, ceiling: u8, _nvic_prio_bits: u8, f: F, -- cgit v1.2.3 From 7ce052be372ad5e3671e4f470ac552db075162fb Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 16 Feb 2019 00:26:07 +0100 Subject: cargo fmt --- macros/src/check.rs | 8 ++++---- src/export.rs | 4 +++- tests/compiletest.rs | 22 ++++++++++------------ 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/macros/src/check.rs b/macros/src/check.rs index 045d152..464e280 100644 --- a/macros/src/check.rs +++ b/macros/src/check.rs @@ -38,10 +38,10 @@ pub fn app(app: &App) -> parse::Result<()> { // Check that all late resources have been initialized in `#[init]` if `init` has signature // `fn()` if !app.init.returns_late_resources { - for res in app - .resources - .iter() - .filter_map(|(name, res)| if res.expr.is_none() { Some(name) } else { None }) + for res in + app.resources + .iter() + .filter_map(|(name, res)| if res.expr.is_none() { Some(name) } else { None }) { if app.init.assigns.iter().all(|assign| assign.left != *res) { return Err(parse::Error::new( diff --git a/src/export.rs b/src/export.rs index 0d74661..6eae65f 100644 --- a/src/export.rs +++ b/src/export.rs @@ -47,7 +47,9 @@ pub struct Priority { impl Priority { #[inline(always)] pub unsafe fn new(value: u8) -> Self { - Priority { inner: Cell::new(value)} + Priority { + inner: Cell::new(value), + } } // these two methods are used by claim (see below) but can't be used from the RTFM application diff --git a/tests/compiletest.rs b/tests/compiletest.rs index acc8954..58702ee 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -38,18 +38,16 @@ fn cfail() { let f = f.unwrap().path(); let name = f.file_stem().unwrap().to_str().unwrap(); - assert!( - Command::new("rustc") - .args(s.split_whitespace()) - .arg(f.display().to_string()) - .arg("-o") - .arg(td.path().join(name).display().to_string()) - .arg("-C") - .arg("linker=true") - .status() - .unwrap() - .success() - ); + assert!(Command::new("rustc") + .args(s.split_whitespace()) + .arg(f.display().to_string()) + .arg("-o") + .arg(td.path().join(name).display().to_string()) + .arg("-C") + .arg("linker=true") + .status() + .unwrap() + .success()); } config.target_rustcflags = Some(s); -- cgit v1.2.3