diff options
Diffstat (limited to '')
49 files changed, 282 insertions, 378 deletions
diff --git a/tests/cfail/cfg-resources.rs b/tests/cfail/cfg-resources.rs index dee1485b..5e20c4de 100644 --- a/tests/cfail/cfg-resources.rs +++ b/tests/cfail/cfg-resources.rs @@ -30,35 +30,35 @@ const APP: () = { static S3: u32 = 0; #[init(resources = [O1, O4, O5, O6, S3])] - fn init() { - resources.O1; //~ ERROR no field `O1` - resources.O4; //~ ERROR no field `O4` - resources.O5; //~ ERROR no field `O5` - resources.O6; //~ ERROR no field `O6` - resources.S3; //~ ERROR no field `S3` + fn init(c: init::Context) { + c.resources.O1; //~ ERROR no field `O1` + c.resources.O4; //~ ERROR no field `O4` + c.resources.O5; //~ ERROR no field `O5` + c.resources.O6; //~ ERROR no field `O6` + c.resources.S3; //~ ERROR no field `S3` } #[idle(resources = [O2, O4, S1, S3])] - fn idle() -> ! { - resources.O2; //~ ERROR no field `O2` - resources.O4; //~ ERROR no field `O4` - resources.S1; //~ ERROR no field `S1` - resources.S3; //~ ERROR no field `S3` + fn idle(c: idle::Context) -> ! { + c.resources.O2; //~ ERROR no field `O2` + c.resources.O4; //~ ERROR no field `O4` + c.resources.S1; //~ ERROR no field `S1` + c.resources.S3; //~ ERROR no field `S3` loop {} } #[interrupt(resources = [O3, S1, S2, S3])] - fn UART0() { - resources.O3; //~ ERROR no field `O3` - resources.S1; //~ ERROR no field `S1` - resources.S2; //~ ERROR no field `S2` - resources.S3; //~ ERROR no field `S3` + fn UART0(c: UART0::Context) { + c.resources.O3; //~ ERROR no field `O3` + c.resources.S1; //~ ERROR no field `S1` + c.resources.S2; //~ ERROR no field `S2` + c.resources.S3; //~ ERROR no field `S3` } #[interrupt(resources = [S2, O5])] - fn UART1() { - resources.S2; //~ ERROR no field `S2` - resources.O5; //~ ERROR no field `O5` + fn UART1(c: UART1::Context) { + c.resources.S2; //~ ERROR no field `S2` + c.resources.O5; //~ ERROR no field `O5` } }; diff --git a/tests/cfail/cfg-static.rs b/tests/cfail/cfg-static.rs index 0d27e533..91465a1e 100644 --- a/tests/cfail/cfg-static.rs +++ b/tests/cfail/cfg-static.rs @@ -10,7 +10,7 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() { + fn init(_: init::Context) { #[cfg(never)] static mut FOO: u32 = 0; @@ -18,7 +18,7 @@ const APP: () = { } #[idle] - fn idle() -> ! { + fn idle(_: idle::Context) -> ! { #[cfg(never)] static mut FOO: u32 = 0; @@ -28,7 +28,7 @@ const APP: () = { } #[exception] - fn SVCall() { + fn SVCall(_: SVCall::Context) { #[cfg(never)] static mut FOO: u32 = 0; @@ -36,7 +36,7 @@ const APP: () = { } #[interrupt] - fn UART0() { + fn UART0(_: UART0::Context) { #[cfg(never)] static mut FOO: u32 = 0; @@ -44,7 +44,7 @@ const APP: () = { } #[task] - fn foo() { + fn foo(_: foo::Context) { #[cfg(never)] static mut FOO: u32 = 0; diff --git a/tests/cfail/duplicate-args-2.rs b/tests/cfail/duplicate-args-2.rs index 1a196e99..5bef79b5 100644 --- a/tests/cfail/duplicate-args-2.rs +++ b/tests/cfail/duplicate-args-2.rs @@ -10,13 +10,13 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[task( priority = 1, priority = 2, //~ ERROR argument appears more than once )] - fn foo() {} + fn foo(_: foo::Context) {} extern "C" { fn UART0(); diff --git a/tests/cfail/duplicate-args.rs b/tests/cfail/duplicate-args.rs index a946bae2..6938cd0d 100644 --- a/tests/cfail/duplicate-args.rs +++ b/tests/cfail/duplicate-args.rs @@ -10,13 +10,13 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[task( capacity = 1, capacity = 2, //~ ERROR argument appears more than once )] - fn foo() {} + fn foo(_: foo::Context) {} extern "C" { fn UART0(); diff --git a/tests/cfail/early-return-2.rs b/tests/cfail/early-return-2.rs deleted file mode 100644 index bf867e07..00000000 --- a/tests/cfail/early-return-2.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - static mut UNINITIALIZED: bool = (); - - #[init] - fn init() { - if false { - return; //~ ERROR `init` is *not* allowed to early return - } - - UNINITIALIZED = true; - } - - #[interrupt(resources = [UNINITIALIZED])] - fn UART0() { - if resources.UNINITIALIZED { - // UB - } - } -}; diff --git a/tests/cfail/early-return.rs b/tests/cfail/early-return.rs deleted file mode 100644 index fb695aac..00000000 --- a/tests/cfail/early-return.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - static mut UNINITIALIZED: bool = (); - - #[init] - fn init() { - let x = || { - // this is OK - return 0; - }; - - return; //~ ERROR `init` is *not* allowed to early return - - UNINITIALIZED = true; - } - - #[interrupt(resources = [UNINITIALIZED])] - fn UART0() { - if resources.UNINITIALIZED { - // UB - } - } -}; diff --git a/tests/cfail/exception-divergent.rs b/tests/cfail/exception-divergent.rs index 692a57c7..3fe9a365 100644 --- a/tests/cfail/exception-divergent.rs +++ b/tests/cfail/exception-divergent.rs @@ -10,11 +10,11 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[exception] - fn SVCall() -> ! { - //~^ ERROR `exception` handlers must have type signature `[unsafe] fn()` + fn SVCall(_: SVCall::Context) -> ! { + //~^ ERROR this `exception` handler must have type signature `fn(SVCall::Context)` loop {} } }; diff --git a/tests/cfail/exception-input.rs b/tests/cfail/exception-input.rs index cb0711ce..d1363fe5 100644 --- a/tests/cfail/exception-input.rs +++ b/tests/cfail/exception-input.rs @@ -10,10 +10,10 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[exception] - fn SVCall(undef: u32) { - //~^ ERROR `exception` handlers must have type signature `[unsafe] fn()` + fn SVCall(_: SVCall::Context, undef: u32) { + //~^ ERROR this `exception` handler must have type signature `fn(SVCall::Context)` } }; diff --git a/tests/cfail/exception-invalid.rs b/tests/cfail/exception-invalid.rs index 0a7fb520..4bb8f1ec 100644 --- a/tests/cfail/exception-invalid.rs +++ b/tests/cfail/exception-invalid.rs @@ -10,10 +10,10 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[exception] - fn NonMaskableInt() { + fn NonMaskableInt(_: NonMaskableInt::Context) { //~^ ERROR only exceptions with configurable priority can be used as hardware tasks } }; diff --git a/tests/cfail/exception-output.rs b/tests/cfail/exception-output.rs index 758dbdd7..8f672985 100644 --- a/tests/cfail/exception-output.rs +++ b/tests/cfail/exception-output.rs @@ -10,11 +10,11 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[exception] - fn SVCall() -> u32 { - //~^ ERROR `exception` handlers must have type signature `[unsafe] fn()` + fn SVCall(_: SVCall::Context) -> u32 { + //~^ ERROR this `exception` handler must have type signature `fn(SVCall::Context)` 0 } }; diff --git a/tests/cfail/exception-sys-tick.rs b/tests/cfail/exception-sys-tick.rs index 69d73dbc..d5eae20b 100644 --- a/tests/cfail/exception-sys-tick.rs +++ b/tests/cfail/exception-sys-tick.rs @@ -10,10 +10,10 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[exception] - fn SysTick() { + fn SysTick(_: SysTick::Context) { //~^ ERROR the `SysTick` exception can't be used because it's used by the runtime } }; diff --git a/tests/cfail/idle-input.rs b/tests/cfail/idle-input.rs index 5095977e..feb83e8b 100644 --- a/tests/cfail/idle-input.rs +++ b/tests/cfail/idle-input.rs @@ -10,10 +10,10 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[idle] - fn idle(undef: u32) { - //~^ ERROR `idle` must have type signature `[unsafe] fn() -> !` + fn idle(_: idle::Context, undef: u32) { + //~^ ERROR `idle` must have type signature `fn(idle::Context) -> !` } }; diff --git a/tests/cfail/idle-not-divergent.rs b/tests/cfail/idle-not-divergent.rs index e90eff08..505fba14 100644 --- a/tests/cfail/idle-not-divergent.rs +++ b/tests/cfail/idle-not-divergent.rs @@ -10,10 +10,10 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[idle] - fn idle() { - //~^ ERROR `idle` must have type signature `[unsafe] fn() -> !` + fn idle(_: idle::Context) { + //~^ ERROR `idle` must have type signature `fn(idle::Context) -> !` } }; diff --git a/tests/cfail/init-divergent.rs b/tests/cfail/init-divergent.rs index 54813d47..0e779ffc 100644 --- a/tests/cfail/init-divergent.rs +++ b/tests/cfail/init-divergent.rs @@ -10,8 +10,8 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() -> ! { - //~^ ERROR `init` must have type signature `[unsafe] fn() [-> init::LateResources]` + fn init(_: init::Context) -> ! { + //~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]` loop {} } }; diff --git a/tests/cfail/init-input.rs b/tests/cfail/init-input.rs index 3bf0cadf..9063efe3 100644 --- a/tests/cfail/init-input.rs +++ b/tests/cfail/init-input.rs @@ -10,7 +10,7 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init(undef: u32) { - //~^ ERROR `init` must have type signature `[unsafe] fn() [-> init::LateResources]` + fn init(_: init::Context, undef: u32) { + //~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]` } }; diff --git a/tests/cfail/init-not-send.rs b/tests/cfail/init-not-send.rs index 3ac495f5..5a33fac7 100644 --- a/tests/cfail/init-not-send.rs +++ b/tests/cfail/init-not-send.rs @@ -1,6 +1,5 @@ //! This is equivalent to the `late-not-send` cfail test -#![feature(extern_crate_item_prelude)] // ??? #![no_main] #![no_std] @@ -21,10 +20,10 @@ const APP: () = { static mut X: Option<NotSend> = None; #[init(resources = [X])] - fn init() { - *resources.X = Some(NotSend { _0: PhantomData }) + fn init(c: init::Context) { + *c.resources.X = Some(NotSend { _0: PhantomData }) } #[interrupt(resources = [X])] - fn UART0() {} + fn UART0(_: UART0::Context) {} }; diff --git a/tests/cfail/init-output.rs b/tests/cfail/init-output.rs index 414a35a8..f88d5340 100644 --- a/tests/cfail/init-output.rs +++ b/tests/cfail/init-output.rs @@ -10,8 +10,8 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() -> u32 { - //~^ ERROR `init` must have type signature `[unsafe] fn() [-> init::LateResources]` + fn init(_: init::Context) -> u32 { + //~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]` 0 } }; diff --git a/tests/cfail/insufficient-free-interrupts.rs b/tests/cfail/insufficient-free-interrupts.rs index baa2582b..7148fbf3 100644 --- a/tests/cfail/insufficient-free-interrupts.rs +++ b/tests/cfail/insufficient-free-interrupts.rs @@ -10,8 +10,8 @@ use rtfm::app; #[app(device = lm3s6965)] //~ ERROR 1 free interrupt (`extern { .. }`) is required const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[task] - fn foo() {} + fn foo(_: foo::Context) {} }; diff --git a/tests/cfail/interrupt-divergent.rs b/tests/cfail/interrupt-divergent.rs index 4a015330..b67601ee 100644 --- a/tests/cfail/interrupt-divergent.rs +++ b/tests/cfail/interrupt-divergent.rs @@ -10,11 +10,11 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[interrupt] - fn UART0() -> ! { - //~^ ERROR `interrupt` handlers must have type signature `[unsafe] fn()` + fn UART0(_: UART0::Context) -> ! { + //~^ ERROR this `interrupt` handler must have type signature `fn(UART0::Context)` loop {} } }; diff --git a/tests/cfail/interrupt-input.rs b/tests/cfail/interrupt-input.rs index d0240f4e..f11b2d39 100644 --- a/tests/cfail/interrupt-input.rs +++ b/tests/cfail/interrupt-input.rs @@ -10,10 +10,10 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[interrupt] - fn UART0(undef: u32) { - //~^ ERROR `interrupt` handlers must have type signature `[unsafe] fn()` + fn UART0(_: UART0::Context, undef: u32) { + //~^ ERROR this `interrupt` handler must have type signature `fn(UART0::Context)` } }; diff --git a/tests/cfail/interrupt-output.rs b/tests/cfail/interrupt-output.rs index 37cd7c21..69e4957f 100644 --- a/tests/cfail/interrupt-output.rs +++ b/tests/cfail/interrupt-output.rs @@ -10,11 +10,11 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[interrupt] - fn UART0() -> u32 { - //~^ ERROR `interrupt` handlers must have type signature `[unsafe] fn()` + fn UART0(_: UART0::Context) -> u32 { + //~^ ERROR this `interrupt` handler must have type signature `fn(UART0::Context)` 0 } }; diff --git a/tests/cfail/late-assigned-to-init.rs b/tests/cfail/late-assigned-to-init.rs index 70a361c1..00d6c8ce 100644 --- a/tests/cfail/late-assigned-to-init.rs +++ b/tests/cfail/late-assigned-to-init.rs @@ -12,5 +12,5 @@ const APP: () = { static mut X: u32 = (); #[init(resources = [X])] //~ ERROR late resources can NOT be assigned to `init` - fn init() {} + fn init(_: init::Context) {} }; diff --git a/tests/cfail/late-not-send.rs b/tests/cfail/late-not-send.rs index eb3048d9..04a4af15 100644 --- a/tests/cfail/late-not-send.rs +++ b/tests/cfail/late-not-send.rs @@ -1,7 +1,6 @@ //! `init` has a static priority of `0`. Initializing resources from it is equivalent to sending a //! message to the task that will own the resource -#![feature(extern_crate_item_prelude)] // ??? #![no_main] #![no_std] @@ -22,12 +21,12 @@ const APP: () = { static mut X: NotSend = (); #[init] - fn init() -> init::LateResources { + fn init(_: init::Context) -> init::LateResources { init::LateResources { X: NotSend { _0: PhantomData }, } } #[interrupt(resources = [X])] - fn UART0() {} + fn UART0(_: UART0::Context) {} }; diff --git a/tests/cfail/needs-send.rs b/tests/cfail/needs-send.rs index 7e3ca306..8dc9707f 100644 --- a/tests/cfail/needs-send.rs +++ b/tests/cfail/needs-send.rs @@ -1,4 +1,3 @@ -#![feature(extern_crate_item_prelude)] // ??? #![no_main] #![no_std] @@ -19,10 +18,10 @@ unsafe impl Sync for NotSend {} #[app(device = lm3s6965)] //~ ERROR cannot be sent between threads safely const APP: () = { #[init(spawn = [foo])] - fn init() {} + fn init(_: init::Context) {} #[task] - fn foo(_x: NotSend) {} + fn foo(_: foo::Context, _x: NotSend) {} extern "C" { fn UART0(); diff --git a/tests/cfail/needs-sync.rs b/tests/cfail/needs-sync.rs index f25f91a2..6025e7d5 100644 --- a/tests/cfail/needs-sync.rs +++ b/tests/cfail/needs-sync.rs @@ -1,4 +1,3 @@ -#![feature(extern_crate_item_prelude)] // ??? #![no_main] #![no_std] @@ -21,13 +20,13 @@ const APP: () = { static X: NotSync = NotSync { _0: PhantomData }; #[init(spawn = [foo])] - fn init() {} + fn init(_: init::Context) {} #[task(priority = 1, resources = [X])] - fn foo() {} + fn foo(_: foo::Context) {} #[task(priority = 2, resources = [X])] - fn bar() {} + fn bar(_: bar::Context) {} extern "C" { fn UART0(); diff --git a/tests/cfail/priority-too-high.rs b/tests/cfail/priority-too-high.rs index ec324014..817462a3 100644 --- a/tests/cfail/priority-too-high.rs +++ b/tests/cfail/priority-too-high.rs @@ -10,13 +10,13 @@ use rtfm::app; #[app(device = lm3s6965)] //~ error evaluation of constant value failed const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} // OK, this is the maximum priority supported by the device #[interrupt(priority = 8)] - fn UART0() {} + fn UART0(_: UART0::Context) {} // this value is too high! #[interrupt(priority = 9)] - fn UART1() {} + fn UART1(_: UART1::Context) {} }; diff --git a/tests/cfail/priority-too-low.rs b/tests/cfail/priority-too-low.rs index 6dcbfd63..361156df 100644 --- a/tests/cfail/priority-too-low.rs +++ b/tests/cfail/priority-too-low.rs @@ -10,13 +10,13 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} // OK, this is the minimum priority that tasks can have #[interrupt(priority = 1)] - fn UART0() {} + fn UART0(_: UART0::Context) {} // this value is too low! #[interrupt(priority = 0)] //~ error this literal must be in the range 1...255 - fn UART1() {} + fn UART1(_: UART1::Context) {} }; diff --git a/tests/cfail/resource-not-declared.rs b/tests/cfail/resource-not-declared.rs index f6d08a65..a37be42d 100644 --- a/tests/cfail/resource-not-declared.rs +++ b/tests/cfail/resource-not-declared.rs @@ -10,5 +10,5 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init(resources = [X])] //~ ERROR this resource has NOT been declared - fn init() {} + fn init(_: init::Context) {} }; diff --git a/tests/cfail/resource-pub.rs b/tests/cfail/resource-pub.rs index 970fc6cc..3fb21f46 100644 --- a/tests/cfail/resource-pub.rs +++ b/tests/cfail/resource-pub.rs @@ -13,5 +13,5 @@ const APP: () = { //~^ ERROR resources must have inherited / private visibility #[init] - fn init() {} + fn init(_: init::Context) {} }; diff --git a/tests/cfail/task-divergent.rs b/tests/cfail/task-divergent.rs index 3822d754..577f0e06 100644 --- a/tests/cfail/task-divergent.rs +++ b/tests/cfail/task-divergent.rs @@ -5,16 +5,14 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[task] - fn foo() -> ! { - //~^ ERROR `task` handlers must have type signature `[unsafe] fn(..)` + fn foo(_: foo::Context) -> ! { + //~^ ERROR this `task` handler must have type signature `fn(foo::Context, ..)` loop {} } diff --git a/tests/cfail/task-idle.rs b/tests/cfail/task-idle.rs index 62d927b9..963bf1ee 100644 --- a/tests/cfail/task-idle.rs +++ b/tests/cfail/task-idle.rs @@ -10,10 +10,10 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[task] - fn idle() { + fn idle(_: idle::Context) { //~^ ERROR `task` handlers can NOT be named `idle`, `init` or `resources` } diff --git a/tests/cfail/task-not-declared.rs b/tests/cfail/task-not-declared.rs index 3e6d87c4..04309f59 100644 --- a/tests/cfail/task-not-declared.rs +++ b/tests/cfail/task-not-declared.rs @@ -10,5 +10,5 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init(spawn = [X])] //~ ERROR this task has NOT been declared - fn init() {} + fn init(_: init::Context) {} }; diff --git a/tests/cfail/unsafe-exception.rs b/tests/cfail/unsafe-exception.rs new file mode 100644 index 00000000..353194a5 --- /dev/null +++ b/tests/cfail/unsafe-exception.rs @@ -0,0 +1,18 @@ +#![no_main] +#![no_std] + +extern crate lm3s6965; +extern crate panic_halt; +extern crate rtfm; + +use rtfm::app; + +#[app(device = lm3s6965)] +const APP: () = { + #[init] + fn init(_: init::Context) {} + + #[exception(binds = SVCall)] + unsafe fn foo(_: foo::Context) {} + //~^ ERROR this `exception` handler must have type signature `fn(foo::Context)` +}; diff --git a/tests/cfail/unsafe-idle.rs b/tests/cfail/unsafe-idle.rs new file mode 100644 index 00000000..fab1b0f1 --- /dev/null +++ b/tests/cfail/unsafe-idle.rs @@ -0,0 +1,20 @@ +#![no_main] +#![no_std] + +extern crate lm3s6965; +extern crate panic_halt; +extern crate rtfm; + +use rtfm::app; + +#[app(device = lm3s6965)] +const APP: () = { + #[init] + fn init(_: init::Context) {} + + #[idle] + unsafe fn idle(_: idle::Context) -> ! { + //~^ ERROR `idle` must have type signature `fn(idle::Context) -> !` + loop {} + } +}; diff --git a/tests/cfail/late-uninit.rs b/tests/cfail/unsafe-init.rs index 55122ed7..d8bb5605 100644 --- a/tests/cfail/late-uninit.rs +++ b/tests/cfail/unsafe-init.rs @@ -1,5 +1,3 @@ -// TODO remove in v0.5.x - #![no_main] #![no_std] @@ -11,8 +9,7 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { - static mut X: u32 = (); //~ ERROR late resources MUST be initialized at the end of `init` - #[init] - fn init() {} + unsafe fn init(_: init::Context) {} + //~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]` }; diff --git a/tests/cfail/unsafe-interrupt.rs b/tests/cfail/unsafe-interrupt.rs new file mode 100644 index 00000000..93225edf --- /dev/null +++ b/tests/cfail/unsafe-interrupt.rs @@ -0,0 +1,18 @@ +#![no_main] +#![no_std] + +extern crate lm3s6965; +extern crate panic_halt; +extern crate rtfm; + +use rtfm::app; + +#[app(device = lm3s6965)] +const APP: () = { + #[init] + fn init(_: init::Context) {} + + #[interrupt(binds = UART0)] + unsafe fn foo(_: foo::Context) {} + //~^ ERROR this `interrupt` handler must have type signature `fn(foo::Context)` +}; diff --git a/tests/cfail/unsafe-task.rs b/tests/cfail/unsafe-task.rs new file mode 100644 index 00000000..58c4d70c --- /dev/null +++ b/tests/cfail/unsafe-task.rs @@ -0,0 +1,22 @@ +#![no_main] +#![no_std] + +extern crate lm3s6965; +extern crate panic_halt; +extern crate rtfm; + +use rtfm::app; + +#[app(device = lm3s6965)] +const APP: () = { + #[init] + fn init(_: init::Context) {} + + #[task] + unsafe fn foo(_: foo::Context) {} + //~^ ERROR this `task` handler must have type signature `fn(foo::Context, ..)` + + extern "C" { + fn UART0(); + } +}; diff --git a/tests/cfail/used-free-interrupt-2.rs b/tests/cfail/used-free-interrupt-2.rs index 616d308d..ba9424fd 100644 --- a/tests/cfail/used-free-interrupt-2.rs +++ b/tests/cfail/used-free-interrupt-2.rs @@ -10,10 +10,10 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[interrupt(binds = UART0)] //~ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers - fn foo() {} + fn foo(_: foo::Context) {} extern "C" { fn UART0(); diff --git a/tests/cfail/used-free-interrupt.rs b/tests/cfail/used-free-interrupt.rs index 78ae5407..1a56741b 100644 --- a/tests/cfail/used-free-interrupt.rs +++ b/tests/cfail/used-free-interrupt.rs @@ -10,10 +10,11 @@ use rtfm::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[interrupt] - fn UART0() {} //~ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers + fn UART0(_: UART0::Context) {} + //~^ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers extern "C" { fn UART0(); diff --git a/tests/cpass/binds.rs b/tests/cpass/binds.rs index 7cb91741..897e083a 100644 --- a/tests/cpass/binds.rs +++ b/tests/cpass/binds.rs @@ -1,4 +1,6 @@ //! Check that `binds` works as advertised +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -6,18 +8,20 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[exception(binds = SVCall)] - fn foo() {} + fn foo(c: foo::Context) { + foo_trampoline(c) + } #[interrupt(binds = UART0)] - fn bar() {} + fn bar(c: bar::Context) { + bar_trampoline(c) + } }; #[allow(dead_code)] diff --git a/tests/cpass/cfg.rs b/tests/cpass/cfg.rs index c91ab604..a0b6a870 100644 --- a/tests/cpass/cfg.rs +++ b/tests/cpass/cfg.rs @@ -6,24 +6,22 @@ #![no_std] extern crate lm3s6965; -extern crate panic_semihosting; +extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[cfg(never)] static mut FOO: u32 = 0; #[init] - fn init() { + fn init(_: init::Context) { #[cfg(never)] static mut BAR: u32 = 0; } #[idle] - fn idle() -> ! { + fn idle(_: idle::Context) -> ! { #[cfg(never)] static mut BAR: u32 = 0; @@ -31,20 +29,20 @@ const APP: () = { } #[task(resources = [FOO], schedule = [quux], spawn = [quux])] - fn foo() { + fn foo(_: foo::Context) { #[cfg(never)] static mut BAR: u32 = 0; } #[task(priority = 3, resources = [FOO], schedule = [quux], spawn = [quux])] - fn bar() { + fn bar(_: bar::Context) { #[cfg(never)] static mut BAR: u32 = 0; } #[cfg(never)] #[task] - fn quux() {} + fn quux(_: quux::Context) {} extern "C" { fn UART0(); diff --git a/tests/cpass/late-not-send.rs b/tests/cpass/late-not-send.rs index 5b278ab5..0f690967 100644 --- a/tests/cpass/late-not-send.rs +++ b/tests/cpass/late-not-send.rs @@ -1,3 +1,5 @@ +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -7,20 +9,18 @@ extern crate rtfm; use core::marker::PhantomData; -use rtfm::app; - pub struct NotSend { _0: PhantomData<*const ()>, } -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { static mut X: NotSend = (); static mut Y: Option<NotSend> = None; #[init(resources = [Y])] - fn init() -> init::LateResources { - *resources.Y = Some(NotSend { _0: PhantomData }); + fn init(c: init::Context) -> init::LateResources { + *c.resources.Y = Some(NotSend { _0: PhantomData }); init::LateResources { X: NotSend { _0: PhantomData }, @@ -28,7 +28,7 @@ const APP: () = { } #[idle(resources = [X, Y])] - fn idle() -> ! { + fn idle(_: idle::Context) -> ! { loop {} } }; diff --git a/tests/cpass/late-resource.rs b/tests/cpass/late-resource.rs index 0dec4cbe..37dcf331 100644 --- a/tests/cpass/late-resource.rs +++ b/tests/cpass/late-resource.rs @@ -1,4 +1,6 @@ //! Runtime initialized resources +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -6,15 +8,13 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { static mut X: u32 = (); static Y: u32 = (); #[init] - fn init() -> init::LateResources { + fn init(_: init::Context) -> init::LateResources { init::LateResources { X: 0, Y: 1 } } }; diff --git a/tests/cpass/peripheral.rs b/tests/cpass/peripheral.rs index 509a6be1..34352b84 100644 --- a/tests/cpass/peripheral.rs +++ b/tests/cpass/peripheral.rs @@ -1,4 +1,6 @@ //! Core and device peripherals +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -6,13 +8,11 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[init] - fn init() { - let _: rtfm::Peripherals = core; - let _: lm3s6965::Peripherals = device; + fn init(c: init::Context) { + let _: rtfm::Peripherals = c.core; + let _: lm3s6965::Peripherals = c.device; } }; diff --git a/tests/cpass/resource.rs b/tests/cpass/resource.rs index bb837393..4e92a032 100644 --- a/tests/cpass/resource.rs +++ b/tests/cpass/resource.rs @@ -1,5 +1,7 @@ //! Check code generation of resources +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -7,9 +9,9 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::{app, Exclusive}; +use rtfm::Exclusive; -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { static mut O1: u32 = 0; // init static mut O2: u32 = 0; // idle @@ -23,57 +25,57 @@ const APP: () = { static S3: u32 = 0; #[init(resources = [O1, O4, O5, O6, S3])] - fn init() { + fn init(c: init::Context) { // owned by `init` == `&'static mut` - let _: &'static mut u32 = resources.O1; + let _: &'static mut u32 = c.resources.O1; // owned by `init` == `&'static` if read-only - let _: &'static u32 = resources.O6; + let _: &'static u32 = c.resources.O6; // `init` has exclusive access to all resources - let _: &mut u32 = resources.O4; - let _: &mut u32 = resources.O5; - let _: &mut u32 = resources.S3; + let _: &mut u32 = c.resources.O4; + let _: &mut u32 = c.resources.O5; + let _: &mut u32 = c.resources.S3; } #[idle(resources = [O2, O4, S1, S3])] - fn idle() -> ! { + fn idle(mut c: idle::Context) -> ! { // owned by `idle` == `&'static mut` - let _: &'static mut u32 = resources.O2; + let _: &'static mut u32 = c.resources.O2; // owned by `idle` == `&'static` if read-only - let _: &'static u32 = resources.O4; + let _: &'static u32 = c.resources.O4; // shared with `idle` == `Mutex` - resources.S1.lock(|_| {}); + c.resources.S1.lock(|_| {}); // `&` if read-only - let _: &u32 = resources.S3; + let _: &u32 = c.resources.S3; loop {} } #[interrupt(resources = [O3, S1, S2, S3])] - fn UART0() { + fn UART0(c: UART0::Context) { // owned by interrupt == `&mut` - let _: &mut u32 = resources.O3; + let _: &mut u32 = c.resources.O3; // no `Mutex` proxy when access from highest priority task - let _: Exclusive<u32> = resources.S1; + let _: Exclusive<u32> = c.resources.S1; // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: Exclusive<u32> = resources.S2; + let _: Exclusive<u32> = c.resources.S2; // `&` if read-only - let _: &u32 = resources.S3; + let _: &u32 = c.resources.S3; } #[interrupt(resources = [S2, O5])] - fn UART1() { + fn UART1(c: UART1::Context) { // owned by interrupt == `&` if read-only - let _: &u32 = resources.O5; + let _: &u32 = c.resources.O5; // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: Exclusive<u32> = resources.S2; + let _: Exclusive<u32> = c.resources.S2; } }; diff --git a/tests/cpass/schedule.rs b/tests/cpass/schedule.rs index 0728d8b3..346f9124 100644 --- a/tests/cpass/schedule.rs +++ b/tests/cpass/schedule.rs @@ -1,3 +1,5 @@ +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -5,52 +7,52 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::{app, Instant}; +use rtfm::Instant; -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[init(schedule = [foo, bar, baz])] - fn init() { - let _: Result<(), ()> = schedule.foo(start + 10.cycles()); - let _: Result<(), u32> = schedule.bar(start + 20.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(start + 30.cycles(), 0, 1); + fn init(c: init::Context) { + let _: Result<(), ()> = c.schedule.foo(c.start + 10.cycles()); + let _: Result<(), u32> = c.schedule.bar(c.start + 20.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 30.cycles(), 0, 1); } #[idle(schedule = [foo, bar, baz])] - fn idle() -> ! { - let _: Result<(), ()> = schedule.foo(Instant::now() + 40.cycles()); - let _: Result<(), u32> = schedule.bar(Instant::now() + 50.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(Instant::now() + 60.cycles(), 0, 1); + fn idle(c: idle::Context) -> ! { + let _: Result<(), ()> = c.schedule.foo(Instant::now() + 40.cycles()); + let _: Result<(), u32> = c.schedule.bar(Instant::now() + 50.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(Instant::now() + 60.cycles(), 0, 1); loop {} } #[exception(schedule = [foo, bar, baz])] - fn SVCall() { - let _: Result<(), ()> = schedule.foo(start + 70.cycles()); - let _: Result<(), u32> = schedule.bar(start + 80.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(start + 90.cycles(), 0, 1); + fn SVCall(c: SVCall::Context) { + let _: Result<(), ()> = c.schedule.foo(c.start + 70.cycles()); + let _: Result<(), u32> = c.schedule.bar(c.start + 80.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 90.cycles(), 0, 1); } #[interrupt(schedule = [foo, bar, baz])] - fn UART0() { - let _: Result<(), ()> = schedule.foo(start + 100.cycles()); - let _: Result<(), u32> = schedule.bar(start + 110.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(start + 120.cycles(), 0, 1); + fn UART0(c: UART0::Context) { + let _: Result<(), ()> = c.schedule.foo(c.start + 100.cycles()); + let _: Result<(), u32> = c.schedule.bar(c.start + 110.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 120.cycles(), 0, 1); } #[task(schedule = [foo, bar, baz])] - fn foo() { - let _: Result<(), ()> = schedule.foo(scheduled + 130.cycles()); - let _: Result<(), u32> = schedule.bar(scheduled + 140.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(scheduled + 150.cycles(), 0, 1); + fn foo(c: foo::Context) { + let _: Result<(), ()> = c.schedule.foo(c.scheduled + 130.cycles()); + let _: Result<(), u32> = c.schedule.bar(c.scheduled + 140.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(c.scheduled + 150.cycles(), 0, 1); } #[task] - fn bar(_x: u32) {} + fn bar(_: bar::Context, _x: u32) {} #[task] - fn baz(_x: u32, _y: u32) {} + fn baz(_: baz::Context, _x: u32, _y: u32) {} extern "C" { fn UART1(); diff --git a/tests/cpass/singleton.rs b/tests/cpass/singleton.rs deleted file mode 100644 index d50f8523..00000000 --- a/tests/cpass/singleton.rs +++ /dev/null @@ -1,66 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate owned_singleton; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::{app, Exclusive}; - -#[app(device = lm3s6965)] -const APP: () = { - #[Singleton] - static mut O1: u32 = 0; - #[Singleton] - static mut O2: u32 = 0; - #[Singleton] - static mut O3: u32 = 0; - #[Singleton] - static O4: u32 = 0; - #[Singleton] - static O5: u32 = 0; - #[Singleton] - static O6: u32 = 0; - - #[Singleton] - static mut S1: u32 = 0; - #[Singleton] - static S2: u32 = 0; - - #[init(resources = [O1, O2, O3, O4, O5, O6, S1, S2])] - fn init() { - let _: O1 = resources.O1; - let _: &mut O2 = resources.O2; - let _: &mut O3 = resources.O3; - let _: O4 = resources.O4; - let _: &mut O5 = resources.O5; - let _: &mut O6 = resources.O6; - - let _: &mut S1 = resources.S1; - let _: &mut S2 = resources.S2; - } - - #[idle(resources = [O2, O5])] - fn idle() -> ! { - let _: O2 = resources.O2; - let _: O5 = resources.O5; - - loop {} - } - - #[interrupt(resources = [O3, O6, S1, S2])] - fn UART0() { - let _: &mut O3 = resources.O3; - let _: &O6 = resources.O6; - - let _: Exclusive<S1> = resources.S1; - let _: &S2 = resources.S2; - } - - #[interrupt(resources = [S1, S2])] - fn UART1() { - let _: Exclusive<S1> = resources.S1; - let _: &S2 = resources.S2; - } -}; diff --git a/tests/cpass/spawn.rs b/tests/cpass/spawn.rs index 3df606a4..0a27c4f6 100644 --- a/tests/cpass/spawn.rs +++ b/tests/cpass/spawn.rs @@ -1,4 +1,6 @@ //! Check code generation of `spawn` +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -6,52 +8,50 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[init(spawn = [foo, bar, baz])] - fn init() { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn init(c: init::Context) { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); } #[idle(spawn = [foo, bar, baz])] - fn idle() -> ! { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn idle(c: idle::Context) -> ! { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); loop {} } #[exception(spawn = [foo, bar, baz])] - fn SVCall() { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn SVCall(c: SVCall::Context) { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); } #[interrupt(spawn = [foo, bar, baz])] - fn UART0() { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn UART0(c: UART0::Context) { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); } #[task(spawn = [foo, bar, baz])] - fn foo() { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn foo(c: foo::Context) { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); } #[task] - fn bar(_x: u32) {} + fn bar(_: bar::Context, _x: u32) {} #[task] - fn baz(_x: u32, _y: u32) {} + fn baz(_: baz::Context, _x: u32, _y: u32) {} extern "C" { fn UART1(); diff --git a/tests/cpass/unsafe.rs b/tests/cpass/unsafe.rs deleted file mode 100644 index b6996ad1..00000000 --- a/tests/cpass/unsafe.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! Check code generation of `unsafe` `init` / `idle` / `exception` / `interrupt` / `task` -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -unsafe fn foo() {} - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - unsafe fn init() { - foo(); - } - - #[idle] - unsafe fn idle() -> ! { - foo(); - - loop {} - } - - #[exception] - unsafe fn SVCall() { - foo(); - } - - #[interrupt] - unsafe fn UART0() { - foo(); - } - - #[task] - unsafe fn bar() { - foo(); - } - - extern "C" { - fn UART1(); - } -}; |