Skip to main content

std_detect/detect/arch/
mod.rs

1#![allow(dead_code)]
2
3// Export the macros for all supported architectures.
4#[macro_use]
5mod x86;
6#[macro_use]
7mod arm;
8#[macro_use]
9mod aarch64;
10#[macro_use]
11mod riscv;
12#[macro_use]
13mod powerpc;
14#[macro_use]
15mod mips;
16#[macro_use]
17mod mips64;
18#[macro_use]
19mod loongarch;
20#[macro_use]
21mod s390x;
22
23cfg_select! {
24    any(target_arch = "x86", target_arch = "x86_64") => {
25        pub use x86::__is_feature_detected;
26        pub(crate) use x86::Feature;
27    }
28    target_arch = "arm" => {
29        pub use arm::__is_feature_detected;
30        pub(crate) use arm::Feature;
31    }
32    any(target_arch = "aarch64", target_arch = "arm64ec") => {
33        pub use aarch64::__is_feature_detected;
34        pub(crate) use aarch64::Feature;
35    }
36    any(target_arch = "riscv32", target_arch = "riscv64") => {
37        pub use riscv::__is_feature_detected;
38        pub(crate) use riscv::Feature;
39    }
40    any(target_arch = "powerpc", target_arch = "powerpc64") => {
41        pub use powerpc::__is_feature_detected;
42        pub(crate) use powerpc::Feature;
43    }
44    target_arch = "mips" => {
45        pub use mips::__is_feature_detected;
46        pub(crate) use mips::Feature;
47    }
48    target_arch = "mips64" => {
49        pub use mips64::__is_feature_detected;
50        pub(crate) use mips64::Feature;
51    }
52    any(target_arch = "loongarch32", target_arch = "loongarch64") => {
53        pub use loongarch::__is_feature_detected;
54        pub(crate) use loongarch::Feature;
55    }
56    target_arch = "s390x" => {
57        pub use s390x::__is_feature_detected;
58        pub(crate) use s390x::Feature;
59    }
60    _ => {
61        // Unimplemented architecture:
62        #[doc(hidden)]
63        pub(crate) enum Feature {
64            Null,
65        }
66        #[doc(hidden)]
67        pub mod __is_feature_detected {}
68
69        impl Feature {
70            #[doc(hidden)]
71            pub(crate) const ALL: &[Self] = &[];
72            #[doc(hidden)]
73            pub(crate) fn from_str(_s: &str) -> Result<Feature, ()> {
74                Err(())
75            }
76            #[doc(hidden)]
77            pub(crate) fn to_str(self) -> &'static str {
78                ""
79            }
80        }
81    }
82}