From 81275bfa4f41e2066770087f3a33cad4227eab41 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 13 Jun 2019 23:56:59 +0200 Subject: rtfm-syntax refactor + heterogeneous multi-core support --- examples/t-late-not-send.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 examples/t-late-not-send.rs (limited to 'examples/t-late-not-send.rs') diff --git a/examples/t-late-not-send.rs b/examples/t-late-not-send.rs new file mode 100644 index 0000000..55a053d --- /dev/null +++ b/examples/t-late-not-send.rs @@ -0,0 +1,36 @@ +//! [compile-pass] late resources don't need to be `Send` if they are owned by `idle` + +#![no_main] +#![no_std] + +use core::marker::PhantomData; + +use panic_halt as _; + +pub struct NotSend { + _0: PhantomData<*const ()>, +} + +#[rtfm::app(device = lm3s6965)] +const APP: () = { + extern "C" { + static mut X: NotSend; + } + + static mut Y: Option = None; + + #[init(resources = [Y])] + fn init(c: init::Context) -> init::LateResources { + // equivalent to late resource initialization + *c.resources.Y = Some(NotSend { _0: PhantomData }); + + init::LateResources { + X: NotSend { _0: PhantomData }, + } + } + + #[idle(resources = [X, Y])] + fn idle(_: idle::Context) -> ! { + loop {} + } +}; -- cgit v1.2.3 From 9195038c87703fc94b6e99f6de593886d51c2b19 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 10 Jul 2019 22:42:44 +0200 Subject: implement RFC #212 --- examples/t-late-not-send.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'examples/t-late-not-send.rs') diff --git a/examples/t-late-not-send.rs b/examples/t-late-not-send.rs index 55a053d..4fd3504 100644 --- a/examples/t-late-not-send.rs +++ b/examples/t-late-not-send.rs @@ -13,23 +13,23 @@ pub struct NotSend { #[rtfm::app(device = lm3s6965)] const APP: () = { - extern "C" { - static mut X: NotSend; + struct Resources { + x: NotSend, + #[init(None)] + y: Option, } - static mut Y: Option = None; - - #[init(resources = [Y])] + #[init(resources = [y])] fn init(c: init::Context) -> init::LateResources { // equivalent to late resource initialization - *c.resources.Y = Some(NotSend { _0: PhantomData }); + *c.resources.y = Some(NotSend { _0: PhantomData }); init::LateResources { - X: NotSend { _0: PhantomData }, + x: NotSend { _0: PhantomData }, } } - #[idle(resources = [X, Y])] + #[idle(resources = [x, y])] fn idle(_: idle::Context) -> ! { loop {} } -- cgit v1.2.3