diff options
Diffstat (limited to 'embassy-executor/src/lib.rs')
| -rw-r--r-- | embassy-executor/src/lib.rs | 83 |
1 files changed, 34 insertions, 49 deletions
diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index 4c7e2f4cd..3ce687eb6 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] | 1 | #![cfg_attr(not(any(feature = "arch-std", feature = "arch-wasm")), no_std)] |
| 2 | #![cfg_attr(all(feature = "nightly", target_arch = "xtensa"), feature(asm_experimental_arch))] | 2 | #![cfg_attr(all(feature = "nightly", feature = "arch-xtensa"), feature(asm_experimental_arch))] |
| 3 | #![allow(clippy::new_without_default)] | 3 | #![allow(clippy::new_without_default)] |
| 4 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 5 | #![warn(missing_docs)] | 5 | #![warn(missing_docs)] |
| @@ -10,47 +10,43 @@ pub(crate) mod fmt; | |||
| 10 | #[cfg(feature = "nightly")] | 10 | #[cfg(feature = "nightly")] |
| 11 | pub use embassy_macros::task; | 11 | pub use embassy_macros::task; |
| 12 | 12 | ||
| 13 | cfg_if::cfg_if! { | 13 | macro_rules! check_at_most_one { |
| 14 | if #[cfg(cortex_m)] { | 14 | (@amo [$($feats:literal)*] [] [$($res:tt)*]) => { |
| 15 | #[path="arch/cortex_m.rs"] | 15 | #[cfg(any($($res)*))] |
| 16 | mod arch; | 16 | compile_error!(concat!("At most one of these features can be enabled at the same time:", $(" `", $feats, "`",)*)); |
| 17 | pub use arch::*; | 17 | }; |
| 18 | #[cfg(feature = "nightly")] | 18 | (@amo $feats:tt [$curr:literal $($rest:literal)*] [$($res:tt)*]) => { |
| 19 | pub use embassy_macros::main_cortex_m as main; | 19 | check_at_most_one!(@amo $feats [$($rest)*] [$($res)* $(all(feature=$curr, feature=$rest),)*]); |
| 20 | } | 20 | }; |
| 21 | else if #[cfg(target_arch="riscv32")] { | 21 | ($($f:literal),*$(,)?) => { |
| 22 | #[path="arch/riscv32.rs"] | 22 | check_at_most_one!(@amo [$($f)*] [$($f)*] []); |
| 23 | mod arch; | 23 | }; |
| 24 | pub use arch::*; | ||
| 25 | #[cfg(feature = "nightly")] | ||
| 26 | pub use embassy_macros::main_riscv as main; | ||
| 27 | } | ||
| 28 | else if #[cfg(all(target_arch="xtensa", feature = "nightly"))] { | ||
| 29 | #[path="arch/xtensa.rs"] | ||
| 30 | mod arch; | ||
| 31 | pub use arch::*; | ||
| 32 | } | ||
| 33 | else if #[cfg(feature="wasm")] { | ||
| 34 | #[path="arch/wasm.rs"] | ||
| 35 | mod arch; | ||
| 36 | pub use arch::*; | ||
| 37 | #[cfg(feature = "nightly")] | ||
| 38 | pub use embassy_macros::main_wasm as main; | ||
| 39 | } | ||
| 40 | else if #[cfg(feature="std")] { | ||
| 41 | #[path="arch/std.rs"] | ||
| 42 | mod arch; | ||
| 43 | pub use arch::*; | ||
| 44 | #[cfg(feature = "nightly")] | ||
| 45 | pub use embassy_macros::main_std as main; | ||
| 46 | } | ||
| 47 | } | 24 | } |
| 25 | check_at_most_one!("arch-cortex-m", "arch-riscv32", "arch-xtensa", "arch-std", "arch-wasm",); | ||
| 26 | |||
| 27 | #[cfg(feature = "_arch")] | ||
| 28 | #[cfg_attr(feature = "arch-cortex-m", path = "arch/cortex_m.rs")] | ||
| 29 | #[cfg_attr(feature = "arch-riscv32", path = "arch/riscv32.rs")] | ||
| 30 | #[cfg_attr(feature = "arch-xtensa", path = "arch/xtensa.rs")] | ||
| 31 | #[cfg_attr(feature = "arch-std", path = "arch/std.rs")] | ||
| 32 | #[cfg_attr(feature = "arch-wasm", path = "arch/wasm.rs")] | ||
| 33 | mod arch; | ||
| 34 | |||
| 35 | #[cfg(feature = "_arch")] | ||
| 36 | pub use arch::*; | ||
| 48 | 37 | ||
| 38 | pub mod raw; | ||
| 39 | |||
| 40 | mod spawner; | ||
| 41 | pub use spawner::*; | ||
| 42 | |||
| 43 | /// Implementation details for embassy macros. | ||
| 44 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. | ||
| 49 | #[doc(hidden)] | 45 | #[doc(hidden)] |
| 50 | /// Implementation details for embassy macros. DO NOT USE. | 46 | pub mod _export { |
| 51 | pub mod export { | ||
| 52 | #[cfg(feature = "rtos-trace")] | 47 | #[cfg(feature = "rtos-trace")] |
| 53 | pub use rtos_trace::trace; | 48 | pub use rtos_trace::trace; |
| 49 | pub use static_cell::StaticCell; | ||
| 54 | 50 | ||
| 55 | /// Expands the given block of code when `embassy-executor` is compiled with | 51 | /// Expands the given block of code when `embassy-executor` is compiled with |
| 56 | /// the `rtos-trace-interrupt` feature. | 52 | /// the `rtos-trace-interrupt` feature. |
| @@ -70,14 +66,3 @@ pub mod export { | |||
| 70 | ($($tt:tt)*) => {}; | 66 | ($($tt:tt)*) => {}; |
| 71 | } | 67 | } |
| 72 | } | 68 | } |
| 73 | |||
| 74 | pub mod raw; | ||
| 75 | |||
| 76 | mod spawner; | ||
| 77 | pub use spawner::*; | ||
| 78 | |||
| 79 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. | ||
| 80 | #[doc(hidden)] | ||
| 81 | pub mod _export { | ||
| 82 | pub use static_cell::StaticCell; | ||
| 83 | } | ||
