1#![allow(missing_docs)]
4
5#[cfg(not(all(
6 portable_atomic_no_atomic_load_store,
7 not(any(
8 target_arch = "avr",
9 target_arch = "msp430",
10 target_arch = "riscv32",
11 target_arch = "riscv64",
12 feature = "critical-section",
13 )),
14)))]
15#[macro_use]
16mod atomic_8_16_macros {
17 #[macro_export]
18 macro_rules! cfg_has_atomic_8 {
19 ($($tt:tt)*) => {
20 $($tt)*
21 };
22 }
23 #[macro_export]
24 macro_rules! cfg_no_atomic_8 {
25 ($($tt:tt)*) => {};
26 }
27 #[macro_export]
28 macro_rules! cfg_has_atomic_16 {
29 ($($tt:tt)*) => {
30 $($tt)*
31 };
32 }
33 #[macro_export]
34 macro_rules! cfg_no_atomic_16 {
35 ($($tt:tt)*) => {};
36 }
37}
38#[cfg(all(
39 portable_atomic_no_atomic_load_store,
40 not(any(
41 target_arch = "avr",
42 target_arch = "msp430",
43 target_arch = "riscv32",
44 target_arch = "riscv64",
45 feature = "critical-section",
46 )),
47))]
48#[macro_use]
49mod atomic_8_16_macros {
50 #[macro_export]
51 macro_rules! cfg_has_atomic_8 {
52 ($($tt:tt)*) => {};
53 }
54 #[macro_export]
55 macro_rules! cfg_no_atomic_8 {
56 ($($tt:tt)*) => {
57 $($tt)*
58 };
59 }
60 #[macro_export]
61 macro_rules! cfg_has_atomic_16 {
62 ($($tt:tt)*) => {};
63 }
64 #[macro_export]
65 macro_rules! cfg_no_atomic_16 {
66 ($($tt:tt)*) => {
67 $($tt)*
68 };
69 }
70}
71
72#[cfg(all(
73 any(not(target_pointer_width = "16"), feature = "fallback"),
74 not(all(
75 portable_atomic_no_atomic_load_store,
76 not(any(
77 target_arch = "avr",
78 target_arch = "msp430",
79 target_arch = "riscv32",
80 target_arch = "riscv64",
81 feature = "critical-section",
82 )),
83 )),
84))]
85#[macro_use]
86mod atomic_32_macros {
87 #[macro_export]
88 macro_rules! cfg_has_atomic_32 {
89 ($($tt:tt)*) => {
90 $($tt)*
91 };
92 }
93 #[macro_export]
94 macro_rules! cfg_no_atomic_32 {
95 ($($tt:tt)*) => {};
96 }
97}
98#[cfg(not(all(
99 any(not(target_pointer_width = "16"), feature = "fallback"),
100 not(all(
101 portable_atomic_no_atomic_load_store,
102 not(any(
103 target_arch = "avr",
104 target_arch = "msp430",
105 target_arch = "riscv32",
106 target_arch = "riscv64",
107 feature = "critical-section",
108 )),
109 )),
110)))]
111#[macro_use]
112mod atomic_32_macros {
113 #[macro_export]
114 macro_rules! cfg_has_atomic_32 {
115 ($($tt:tt)*) => {};
116 }
117 #[macro_export]
118 macro_rules! cfg_no_atomic_32 {
119 ($($tt:tt)*) => {
120 $($tt)*
121 };
122 }
123}
124
125#[cfg_attr(
126 portable_atomic_no_cfg_target_has_atomic,
127 cfg(any(
128 all(
129 feature = "fallback",
130 any(
131 not(portable_atomic_no_atomic_cas),
132 portable_atomic_unsafe_assume_single_core,
133 feature = "critical-section",
134 target_arch = "avr",
135 target_arch = "msp430",
136 ),
137 ),
138 not(portable_atomic_no_atomic_64),
139 not(any(target_pointer_width = "16", target_pointer_width = "32")),
140 all(
141 target_arch = "riscv32",
142 not(any(miri, portable_atomic_sanitize_thread)),
143 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
144 any(target_feature = "zacas", portable_atomic_target_feature = "zacas"),
145 ),
146 ))
147)]
148#[cfg_attr(
149 not(portable_atomic_no_cfg_target_has_atomic),
150 cfg(any(
151 all(
152 feature = "fallback",
153 any(
154 target_has_atomic = "ptr",
155 portable_atomic_unsafe_assume_single_core,
156 feature = "critical-section",
157 target_arch = "avr",
158 target_arch = "msp430",
159 ),
160 ),
161 target_has_atomic = "64",
162 not(any(target_pointer_width = "16", target_pointer_width = "32")),
163 all(
164 target_arch = "riscv32",
165 not(any(miri, portable_atomic_sanitize_thread)),
166 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
167 any(target_feature = "zacas", portable_atomic_target_feature = "zacas"),
168 ),
169 ))
170)]
171#[macro_use]
172mod atomic_64_macros {
173 #[macro_export]
174 macro_rules! cfg_has_atomic_64 {
175 ($($tt:tt)*) => {
176 $($tt)*
177 };
178 }
179 #[macro_export]
180 macro_rules! cfg_no_atomic_64 {
181 ($($tt:tt)*) => {};
182 }
183}
184#[cfg_attr(
185 portable_atomic_no_cfg_target_has_atomic,
186 cfg(not(any(
187 all(
188 feature = "fallback",
189 any(
190 not(portable_atomic_no_atomic_cas),
191 portable_atomic_unsafe_assume_single_core,
192 feature = "critical-section",
193 target_arch = "avr",
194 target_arch = "msp430",
195 ),
196 ),
197 not(portable_atomic_no_atomic_64),
198 not(any(target_pointer_width = "16", target_pointer_width = "32")),
199 all(
200 target_arch = "riscv32",
201 not(any(miri, portable_atomic_sanitize_thread)),
202 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
203 any(target_feature = "zacas", portable_atomic_target_feature = "zacas"),
204 ),
205 )))
206)]
207#[cfg_attr(
208 not(portable_atomic_no_cfg_target_has_atomic),
209 cfg(not(any(
210 all(
211 feature = "fallback",
212 any(
213 target_has_atomic = "ptr",
214 portable_atomic_unsafe_assume_single_core,
215 feature = "critical-section",
216 target_arch = "avr",
217 target_arch = "msp430",
218 ),
219 ),
220 target_has_atomic = "64",
221 not(any(target_pointer_width = "16", target_pointer_width = "32")),
222 all(
223 target_arch = "riscv32",
224 not(any(miri, portable_atomic_sanitize_thread)),
225 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
226 any(target_feature = "zacas", portable_atomic_target_feature = "zacas"),
227 ),
228 )))
229)]
230#[macro_use]
231mod atomic_64_macros {
232 #[macro_export]
233 macro_rules! cfg_has_atomic_64 {
234 ($($tt:tt)*) => {};
235 }
236 #[macro_export]
237 macro_rules! cfg_no_atomic_64 {
238 ($($tt:tt)*) => {
239 $($tt)*
240 };
241 }
242}
243
244#[cfg_attr(
245 not(feature = "fallback"),
246 cfg(any(
247 all(
248 target_arch = "aarch64",
249 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
250 ),
251 all(target_arch = "arm64ec", not(portable_atomic_no_asm)),
252 all(
253 target_arch = "x86_64",
254 not(all(
255 any(miri, portable_atomic_sanitize_thread),
256 portable_atomic_no_cmpxchg16b_intrinsic,
257 )),
258 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
259 any(target_feature = "cmpxchg16b", portable_atomic_target_feature = "cmpxchg16b"),
260 ),
261 all(
262 target_arch = "riscv64",
263 not(any(miri, portable_atomic_sanitize_thread)),
264 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
265 any(target_feature = "zacas", portable_atomic_target_feature = "zacas"),
266 ),
267 all(
268 target_arch = "powerpc64",
269 portable_atomic_unstable_asm_experimental_arch,
270 any(
271 target_feature = "quadword-atomics",
272 portable_atomic_target_feature = "quadword-atomics",
273 ),
274 ),
275 all(target_arch = "s390x", not(portable_atomic_no_asm)),
276 ))
277)]
278#[cfg_attr(
279 all(feature = "fallback", portable_atomic_no_cfg_target_has_atomic),
280 cfg(any(
281 not(portable_atomic_no_atomic_cas),
282 portable_atomic_unsafe_assume_single_core,
283 feature = "critical-section",
284 target_arch = "avr",
285 target_arch = "msp430",
286 ))
287)]
288#[cfg_attr(
289 all(feature = "fallback", not(portable_atomic_no_cfg_target_has_atomic)),
290 cfg(any(
291 target_has_atomic = "ptr",
292 portable_atomic_unsafe_assume_single_core,
293 feature = "critical-section",
294 target_arch = "avr",
295 target_arch = "msp430",
296 ))
297)]
298#[macro_use]
299mod atomic_128_macros {
300 #[macro_export]
301 macro_rules! cfg_has_atomic_128 {
302 ($($tt:tt)*) => {
303 $($tt)*
304 };
305 }
306 #[macro_export]
307 macro_rules! cfg_no_atomic_128 {
308 ($($tt:tt)*) => {};
309 }
310}
311#[cfg_attr(
312 not(feature = "fallback"),
313 cfg(not(any(
314 all(
315 target_arch = "aarch64",
316 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
317 ),
318 all(target_arch = "arm64ec", not(portable_atomic_no_asm)),
319 all(
320 target_arch = "x86_64",
321 not(all(
322 any(miri, portable_atomic_sanitize_thread),
323 portable_atomic_no_cmpxchg16b_intrinsic,
324 )),
325 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
326 any(target_feature = "cmpxchg16b", portable_atomic_target_feature = "cmpxchg16b"),
327 ),
328 all(
329 target_arch = "riscv64",
330 not(any(miri, portable_atomic_sanitize_thread)),
331 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
332 any(target_feature = "zacas", portable_atomic_target_feature = "zacas"),
333 ),
334 all(
335 target_arch = "powerpc64",
336 portable_atomic_unstable_asm_experimental_arch,
337 any(
338 target_feature = "quadword-atomics",
339 portable_atomic_target_feature = "quadword-atomics",
340 ),
341 ),
342 all(target_arch = "s390x", not(portable_atomic_no_asm)),
343 )))
344)]
345#[cfg_attr(
346 all(feature = "fallback", portable_atomic_no_cfg_target_has_atomic),
347 cfg(not(any(
348 not(portable_atomic_no_atomic_cas),
349 portable_atomic_unsafe_assume_single_core,
350 feature = "critical-section",
351 target_arch = "avr",
352 target_arch = "msp430",
353 )))
354)]
355#[cfg_attr(
356 all(feature = "fallback", not(portable_atomic_no_cfg_target_has_atomic)),
357 cfg(not(any(
358 target_has_atomic = "ptr",
359 portable_atomic_unsafe_assume_single_core,
360 feature = "critical-section",
361 target_arch = "avr",
362 target_arch = "msp430",
363 )))
364)]
365#[macro_use]
366mod atomic_128_macros {
367 #[macro_export]
368 macro_rules! cfg_has_atomic_128 {
369 ($($tt:tt)*) => {};
370 }
371 #[macro_export]
372 macro_rules! cfg_no_atomic_128 {
373 ($($tt:tt)*) => {
374 $($tt)*
375 };
376 }
377}
378
379#[cfg_attr(
380 portable_atomic_no_cfg_target_has_atomic,
381 cfg(any(
382 not(portable_atomic_no_atomic_cas),
383 portable_atomic_unsafe_assume_single_core,
384 feature = "critical-section",
385 target_arch = "avr",
386 target_arch = "msp430",
387 ))
388)]
389#[cfg_attr(
390 not(portable_atomic_no_cfg_target_has_atomic),
391 cfg(any(
392 target_has_atomic = "ptr",
393 portable_atomic_unsafe_assume_single_core,
394 feature = "critical-section",
395 target_arch = "avr",
396 target_arch = "msp430",
397 ))
398)]
399#[macro_use]
400mod atomic_cas_macros {
401 #[macro_export]
402 macro_rules! cfg_has_atomic_cas {
403 ($($tt:tt)*) => {
404 $($tt)*
405 };
406 }
407 #[macro_export]
408 macro_rules! cfg_no_atomic_cas {
409 ($($tt:tt)*) => {};
410 }
411 macro_rules! cfg_has_atomic_cas_or_amo32 {
413 ($($tt:tt)*) => {
414 $($tt)*
415 };
416 }
417 macro_rules! cfg_has_atomic_cas_or_amo8 {
418 ($($tt:tt)*) => {
419 $($tt)*
420 };
421 }
422}
423#[cfg_attr(
424 portable_atomic_no_cfg_target_has_atomic,
425 cfg(not(any(
426 not(portable_atomic_no_atomic_cas),
427 portable_atomic_unsafe_assume_single_core,
428 feature = "critical-section",
429 target_arch = "avr",
430 target_arch = "msp430",
431 )))
432)]
433#[cfg_attr(
434 not(portable_atomic_no_cfg_target_has_atomic),
435 cfg(not(any(
436 target_has_atomic = "ptr",
437 portable_atomic_unsafe_assume_single_core,
438 feature = "critical-section",
439 target_arch = "avr",
440 target_arch = "msp430",
441 )))
442)]
443#[macro_use]
444mod atomic_cas_macros {
445 #[macro_export]
446 macro_rules! cfg_has_atomic_cas {
447 ($($tt:tt)*) => {};
448 }
449 #[macro_export]
450 macro_rules! cfg_no_atomic_cas {
451 ($($tt:tt)*) => {
452 $($tt)*
453 };
454 }
455 #[cfg_attr(
457 any(target_arch = "riscv32", target_arch = "riscv64"),
458 cfg(not(any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo")))
459 )]
460 macro_rules! cfg_has_atomic_cas_or_amo32 {
461 ($($tt:tt)*) => {};
462 }
463 #[cfg_attr(
464 any(target_arch = "riscv32", target_arch = "riscv64"),
465 cfg(not(any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo")))
466 )]
467 macro_rules! cfg_no_atomic_cas_or_amo32 {
468 ($($tt:tt)*) => {
469 $($tt)*
470 };
471 }
472 #[cfg(all(
473 any(target_arch = "riscv32", target_arch = "riscv64"),
474 any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo"),
475 ))]
476 macro_rules! cfg_has_atomic_cas_or_amo32 {
477 ($($tt:tt)*) => {
478 $($tt)*
479 };
480 }
481 #[cfg(all(
482 any(target_arch = "riscv32", target_arch = "riscv64"),
483 any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo"),
484 ))]
485 macro_rules! cfg_no_atomic_cas_or_amo32 {
486 ($($tt:tt)*) => {};
487 }
488 #[cfg_attr(
489 any(target_arch = "riscv32", target_arch = "riscv64"),
490 cfg(not(any(target_feature = "zabha", portable_atomic_target_feature = "zabha")))
491 )]
492 #[allow(unused_macros)]
493 macro_rules! cfg_has_atomic_cas_or_amo8 {
494 ($($tt:tt)*) => {};
495 }
496 #[cfg_attr(
497 any(target_arch = "riscv32", target_arch = "riscv64"),
498 cfg(not(any(target_feature = "zabha", portable_atomic_target_feature = "zabha")))
499 )]
500 #[cfg_attr(target_arch = "bpf", allow(unused_macros))]
501 macro_rules! cfg_no_atomic_cas_or_amo8 {
502 ($($tt:tt)*) => {
503 $($tt)*
504 };
505 }
506 #[cfg(all(
507 any(target_arch = "riscv32", target_arch = "riscv64"),
508 any(target_feature = "zabha", portable_atomic_target_feature = "zabha"),
509 ))]
510 macro_rules! cfg_has_atomic_cas_or_amo8 {
511 ($($tt:tt)*) => {
512 $($tt)*
513 };
514 }
515 #[cfg(all(
516 any(target_arch = "riscv32", target_arch = "riscv64"),
517 any(target_feature = "zabha", portable_atomic_target_feature = "zabha"),
518 ))]
519 macro_rules! cfg_no_atomic_cas_or_amo8 {
520 ($($tt:tt)*) => {};
521 }
522}
523
524mod check {
526 crate::cfg_has_atomic_8! { type _Atomic8 = (); }
527 crate::cfg_no_atomic_8! { type _Atomic8 = (); }
528 crate::cfg_has_atomic_16! { type _Atomic16 = (); }
529 crate::cfg_no_atomic_16! { type _Atomic16 = (); }
530 crate::cfg_has_atomic_32! { type _Atomic32 = (); }
531 crate::cfg_no_atomic_32! { type _Atomic32 = (); }
532 crate::cfg_has_atomic_64! { type _Atomic64 = (); }
533 crate::cfg_no_atomic_64! { type _Atomic64 = (); }
534 crate::cfg_has_atomic_128! { type _Atomic128 = (); }
535 crate::cfg_no_atomic_128! { type _Atomic128 = (); }
536 crate::cfg_has_atomic_ptr! { type _AtomicPtr = (); }
537 crate::cfg_no_atomic_ptr! { type _AtomicPtr = (); }
538 crate::cfg_has_atomic_cas! { type __AtomicPtr = (); }
539 crate::cfg_no_atomic_cas! { type __AtomicPtr = (); }
540 #[allow(unused_imports)]
541 use self::{
542 __AtomicPtr as _, _Atomic8 as _, _Atomic16 as _, _Atomic32 as _, _Atomic64 as _,
543 _Atomic128 as _, _AtomicPtr as _,
544 };
545}