From 6066619906ef0bd47ed2217ce49022de37169595 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Tue, 25 Oct 2022 15:50:53 +0800 Subject: [PATCH] xous-rs: use `target_os` and `target_arch` cfgs Look at `target_os` to determine whether to enter "hosted" mode or not. If `target_os` is "xous", then the Xous standard library should default to using builtin Rust libstd features. If it is "xous", then we should instead use our arch-specific implementations. This enables third-party programs to directly use the `xous` crate without specifying feature flags. Signed-off-by: Sean Cross --- xous-rs/src/arch/mod.rs | 12 ++++-------- xous-rs/src/definitions.rs | 8 ++------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/xous-rs/src/arch/mod.rs b/xous-rs/src/arch/mod.rs index 19d19fb2a..131d4c341 100644 --- a/xous-rs/src/arch/mod.rs +++ b/xous-rs/src/arch/mod.rs @@ -1,20 +1,16 @@ -#[cfg(any(feature="precursor", feature="renode"))] +#[cfg(all(target_os = "xous", target_arch = "riscv32"))] pub mod riscv; -#[cfg(any(feature="precursor", feature="renode"))] +#[cfg(all(target_os = "xous", target_arch = "riscv32"))] pub use riscv::*; #[cfg(all( not(feature="processes-as-threads"), - any(feature="hosted", - not(any(feature="precursor", feature="renode")) - ) + not(target_os = "xous") ))] pub mod hosted; #[cfg(all( not(feature="processes-as-threads"), - any(feature="hosted", - not(any(feature="precursor", feature="renode")) - ) + not(target_os = "xous") ))] pub use hosted::*; diff --git a/xous-rs/src/definitions.rs b/xous-rs/src/definitions.rs index 4c92a3859..7cee91acb 100644 --- a/xous-rs/src/definitions.rs +++ b/xous-rs/src/definitions.rs @@ -55,9 +55,7 @@ pub const BASE_QUANTA_MS: u32 = 10; pub const BOOKEND_START: &'static str = "_|TT|_"; pub const BOOKEND_END: &'static str = "_|TE|_"; -#[cfg(any(feature="hosted", - not(any(feature="precursor", feature="renode")) -))] +#[cfg(not(target_os = "xous"))] use core::sync::atomic::AtomicU64; // Secretly, you can change this by setting the XOUS_SEED environment variable. @@ -66,9 +64,7 @@ use core::sync::atomic::AtomicU64; // The code that reads the varable this is all the way over in xous-rs\src\arch\hosted\mod.rs#29, and // it's glommed onto some other static process initialization code because I don't fully understand // what's going on over there. -#[cfg(any(feature="hosted", - not(any(feature="precursor", feature="renode")) -))] +#[cfg(not(target_os = "xous"))] pub static TESTING_RNG_SEED: AtomicU64 = AtomicU64::new(0); pub mod exceptions;