From e2bde8d21acdfb845554d960536bfb94a7bb1f86 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 27 Apr 2017 19:06:22 -0500 Subject: make the ceiling part of the task signature remove the P.as_ceiling method --- src/lib.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 3d08402d..aeb29e0b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -436,7 +436,7 @@ extern crate typenum; use core::cell::UnsafeCell; use core::marker::PhantomData; -use core::{mem, ptr}; +use core::ptr; use cortex_m::ctxt::Context; use cortex_m::interrupt::Nr; @@ -612,7 +612,7 @@ where /// Disables a `task` /// /// The task won't run even if the underlying interrupt is raised -pub fn disable(_task: fn(T, P)) +pub fn disable(_task: fn(T, P, C)) where T: Context + Nr, { @@ -624,7 +624,7 @@ where } /// Enables a `task` -pub fn enable(_task: fn(T, P)) +pub fn enable(_task: fn(T, P, C)) where T: Context + Nr, { @@ -655,7 +655,7 @@ pub fn logical2hw(logical: u8) -> u8 { } /// Requests the execution of a `task` -pub fn request(_task: fn(T, P)) +pub fn request(_task: fn(T, P, C)) where T: Context + Nr, { @@ -719,15 +719,6 @@ pub struct P { _marker: PhantomData, } -impl P { - /// Turns this priority into a ceiling - pub fn as_ceiling(&self) -> &C { - unsafe { - mem::transmute(self) - } - } -} - impl P where T: Unsigned, @@ -885,11 +876,12 @@ macro_rules! tasks { enable_tasks(); }); - fn validate_signature(_: fn($crate::P0) -> !) {} + fn validate_signature(_: fn($crate::P0, $crate::C0) -> !) {} validate_signature(idle); let p0 = unsafe { ::core::mem::transmute::<_, P0>(()) }; - idle(p0); + let c0 = unsafe { ::core::mem::transmute::<_, C0>(()) }; + idle(p0, c0); fn set_priorities() { // NOTE(safe) this function runs in an interrupt free context @@ -931,11 +923,19 @@ macro_rules! tasks { extern "C" fn $task( task: ::$device::interrupt::$Interrupt ) { + fn validate_signature( + _: fn(::$device::interrupt::$Interrupt, + $crate::P, + $crate::C)) {} + validate_signature(::$task); let p = unsafe { ::core::mem::transmute::<_, $crate::$P>(()) }; + let c = unsafe { + ::core::mem::transmute(()) + }; $crate::_validate_priority(&p); - ::$task(task, p) + ::$task(task, p, c) } $task -- cgit v1.2.3