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 ))
141)]
142#[cfg_attr(
143 not(portable_atomic_no_cfg_target_has_atomic),
144 cfg(any(
145 all(
146 feature = "fallback",
147 any(
148 target_has_atomic = "ptr",
149 portable_atomic_unsafe_assume_single_core,
150 feature = "critical-section",
151 target_arch = "avr",
152 target_arch = "msp430",
153 ),
154 ),
155 target_has_atomic = "64",
156 not(any(target_pointer_width = "16", target_pointer_width = "32")),
157 all(
158 target_arch = "riscv32",
159 not(any(miri, portable_atomic_sanitize_thread)),
160 not(portable_atomic_no_asm),
161 any(
162 target_feature = "experimental-zacas",
163 portable_atomic_target_feature = "experimental-zacas",
164 all(
165 feature = "fallback",
166 not(portable_atomic_no_outline_atomics),
167 any(test, portable_atomic_outline_atomics), any(target_os = "linux", target_os = "android"),
169 ),
170 ),
171 ),
172 ))
173)]
174#[macro_use]
175mod atomic_64_macros {
176 #[macro_export]
177 macro_rules! cfg_has_atomic_64 {
178 ($($tt:tt)*) => {
179 $($tt)*
180 };
181 }
182 #[macro_export]
183 macro_rules! cfg_no_atomic_64 {
184 ($($tt:tt)*) => {};
185 }
186}
187#[cfg_attr(
188 portable_atomic_no_cfg_target_has_atomic,
189 cfg(not(any(
190 all(
191 feature = "fallback",
192 any(
193 not(portable_atomic_no_atomic_cas),
194 portable_atomic_unsafe_assume_single_core,
195 feature = "critical-section",
196 target_arch = "avr",
197 target_arch = "msp430",
198 ),
199 ),
200 not(portable_atomic_no_atomic_64),
201 not(any(target_pointer_width = "16", target_pointer_width = "32")),
202 )))
203)]
204#[cfg_attr(
205 not(portable_atomic_no_cfg_target_has_atomic),
206 cfg(not(any(
207 all(
208 feature = "fallback",
209 any(
210 target_has_atomic = "ptr",
211 portable_atomic_unsafe_assume_single_core,
212 feature = "critical-section",
213 target_arch = "avr",
214 target_arch = "msp430",
215 ),
216 ),
217 target_has_atomic = "64",
218 not(any(target_pointer_width = "16", target_pointer_width = "32")),
219 all(
220 target_arch = "riscv32",
221 not(any(miri, portable_atomic_sanitize_thread)),
222 not(portable_atomic_no_asm),
223 any(
224 target_feature = "experimental-zacas",
225 portable_atomic_target_feature = "experimental-zacas",
226 all(
227 feature = "fallback",
228 not(portable_atomic_no_outline_atomics),
229 any(test, portable_atomic_outline_atomics), any(target_os = "linux", target_os = "android"),
231 ),
232 ),
233 ),
234 )))
235)]
236#[macro_use]
237mod atomic_64_macros {
238 #[macro_export]
239 macro_rules! cfg_has_atomic_64 {
240 ($($tt:tt)*) => {};
241 }
242 #[macro_export]
243 macro_rules! cfg_no_atomic_64 {
244 ($($tt:tt)*) => {
245 $($tt)*
246 };
247 }
248}
249
250#[cfg_attr(
251 not(feature = "fallback"),
252 cfg(any(
253 all(
254 target_arch = "aarch64",
255 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
256 ),
257 all(target_arch = "arm64ec", not(portable_atomic_no_asm)),
258 all(
259 target_arch = "x86_64",
260 not(all(
261 any(miri, portable_atomic_sanitize_thread),
262 portable_atomic_no_cmpxchg16b_intrinsic,
263 )),
264 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
265 any(
266 target_feature = "cmpxchg16b",
267 portable_atomic_target_feature = "cmpxchg16b",
268 all(
269 feature = "fallback",
270 not(portable_atomic_no_outline_atomics),
271 not(any(target_env = "sgx", miri)),
272 ),
273 ),
274 ),
275 all(
276 target_arch = "riscv64",
277 not(portable_atomic_no_asm),
278 any(
279 target_feature = "experimental-zacas",
280 portable_atomic_target_feature = "experimental-zacas",
281 all(
282 feature = "fallback",
283 not(portable_atomic_no_outline_atomics),
284 any(test, portable_atomic_outline_atomics), any(target_os = "linux", target_os = "android"),
286 not(any(miri, portable_atomic_sanitize_thread)),
287 ),
288 ),
289 ),
290 all(
291 target_arch = "powerpc64",
292 portable_atomic_unstable_asm_experimental_arch,
293 any(
294 target_feature = "quadword-atomics",
295 portable_atomic_target_feature = "quadword-atomics",
296 all(
297 feature = "fallback",
298 not(portable_atomic_no_outline_atomics),
299 any(
300 all(
301 target_os = "linux",
302 any(
303 all(
304 target_env = "gnu",
305 any(target_endian = "little", not(target_feature = "crt-static")),
306 ),
307 all(
308 any(target_env = "musl", target_env = "ohos", target_env = "uclibc"),
309 not(target_feature = "crt-static"),
310 ),
311 portable_atomic_outline_atomics,
312 ),
313 ),
314 target_os = "android",
315 target_os = "freebsd",
316 target_os = "openbsd",
317 ),
318 not(any(miri, portable_atomic_sanitize_thread)),
319 ),
320 ),
321 ),
322 all(target_arch = "s390x", not(portable_atomic_no_asm)),
323 ))
324)]
325#[cfg_attr(
326 all(feature = "fallback", portable_atomic_no_cfg_target_has_atomic),
327 cfg(any(
328 not(portable_atomic_no_atomic_cas),
329 portable_atomic_unsafe_assume_single_core,
330 feature = "critical-section",
331 target_arch = "avr",
332 target_arch = "msp430",
333 ))
334)]
335#[cfg_attr(
336 all(feature = "fallback", not(portable_atomic_no_cfg_target_has_atomic)),
337 cfg(any(
338 target_has_atomic = "ptr",
339 portable_atomic_unsafe_assume_single_core,
340 feature = "critical-section",
341 target_arch = "avr",
342 target_arch = "msp430",
343 ))
344)]
345#[macro_use]
346mod atomic_128_macros {
347 #[macro_export]
348 macro_rules! cfg_has_atomic_128 {
349 ($($tt:tt)*) => {
350 $($tt)*
351 };
352 }
353 #[macro_export]
354 macro_rules! cfg_no_atomic_128 {
355 ($($tt:tt)*) => {};
356 }
357}
358#[cfg_attr(
359 not(feature = "fallback"),
360 cfg(not(any(
361 all(
362 target_arch = "aarch64",
363 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
364 ),
365 all(target_arch = "arm64ec", not(portable_atomic_no_asm)),
366 all(
367 target_arch = "x86_64",
368 not(all(
369 any(miri, portable_atomic_sanitize_thread),
370 portable_atomic_no_cmpxchg16b_intrinsic,
371 )),
372 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
373 any(
374 target_feature = "cmpxchg16b",
375 portable_atomic_target_feature = "cmpxchg16b",
376 all(
377 feature = "fallback",
378 not(portable_atomic_no_outline_atomics),
379 not(any(target_env = "sgx", miri)),
380 ),
381 ),
382 ),
383 all(
384 target_arch = "riscv64",
385 not(portable_atomic_no_asm),
386 any(
387 target_feature = "experimental-zacas",
388 portable_atomic_target_feature = "experimental-zacas",
389 all(
390 feature = "fallback",
391 not(portable_atomic_no_outline_atomics),
392 any(test, portable_atomic_outline_atomics), any(target_os = "linux", target_os = "android"),
394 not(any(miri, portable_atomic_sanitize_thread)),
395 ),
396 ),
397 ),
398 all(
399 target_arch = "powerpc64",
400 portable_atomic_unstable_asm_experimental_arch,
401 any(
402 target_feature = "quadword-atomics",
403 portable_atomic_target_feature = "quadword-atomics",
404 all(
405 feature = "fallback",
406 not(portable_atomic_no_outline_atomics),
407 any(
408 all(
409 target_os = "linux",
410 any(
411 all(
412 target_env = "gnu",
413 any(target_endian = "little", not(target_feature = "crt-static")),
414 ),
415 all(
416 any(target_env = "musl", target_env = "ohos", target_env = "uclibc"),
417 not(target_feature = "crt-static"),
418 ),
419 portable_atomic_outline_atomics,
420 ),
421 ),
422 target_os = "android",
423 target_os = "freebsd",
424 target_os = "openbsd",
425 ),
426 not(any(miri, portable_atomic_sanitize_thread)),
427 ),
428 ),
429 ),
430 all(target_arch = "s390x", not(portable_atomic_no_asm)),
431 )))
432)]
433#[cfg_attr(
434 all(feature = "fallback", portable_atomic_no_cfg_target_has_atomic),
435 cfg(not(any(
436 not(portable_atomic_no_atomic_cas),
437 portable_atomic_unsafe_assume_single_core,
438 feature = "critical-section",
439 target_arch = "avr",
440 target_arch = "msp430",
441 )))
442)]
443#[cfg_attr(
444 all(feature = "fallback", not(portable_atomic_no_cfg_target_has_atomic)),
445 cfg(not(any(
446 target_has_atomic = "ptr",
447 portable_atomic_unsafe_assume_single_core,
448 feature = "critical-section",
449 target_arch = "avr",
450 target_arch = "msp430",
451 )))
452)]
453#[macro_use]
454mod atomic_128_macros {
455 #[macro_export]
456 macro_rules! cfg_has_atomic_128 {
457 ($($tt:tt)*) => {};
458 }
459 #[macro_export]
460 macro_rules! cfg_no_atomic_128 {
461 ($($tt:tt)*) => {
462 $($tt)*
463 };
464 }
465}
466
467#[cfg_attr(
468 portable_atomic_no_cfg_target_has_atomic,
469 cfg(any(
470 not(portable_atomic_no_atomic_cas),
471 portable_atomic_unsafe_assume_single_core,
472 feature = "critical-section",
473 target_arch = "avr",
474 target_arch = "msp430",
475 ))
476)]
477#[cfg_attr(
478 not(portable_atomic_no_cfg_target_has_atomic),
479 cfg(any(
480 target_has_atomic = "ptr",
481 portable_atomic_unsafe_assume_single_core,
482 feature = "critical-section",
483 target_arch = "avr",
484 target_arch = "msp430",
485 ))
486)]
487#[macro_use]
488mod atomic_cas_macros {
489 #[macro_export]
490 macro_rules! cfg_has_atomic_cas {
491 ($($tt:tt)*) => {
492 $($tt)*
493 };
494 }
495 #[macro_export]
496 macro_rules! cfg_no_atomic_cas {
497 ($($tt:tt)*) => {};
498 }
499 macro_rules! cfg_has_atomic_cas_or_amo32 {
501 ($($tt:tt)*) => {
502 $($tt)*
503 };
504 }
505 macro_rules! cfg_has_atomic_cas_or_amo8 {
506 ($($tt:tt)*) => {
507 $($tt)*
508 };
509 }
510}
511#[cfg_attr(
512 portable_atomic_no_cfg_target_has_atomic,
513 cfg(not(any(
514 not(portable_atomic_no_atomic_cas),
515 portable_atomic_unsafe_assume_single_core,
516 feature = "critical-section",
517 target_arch = "avr",
518 target_arch = "msp430",
519 )))
520)]
521#[cfg_attr(
522 not(portable_atomic_no_cfg_target_has_atomic),
523 cfg(not(any(
524 target_has_atomic = "ptr",
525 portable_atomic_unsafe_assume_single_core,
526 feature = "critical-section",
527 target_arch = "avr",
528 target_arch = "msp430",
529 )))
530)]
531#[macro_use]
532mod atomic_cas_macros {
533 #[macro_export]
534 macro_rules! cfg_has_atomic_cas {
535 ($($tt:tt)*) => {};
536 }
537 #[macro_export]
538 macro_rules! cfg_no_atomic_cas {
539 ($($tt:tt)*) => {
540 $($tt)*
541 };
542 }
543 #[cfg_attr(
545 any(target_arch = "riscv32", target_arch = "riscv64"),
546 cfg(not(any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo")))
547 )]
548 macro_rules! cfg_has_atomic_cas_or_amo32 {
549 ($($tt:tt)*) => {};
550 }
551 #[cfg_attr(
552 any(target_arch = "riscv32", target_arch = "riscv64"),
553 cfg(not(any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo")))
554 )]
555 macro_rules! cfg_no_atomic_cas_or_amo32 {
556 ($($tt:tt)*) => {
557 $($tt)*
558 };
559 }
560 #[cfg(all(
561 any(target_arch = "riscv32", target_arch = "riscv64"),
562 any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo"),
563 ))]
564 macro_rules! cfg_has_atomic_cas_or_amo32 {
565 ($($tt:tt)*) => {
566 $($tt)*
567 };
568 }
569 #[cfg(all(
570 any(target_arch = "riscv32", target_arch = "riscv64"),
571 any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo"),
572 ))]
573 macro_rules! cfg_no_atomic_cas_or_amo32 {
574 ($($tt:tt)*) => {};
575 }
576 #[cfg_attr(
577 any(target_arch = "riscv32", target_arch = "riscv64"),
578 cfg(not(any(target_feature = "zabha", portable_atomic_target_feature = "zabha")))
579 )]
580 #[allow(unused_macros)]
581 macro_rules! cfg_has_atomic_cas_or_amo8 {
582 ($($tt:tt)*) => {};
583 }
584 #[cfg_attr(
585 any(target_arch = "riscv32", target_arch = "riscv64"),
586 cfg(not(any(target_feature = "zabha", portable_atomic_target_feature = "zabha")))
587 )]
588 #[cfg_attr(target_arch = "bpf", allow(unused_macros))]
589 macro_rules! cfg_no_atomic_cas_or_amo8 {
590 ($($tt:tt)*) => {
591 $($tt)*
592 };
593 }
594 #[cfg(all(
595 any(target_arch = "riscv32", target_arch = "riscv64"),
596 any(target_feature = "zabha", portable_atomic_target_feature = "zabha"),
597 ))]
598 macro_rules! cfg_has_atomic_cas_or_amo8 {
599 ($($tt:tt)*) => {
600 $($tt)*
601 };
602 }
603 #[cfg(all(
604 any(target_arch = "riscv32", target_arch = "riscv64"),
605 any(target_feature = "zabha", portable_atomic_target_feature = "zabha"),
606 ))]
607 macro_rules! cfg_no_atomic_cas_or_amo8 {
608 ($($tt:tt)*) => {};
609 }
610}
611
612mod check {
614 crate::cfg_has_atomic_8! { type _Atomic8 = (); }
615 crate::cfg_no_atomic_8! { type _Atomic8 = (); }
616 crate::cfg_has_atomic_16! { type _Atomic16 = (); }
617 crate::cfg_no_atomic_16! { type _Atomic16 = (); }
618 crate::cfg_has_atomic_32! { type _Atomic32 = (); }
619 crate::cfg_no_atomic_32! { type _Atomic32 = (); }
620 crate::cfg_has_atomic_64! { type _Atomic64 = (); }
621 crate::cfg_no_atomic_64! { type _Atomic64 = (); }
622 crate::cfg_has_atomic_128! { type _Atomic128 = (); }
623 crate::cfg_no_atomic_128! { type _Atomic128 = (); }
624 crate::cfg_has_atomic_ptr! { type _AtomicPtr = (); }
625 crate::cfg_no_atomic_ptr! { type _AtomicPtr = (); }
626 crate::cfg_has_atomic_cas! { type __AtomicPtr = (); }
627 crate::cfg_no_atomic_cas! { type __AtomicPtr = (); }
628 #[allow(unused_imports)]
629 use self::{
630 _Atomic128 as _, _Atomic16 as _, _Atomic32 as _, _Atomic64 as _, _Atomic8 as _,
631 _AtomicPtr as _, __AtomicPtr as _,
632 };
633}