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 not(portable_atomic_pre_llvm_19),
162 any(
163 target_feature = "experimental-zacas",
164 portable_atomic_target_feature = "experimental-zacas",
165 all(
166 feature = "fallback",
167 not(portable_atomic_no_outline_atomics),
168 any(test, portable_atomic_outline_atomics), any(target_os = "linux", target_os = "android"),
170 ),
171 ),
172 ),
173 ))
174)]
175#[macro_use]
176mod atomic_64_macros {
177 #[macro_export]
178 macro_rules! cfg_has_atomic_64 {
179 ($($tt:tt)*) => {
180 $($tt)*
181 };
182 }
183 #[macro_export]
184 macro_rules! cfg_no_atomic_64 {
185 ($($tt:tt)*) => {};
186 }
187}
188#[cfg_attr(
189 portable_atomic_no_cfg_target_has_atomic,
190 cfg(not(any(
191 all(
192 feature = "fallback",
193 any(
194 not(portable_atomic_no_atomic_cas),
195 portable_atomic_unsafe_assume_single_core,
196 feature = "critical-section",
197 target_arch = "avr",
198 target_arch = "msp430",
199 ),
200 ),
201 not(portable_atomic_no_atomic_64),
202 not(any(target_pointer_width = "16", target_pointer_width = "32")),
203 )))
204)]
205#[cfg_attr(
206 not(portable_atomic_no_cfg_target_has_atomic),
207 cfg(not(any(
208 all(
209 feature = "fallback",
210 any(
211 target_has_atomic = "ptr",
212 portable_atomic_unsafe_assume_single_core,
213 feature = "critical-section",
214 target_arch = "avr",
215 target_arch = "msp430",
216 ),
217 ),
218 target_has_atomic = "64",
219 not(any(target_pointer_width = "16", target_pointer_width = "32")),
220 all(
221 target_arch = "riscv32",
222 not(any(miri, portable_atomic_sanitize_thread)),
223 not(portable_atomic_no_asm),
224 not(portable_atomic_pre_llvm_19),
225 any(
226 target_feature = "experimental-zacas",
227 portable_atomic_target_feature = "experimental-zacas",
228 all(
229 feature = "fallback",
230 not(portable_atomic_no_outline_atomics),
231 any(test, portable_atomic_outline_atomics), any(target_os = "linux", target_os = "android"),
233 ),
234 ),
235 ),
236 )))
237)]
238#[macro_use]
239mod atomic_64_macros {
240 #[macro_export]
241 macro_rules! cfg_has_atomic_64 {
242 ($($tt:tt)*) => {};
243 }
244 #[macro_export]
245 macro_rules! cfg_no_atomic_64 {
246 ($($tt:tt)*) => {
247 $($tt)*
248 };
249 }
250}
251
252#[cfg_attr(
253 not(feature = "fallback"),
254 cfg(any(
255 all(
256 target_arch = "aarch64",
257 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
258 ),
259 all(target_arch = "arm64ec", portable_atomic_unstable_asm_experimental_arch),
260 all(
261 target_arch = "x86_64",
262 not(all(
263 any(miri, portable_atomic_sanitize_thread),
264 portable_atomic_no_cmpxchg16b_intrinsic,
265 )),
266 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
267 any(
268 target_feature = "cmpxchg16b",
269 portable_atomic_target_feature = "cmpxchg16b",
270 all(
271 feature = "fallback",
272 not(portable_atomic_no_outline_atomics),
273 not(any(target_env = "sgx", miri)),
274 ),
275 ),
276 ),
277 all(
278 target_arch = "riscv64",
279 not(portable_atomic_no_asm),
280 not(portable_atomic_pre_llvm_19),
281 any(
282 target_feature = "experimental-zacas",
283 portable_atomic_target_feature = "experimental-zacas",
284 all(
285 feature = "fallback",
286 not(portable_atomic_no_outline_atomics),
287 any(test, portable_atomic_outline_atomics), any(target_os = "linux", target_os = "android"),
289 not(any(miri, portable_atomic_sanitize_thread)),
290 ),
291 ),
292 ),
293 all(
294 target_arch = "powerpc64",
295 portable_atomic_unstable_asm_experimental_arch,
296 any(
297 target_feature = "quadword-atomics",
298 portable_atomic_target_feature = "quadword-atomics",
299 all(
300 feature = "fallback",
301 not(portable_atomic_no_outline_atomics),
302 portable_atomic_outline_atomics, any(
304 all(
305 target_os = "linux",
306 any(
307 target_env = "gnu",
308 all(
309 any(target_env = "musl", target_env = "ohos"),
310 not(target_feature = "crt-static"),
311 ),
312 portable_atomic_outline_atomics,
313 ),
314 ),
315 target_os = "android",
316 target_os = "freebsd",
317 all(target_os = "openbsd", portable_atomic_outline_atomics),
318 ),
319 not(any(miri, portable_atomic_sanitize_thread)),
320 ),
321 ),
322 ),
323 all(target_arch = "s390x", portable_atomic_unstable_asm_experimental_arch),
324 ))
325)]
326#[cfg_attr(
327 all(feature = "fallback", portable_atomic_no_cfg_target_has_atomic),
328 cfg(any(
329 not(portable_atomic_no_atomic_cas),
330 portable_atomic_unsafe_assume_single_core,
331 feature = "critical-section",
332 target_arch = "avr",
333 target_arch = "msp430",
334 ))
335)]
336#[cfg_attr(
337 all(feature = "fallback", not(portable_atomic_no_cfg_target_has_atomic)),
338 cfg(any(
339 target_has_atomic = "ptr",
340 portable_atomic_unsafe_assume_single_core,
341 feature = "critical-section",
342 target_arch = "avr",
343 target_arch = "msp430",
344 ))
345)]
346#[macro_use]
347mod atomic_128_macros {
348 #[macro_export]
349 macro_rules! cfg_has_atomic_128 {
350 ($($tt:tt)*) => {
351 $($tt)*
352 };
353 }
354 #[macro_export]
355 macro_rules! cfg_no_atomic_128 {
356 ($($tt:tt)*) => {};
357 }
358}
359#[cfg_attr(
360 not(feature = "fallback"),
361 cfg(not(any(
362 all(
363 target_arch = "aarch64",
364 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
365 ),
366 all(target_arch = "arm64ec", portable_atomic_unstable_asm_experimental_arch),
367 all(
368 target_arch = "x86_64",
369 not(all(
370 any(miri, portable_atomic_sanitize_thread),
371 portable_atomic_no_cmpxchg16b_intrinsic,
372 )),
373 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
374 any(
375 target_feature = "cmpxchg16b",
376 portable_atomic_target_feature = "cmpxchg16b",
377 all(
378 feature = "fallback",
379 not(portable_atomic_no_outline_atomics),
380 not(any(target_env = "sgx", miri)),
381 ),
382 ),
383 ),
384 all(
385 target_arch = "riscv64",
386 not(portable_atomic_no_asm),
387 not(portable_atomic_pre_llvm_19),
388 any(
389 target_feature = "experimental-zacas",
390 portable_atomic_target_feature = "experimental-zacas",
391 all(
392 feature = "fallback",
393 not(portable_atomic_no_outline_atomics),
394 any(test, portable_atomic_outline_atomics), any(target_os = "linux", target_os = "android"),
396 not(any(miri, portable_atomic_sanitize_thread)),
397 ),
398 ),
399 ),
400 all(
401 target_arch = "powerpc64",
402 portable_atomic_unstable_asm_experimental_arch,
403 any(
404 target_feature = "quadword-atomics",
405 portable_atomic_target_feature = "quadword-atomics",
406 all(
407 feature = "fallback",
408 not(portable_atomic_no_outline_atomics),
409 portable_atomic_outline_atomics, any(
411 all(
412 target_os = "linux",
413 any(
414 target_env = "gnu",
415 all(
416 any(target_env = "musl", target_env = "ohos"),
417 not(target_feature = "crt-static"),
418 ),
419 portable_atomic_outline_atomics,
420 ),
421 ),
422 target_os = "android",
423 target_os = "freebsd",
424 all(target_os = "openbsd", portable_atomic_outline_atomics),
425 ),
426 not(any(miri, portable_atomic_sanitize_thread)),
427 ),
428 ),
429 ),
430 all(target_arch = "s390x", portable_atomic_unstable_asm_experimental_arch),
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 {
630 _Atomic128 as _, _Atomic16 as _, _Atomic32 as _, _Atomic64 as _, _Atomic8 as _,
631 _AtomicPtr as _, __AtomicPtr as _,
632 };
633}