Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 macro_rules! value {
2 ($name:ident, $($value:literal,)+) => {
3 $(
4 #[cfg($name = $value)]
5 {
6 $value
7 }
8 )+
9 };
10 }
11
12 macro_rules! features {
13 ($($feature:literal,)+) => {
14 &[
15 $(
16 #[cfg(target_feature = $feature)]
17 $feature,
18 )+
19 ]
20 }
21 }
22
23 pub fn arch() -> &'static str {
24 value! {
25 target_arch,
26 "aarch64",
27 "arm",
28 "asmjs",
29 "avr",
30 "hexagon",
31 "le32",
32 "loongarch64",
33 "mips",
34 "mips64",
35 "msp430",
36 "nvptx",
37 "nvptx64",
38 "powerpc",
39 "powerpc64",
40 "riscv32",
41 "riscv64",
42 "s390x",
43 "sparc",
44 "sparc64",
45 "spriv",
46 "thumb",
47 "wasm32",
48 "x86",
49 "x86_64",
50 "xcore",
51 }
52 }
53
54 pub fn endian() -> &'static str {
55 value! {
56 target_endian,
57 "big",
58 "little",
59 }
60 }
61
62 pub fn env() -> &'static str {
63 value! {
64 target_env,
65 "",
66 "gnu",
67 "libnx",
68 "msvc",
69 "musl",
70 "newlib",
71 "sgx",
72 "uclibc",
73 }
74 }
75
76 pub fn family() -> &'static str {
77 value! {
78 target_family,
79 "unix",
80 "wasm",
81 "windows",
82 }
83 }
84
85 pub fn features() -> &'static [&'static str] {
86 features!(
87 "adx",
88 "aes",
89 "altivec",
90 "atomics",
91 "avx",
92 "avx2",
93 "avx512bf16",
94 "avx512bitalg",
95 "avx512bw",
96 "avx512cd",
97 "avx512f",
98 "avx512gfni",
99 "avx512ifma",
100 "avx512vaes",
101 "avx512vbmi",
102 "avx512vl",
103 "avx512vnni",
104 "avx512vpopcntdq",
105 "bmi1",
106 "bmi2",
107 "cmpxchg16b",
108 "crc",
109 "f16c",
110 "fma",
111 "fxsr",
112 "lzcnt",
113 "msa",
114 "neon",
115 "pclmulqdq",
116 "popcnt",
117 "rdrand",
118 "rdseed",
119 "rtm",
120 "sha",
121 "simd128",
122 "sse",
123 "sse2",
124 "sse3",
125 "sse4.1",
126 "sse4.2",
127 "sse4a",
128 "ssse3",
129 "tbm",
130 "tme",
131 "v7",
132 "v8",
133 "vsx",
134 "xsave",
135 "xsavec",
136 "xsaveopt",
137 "xsaves",
138 )
139 }
140
141 pub fn os() -> &'static str {
142 value! {
143 target_os,
144 "aix",
145 "android",
146 "bitrig",
147 "cloudabi",
148 "cuda",
149 "dragonfly",
150 "emscripten",
151 "freebsd",
152 "fuchsia",
153 "haiku",
154 "hermit",
155 "hurd",
156 "illumos",
157 "ios",
158 "l4re",
159 "linux",
160 "macos",
161 "netbsd",
162 "none",
163 "openbsd",
164 "psp",
165 "redox",
166 "sgx",
167 "solaris",
168 "tvos",
169 "vxworks",
170 "wasi",
171 "watchos",
172 "windows",
173 }
174 }
175
176 pub fn pointer_width() -> &'static str {
177 value! {
178 target_pointer_width,
179 "8",
180 "16",
181 "32",
182 "64",
183 }
184 }
185
186 pub fn test() -> bool {
187 cfg!(test)
188 }
189
190 pub fn vendor() -> &'static str {
191 if cfg!(target_vendor = "apple") {
192 "apple"
193 } else if cfg!(target_vendor = "fortanix") {
194 "fortanix"
195 } else if cfg!(target_vendor = "pc") {
196 "pc"
197 } else if cfg!(target_vendor = "sun") {
198 "sun"
199 } else if cfg!(target_vendor = "uwp") {
200 "uwp"
201 } else if cfg!(target_vendor = "ibm") {
202 "ibm"
203 } else {
204 "unknown"
205 }
206 }