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 loongarch;
18#[macro_use]
19mod s390x;
20
21cfg_select! {
22    any(target_arch = "x86", target_arch = "x86_64") => {
23        pub use x86::__is_feature_detected;
24        pub(crate) use x86::Feature;
25    }
26    target_arch = "arm" => {
27        pub use arm::__is_feature_detected;
28        pub(crate) use arm::Feature;
29    }
30    any(target_arch = "aarch64", target_arch = "arm64ec") => {
31        pub use aarch64::__is_feature_detected;
32        pub(crate) use aarch64::Feature;
33    }
34    any(target_arch = "riscv32", target_arch = "riscv64") => {
35        pub use riscv::__is_feature_detected;
36        pub(crate) use riscv::Feature;
37    }
38    any(target_arch = "powerpc", target_arch = "powerpc64") => {
39        pub use powerpc::__is_feature_detected;
40        pub(crate) use powerpc::Feature;
41    }
42    any(
43        target_arch = "mips",
44        target_arch = "mips32r6",
45        target_arch = "mips64",
46        target_arch = "mips64r6"
47    ) => {
48        pub use mips::__is_feature_detected;
49        pub(crate) use mips::Feature;
50    }
51    any(target_arch = "loongarch32", target_arch = "loongarch64") => {
52        pub use loongarch::__is_feature_detected;
53        pub(crate) use loongarch::Feature;
54    }
55    target_arch = "s390x" => {
56        pub use s390x::__is_feature_detected;
57        pub(crate) use s390x::Feature;
58    }
59    _ => {
60        // Unimplemented architecture:
61        #[doc(hidden)]
62        pub(crate) enum Feature {
63            Null,
64        }
65        #[doc(hidden)]
66        pub mod __is_feature_detected {}
67
68        impl Feature {
69            #[doc(hidden)]
70            pub(crate) const ALL: &[Self] = &[];
71            #[doc(hidden)]
72            pub(crate) fn from_str(_s: &str) -> Result<Feature, ()> {
73                Err(())
74            }
75            #[doc(hidden)]
76            pub(crate) fn to_str(self) -> &'static str {
77                ""
78            }
79        }
80    }
81}