diff options
Diffstat (limited to 'embassy-executor/src/lib.rs')
| -rw-r--r-- | embassy-executor/src/lib.rs | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index 8707995b4..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,41 +10,35 @@ 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::*; | ||
| 37 | |||
| 38 | pub mod raw; | ||
| 39 | |||
| 40 | mod spawner; | ||
| 41 | pub use spawner::*; | ||
| 48 | 42 | ||
| 49 | /// Implementation details for embassy macros. | 43 | /// Implementation details for embassy macros. |
| 50 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. | 44 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. |
| @@ -72,8 +66,3 @@ pub mod _export { | |||
| 72 | ($($tt:tt)*) => {}; | 66 | ($($tt:tt)*) => {}; |
| 73 | } | 67 | } |
| 74 | } | 68 | } |
| 75 | |||
| 76 | pub mod raw; | ||
| 77 | |||
| 78 | mod spawner; | ||
| 79 | pub use spawner::*; | ||
