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", feature = "libc") => {
65 #[allow(dead_code)] #[cfg(target_arch = "aarch64")]
67 #[path = "os/aarch64.rs"]
68 mod aarch64;
69 #[path = "os/openbsd/mod.rs"]
70 mod os;
71 }
72 all(target_os = "windows", any(target_arch = "aarch64", target_arch = "arm64ec")) => {
73 #[path = "os/windows/aarch64.rs"]
74 mod os;
75 }
76 all(target_vendor = "apple", target_arch = "aarch64", feature = "libc") => {
77 #[path = "os/darwin/aarch64.rs"]
78 mod os;
79 }
80 _ => {
81 #[path = "os/other.rs"]
82 mod os;
83 }
84}
85
86#[inline]
88#[allow(dead_code)]
89fn check_for(x: Feature) -> bool {
90 cache::test(x as u32)
91}
92
93#[unstable(feature = "stdarch_internal", issue = "none")]
97pub fn features() -> impl Iterator<Item = (&'static str, bool)> {
98 cfg_select! {
99 any(
100 target_arch = "x86",
101 target_arch = "x86_64",
102 target_arch = "arm",
103 target_arch = "aarch64",
104 target_arch = "arm64ec",
105 target_arch = "riscv32",
106 target_arch = "riscv64",
107 target_arch = "powerpc",
108 target_arch = "powerpc64",
109 target_arch = "mips",
110 target_arch = "mips64",
111 target_arch = "loongarch32",
112 target_arch = "loongarch64",
113 target_arch = "s390x",
114 ) => {
115 (0_u8..Feature::_last as u8).map(|discriminant: u8| {
116 #[allow(bindings_with_variant_name)] let f: Feature = unsafe { core::mem::transmute(discriminant) };
118 let name: &'static str = f.to_str();
119 let enabled: bool = check_for(f);
120 (name, enabled)
121 })
122 }
123 _ => None.into_iter(),
124 }
125}