1#[macro_use]
21mod macros;
22
23mod arch;
24
25#[doc(hidden)]
28#[unstable(feature = "stdarch_internal", issue = "none")]
29pub use self::arch::__is_feature_detected;
30pub(crate) use self::arch::Feature;
31
32mod bit;
33mod cache;
34
35cfg_select! {
36    miri => {
37        #[path = "os/other.rs"]
43        mod os;
44    }
45    any(target_arch = "x86", target_arch = "x86_64") => {
46        #[path = "os/x86.rs"]
48        mod os;
49    }
50    all(any(target_os = "linux", target_os = "android"), feature = "libc") => {
51        #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
52        #[path = "os/riscv.rs"]
53        mod riscv;
54        #[path = "os/linux/mod.rs"]
55        mod os;
56    }
57    all(target_os = "freebsd", feature = "libc") => {
58        #[cfg(target_arch = "aarch64")]
59        #[path = "os/aarch64.rs"]
60        mod aarch64;
61        #[path = "os/freebsd/mod.rs"]
62        mod os;
63    }
64    all(target_os = "openbsd", target_arch = "aarch64", feature = "libc") => {
65        #[allow(dead_code)] #[path = "os/aarch64.rs"]
67        mod aarch64;
68        #[path = "os/openbsd/aarch64.rs"]
69        mod os;
70    }
71    all(target_os = "windows", any(target_arch = "aarch64", target_arch = "arm64ec")) => {
72        #[path = "os/windows/aarch64.rs"]
73        mod os;
74    }
75    all(target_vendor = "apple", target_arch = "aarch64", feature = "libc") => {
76        #[path = "os/darwin/aarch64.rs"]
77        mod os;
78    }
79    _ => {
80        #[path = "os/other.rs"]
81        mod os;
82    }
83}
84
85#[inline]
87#[allow(dead_code)]
88fn check_for(x: Feature) -> bool {
89    cache::test(x as u32)
90}
91
92#[unstable(feature = "stdarch_internal", issue = "none")]
96pub fn features() -> impl Iterator<Item = (&'static str, bool)> {
97    cfg_select! {
98        any(
99            target_arch = "x86",
100            target_arch = "x86_64",
101            target_arch = "arm",
102            target_arch = "aarch64",
103            target_arch = "arm64ec",
104            target_arch = "riscv32",
105            target_arch = "riscv64",
106            target_arch = "powerpc",
107            target_arch = "powerpc64",
108            target_arch = "mips",
109            target_arch = "mips64",
110            target_arch = "loongarch32",
111            target_arch = "loongarch64",
112            target_arch = "s390x",
113        ) => {
114            (0_u8..Feature::_last as u8).map(|discriminant: u8| {
115                #[allow(bindings_with_variant_name)] let f: Feature = unsafe { core::mem::transmute(discriminant) };
117                let name: &'static str = f.to_str();
118                let enabled: bool = check_for(f);
119                (name, enabled)
120            })
121        }
122        _ => None.into_iter(),
123    }
124}