1use cfg_if::cfg_if;
21
22#[macro_use]
23mod macros;
24
25mod arch;
26
27#[doc(hidden)]
30#[unstable(feature = "stdarch_internal", issue = "none")]
31pub use self::arch::__is_feature_detected;
32
33pub(crate) use self::arch::Feature;
34
35mod bit;
36mod cache;
37
38cfg_if! {
39 if #[cfg(miri)] {
40 #[path = "os/other.rs"]
46 mod os;
47 } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
48 #[path = "os/x86.rs"]
50 mod os;
51 } else if #[cfg(all(any(target_os = "linux", target_os = "android"), feature = "libc"))] {
52 #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
53 #[path = "os/riscv.rs"]
54 mod riscv;
55 #[path = "os/linux/mod.rs"]
56 mod os;
57 } else if #[cfg(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 } else if #[cfg(all(target_os = "openbsd", target_arch = "aarch64", feature = "libc"))] {
64 #[allow(dead_code)] #[path = "os/aarch64.rs"]
66 mod aarch64;
67 #[path = "os/openbsd/aarch64.rs"]
68 mod os;
69 } else if #[cfg(all(target_os = "windows", any(target_arch = "aarch64", target_arch = "arm64ec")))] {
70 #[path = "os/windows/aarch64.rs"]
71 mod os;
72 } else if #[cfg(all(target_vendor = "apple", target_arch = "aarch64", feature = "libc"))] {
73 #[path = "os/darwin/aarch64.rs"]
74 mod os;
75 } else {
76 #[path = "os/other.rs"]
77 mod os;
78 }
79}
80
81#[inline]
83#[allow(dead_code)]
84fn check_for(x: Feature) -> bool {
85 cache::test(x as u32)
86}
87
88#[unstable(feature = "stdarch_internal", issue = "none")]
92pub fn features() -> impl Iterator<Item = (&'static str, bool)> {
93 cfg_if! {
94 if #[cfg(any(
95 target_arch = "x86",
96 target_arch = "x86_64",
97 target_arch = "arm",
98 target_arch = "aarch64",
99 target_arch = "arm64ec",
100 target_arch = "riscv32",
101 target_arch = "riscv64",
102 target_arch = "powerpc",
103 target_arch = "powerpc64",
104 target_arch = "mips",
105 target_arch = "mips64",
106 target_arch = "loongarch64",
107 target_arch = "s390x",
108 ))] {
109 (0_u8..Feature::_last as u8).map(|discriminant: u8| {
110 #[allow(bindings_with_variant_name)] let f: Feature = unsafe { core::mem::transmute(discriminant) };
112 let name: &'static str = f.to_str();
113 let enabled: bool = check_for(f);
114 (name, enabled)
115 })
116 } else {
117 None.into_iter()
118 }
119 }
120}