diff options
author | 2017-04-14 00:33:07 -0500 | |
---|---|---|
committer | 2017-04-14 00:33:07 -0500 | |
commit | c6bf89a31874839f22f9de823f874133b9746ce3 (patch) | |
tree | 67b62b72b1fb5a225a64a4b179fa66615a1d0add | |
parent | bf17ee7422d4ebf55b6eeafea6f6a74cabe2441a (diff) | |
download | rtic-c6bf89a31874839f22f9de823f874133b9746ce3.tar.gz rtic-c6bf89a31874839f22f9de823f874133b9746ce3.tar.zst rtic-c6bf89a31874839f22f9de823f874133b9746ce3.zip |
remove unnecessary trait bounds
-rw-r--r-- | build.rs | 2 | ||||
-rw-r--r-- | src/lib.rs | 37 | ||||
-rw-r--r-- | tests/cfail/tasks-wrong-init.rs | 4 |
3 files changed, 15 insertions, 28 deletions
@@ -40,7 +40,7 @@ fn main() { ); // Ceilings - for i in 1..(1 << bits) + 1 { + for i in 0..(1 << bits) + 1 { let c = Ident::new(format!("C{}", i)); let u = Ident::new(format!("U{}", i)); @@ -1,3 +1,6 @@ +//! Stack Resource Policy + +#![deny(missing_docs)] #![deny(warnings)] #![feature(asm)] #![feature(const_fn)] @@ -52,10 +55,7 @@ impl<T, C> Resource<T, C> { } } -impl<T, CEILING> Resource<T, C<CEILING>> -where - C<CEILING>: Ceiling, -{ +impl<T, CEILING> Resource<T, C<CEILING>> { /// Borrows the resource for the duration of another resource's critical /// section /// @@ -68,7 +68,6 @@ where where SCEILING: GreaterThanOrEqual<CEILING>, CEILING: GreaterThanOrEqual<PRIORITY>, - P<PRIORITY>: Priority, { unsafe { &*self.data.get() } } @@ -82,7 +81,6 @@ where ) -> &'task T where CEILING: Cmp<PRIORITY, Output = Equal>, - P<PRIORITY>: Priority, { unsafe { &*self.data.get() } } @@ -95,7 +93,6 @@ where ) -> &'task mut T where CEILING: Cmp<PRIORITY, Output = Equal>, - P<PRIORITY>: Priority, { unsafe { &mut *self.data.get() } } @@ -117,10 +114,8 @@ where ) -> R where F: FnOnce(&T, C<CEILING>) -> R, - C<CEILING>: Ceiling, CEILING: Cmp<PRIORITY, Output = Greater> + Cmp<UMAX, Output = Less> + Level, - P<PRIORITY>: Priority, { unsafe { let old_basepri = basepri::read(); @@ -147,10 +142,8 @@ where ) -> R where F: FnOnce(&mut T) -> R, - C<CEILING>: Ceiling, CEILING: Cmp<PRIORITY, Output = Greater> + Cmp<UMAX, Output = Less> + Level, - P<PRIORITY>: Priority, { unsafe { let old_basepri = basepri::read(); @@ -164,9 +157,9 @@ where } } -unsafe impl<T, CEILING> Sync for Resource<T, CEILING> +unsafe impl<T, C> Sync for Resource<T, C> where - CEILING: Ceiling, + C: Ceiling, { } @@ -197,10 +190,7 @@ where } } -impl<Periph, CEILING> Peripheral<Periph, C<CEILING>> -where - C<CEILING>: Ceiling, -{ +impl<Periph, CEILING> Peripheral<Periph, C<CEILING>> { /// See [Resource.borrow](./struct.Resource.html#method.borrow) pub fn borrow<'cs, PRIORITY, SCEILING>( &'static self, @@ -221,7 +211,6 @@ where ) -> &'task Periph where CEILING: Cmp<PRIORITY, Output = Equal>, - P<PRIORITY>: Priority, { unsafe { &*self.peripheral.get() } } @@ -235,10 +224,8 @@ where ) -> R where F: FnOnce(&Periph, C<CEILING>) -> R, - C<CEILING>: Ceiling, CEILING: Cmp<PRIORITY, Output = Greater> + Cmp<UMAX, Output = Less> + Level, - P<PRIORITY>: Priority, { unsafe { let old_basepri = basepri::read(); @@ -279,7 +266,7 @@ where r } -/// Requests the execution of the task `task` +/// Requests the execution of a `task` pub fn request<T, P>(_task: fn(T, P)) where T: Context + Nr, @@ -320,12 +307,13 @@ impl<T> P<T> where T: Level, { + #[doc(hidden)] pub fn hw() -> u8 { T::hw() } } -/// A valid ceiling +/// A valid resource ceiling /// /// DO NOT IMPLEMENT THIS TRAIT YOURSELF pub unsafe trait Ceiling {} @@ -339,10 +327,11 @@ pub unsafe trait GreaterThanOrEqual<RHS> {} /// /// DO NOT IMPLEMENT THIS TRAIT YOURSELF pub unsafe trait Level { + /// Interrupt hardware level fn hw() -> u8; } -/// A valid priority level +/// A valid task priority /// /// DO NOT IMPLEMENT THIS TRAIT YOURSELF pub unsafe trait Priority {} @@ -354,8 +343,6 @@ fn logical2hw(logical: u8) -> u8 { /// Priority 0, the lowest priority pub type P0 = P<::typenum::U0>; -unsafe impl Priority for P0 {} - /// Declares tasks #[macro_export] macro_rules! tasks { diff --git a/tests/cfail/tasks-wrong-init.rs b/tests/cfail/tasks-wrong-init.rs index 73c47224..368772fd 100644 --- a/tests/cfail/tasks-wrong-init.rs +++ b/tests/cfail/tasks-wrong-init.rs @@ -14,8 +14,8 @@ tasks!(device, { j1: (Exti0, P1), }); -// WRONG. `init` must have signature `fn(C16)` -fn init(_: C1) {} +// WRONG. `init` must have signature `fn(P0, C16)` +fn init(_: P0, _: C1) {} fn idle(_: P0) {} |