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 <sean@xobs.io>
This commit is contained in:
Sean Cross 2022-10-25 15:50:53 +08:00
parent fd42770ee0
commit 6066619906
2 changed files with 6 additions and 14 deletions

View file

@ -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::*;

View file

@ -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;