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 not(all(
250 any(miri, portable_atomic_sanitize_thread),
251 not(portable_atomic_atomic_intrinsics),
252 )),
253 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
254 ),
255 all(
256 target_arch = "arm64ec",
257 not(all(
258 any(miri, portable_atomic_sanitize_thread),
259 not(portable_atomic_atomic_intrinsics),
260 )),
261 not(portable_atomic_no_asm),
262 ),
263 all(
264 target_arch = "x86_64",
265 not(all(
266 any(miri, portable_atomic_sanitize_thread),
267 portable_atomic_no_cmpxchg16b_intrinsic,
268 )),
269 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
270 any(target_feature = "cmpxchg16b", portable_atomic_target_feature = "cmpxchg16b"),
271 ),
272 all(
273 target_arch = "riscv64",
274 not(any(miri, portable_atomic_sanitize_thread)),
275 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
276 any(target_feature = "zacas", portable_atomic_target_feature = "zacas"),
277 ),
278 all(
279 target_arch = "powerpc64",
280 not(all(
281 any(miri, portable_atomic_sanitize_thread),
282 not(portable_atomic_atomic_intrinsics),
283 )),
284 portable_atomic_unstable_asm_experimental_arch,
285 any(
286 target_feature = "quadword-atomics",
287 portable_atomic_target_feature = "quadword-atomics",
288 ),
289 ),
290 all(
291 target_arch = "s390x",
292 not(all(
293 any(miri, portable_atomic_sanitize_thread),
294 not(portable_atomic_atomic_intrinsics),
295 )),
296 not(portable_atomic_no_asm),
297 ),
298 ))
299)]
300#[cfg_attr(
301 all(feature = "fallback", portable_atomic_no_cfg_target_has_atomic),
302 cfg(any(
303 not(portable_atomic_no_atomic_cas),
304 portable_atomic_unsafe_assume_single_core,
305 feature = "critical-section",
306 target_arch = "avr",
307 target_arch = "msp430",
308 ))
309)]
310#[cfg_attr(
311 all(feature = "fallback", not(portable_atomic_no_cfg_target_has_atomic)),
312 cfg(any(
313 target_has_atomic = "ptr",
314 portable_atomic_unsafe_assume_single_core,
315 feature = "critical-section",
316 target_arch = "avr",
317 target_arch = "msp430",
318 ))
319)]
320#[macro_use]
321mod atomic_128_macros {
322 #[macro_export]
323 macro_rules! cfg_has_atomic_128 {
324 ($($tt:tt)*) => {
325 $($tt)*
326 };
327 }
328 #[macro_export]
329 macro_rules! cfg_no_atomic_128 {
330 ($($tt:tt)*) => {};
331 }
332}
333#[cfg_attr(
334 not(feature = "fallback"),
335 cfg(not(any(
336 all(
337 target_arch = "aarch64",
338 not(all(
339 any(miri, portable_atomic_sanitize_thread),
340 not(portable_atomic_atomic_intrinsics),
341 )),
342 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
343 ),
344 all(
345 target_arch = "arm64ec",
346 not(all(
347 any(miri, portable_atomic_sanitize_thread),
348 not(portable_atomic_atomic_intrinsics),
349 )),
350 not(portable_atomic_no_asm),
351 ),
352 all(
353 target_arch = "x86_64",
354 not(all(
355 any(miri, portable_atomic_sanitize_thread),
356 portable_atomic_no_cmpxchg16b_intrinsic,
357 )),
358 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
359 any(target_feature = "cmpxchg16b", portable_atomic_target_feature = "cmpxchg16b"),
360 ),
361 all(
362 target_arch = "riscv64",
363 not(any(miri, portable_atomic_sanitize_thread)),
364 any(not(portable_atomic_no_asm), portable_atomic_unstable_asm),
365 any(target_feature = "zacas", portable_atomic_target_feature = "zacas"),
366 ),
367 all(
368 target_arch = "powerpc64",
369 not(all(
370 any(miri, portable_atomic_sanitize_thread),
371 not(portable_atomic_atomic_intrinsics),
372 )),
373 portable_atomic_unstable_asm_experimental_arch,
374 any(
375 target_feature = "quadword-atomics",
376 portable_atomic_target_feature = "quadword-atomics",
377 ),
378 ),
379 all(
380 target_arch = "s390x",
381 not(all(
382 any(miri, portable_atomic_sanitize_thread),
383 not(portable_atomic_atomic_intrinsics),
384 )),
385 not(portable_atomic_no_asm),
386 ),
387 )))
388)]
389#[cfg_attr(
390 all(feature = "fallback", portable_atomic_no_cfg_target_has_atomic),
391 cfg(not(any(
392 not(portable_atomic_no_atomic_cas),
393 portable_atomic_unsafe_assume_single_core,
394 feature = "critical-section",
395 target_arch = "avr",
396 target_arch = "msp430",
397 )))
398)]
399#[cfg_attr(
400 all(feature = "fallback", not(portable_atomic_no_cfg_target_has_atomic)),
401 cfg(not(any(
402 target_has_atomic = "ptr",
403 portable_atomic_unsafe_assume_single_core,
404 feature = "critical-section",
405 target_arch = "avr",
406 target_arch = "msp430",
407 )))
408)]
409#[macro_use]
410mod atomic_128_macros {
411 #[macro_export]
412 macro_rules! cfg_has_atomic_128 {
413 ($($tt:tt)*) => {};
414 }
415 #[macro_export]
416 macro_rules! cfg_no_atomic_128 {
417 ($($tt:tt)*) => {
418 $($tt)*
419 };
420 }
421}
422
423#[cfg_attr(
424 portable_atomic_no_cfg_target_has_atomic,
425 cfg(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(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 $($tt)*
449 };
450 }
451 #[macro_export]
452 macro_rules! cfg_no_atomic_cas {
453 ($($tt:tt)*) => {};
454 }
455 macro_rules! cfg_has_atomic_cas_or_amo32 {
457 ($($tt:tt)*) => {
458 $($tt)*
459 };
460 }
461 macro_rules! cfg_has_atomic_cas_or_amo8 {
462 ($($tt:tt)*) => {
463 $($tt)*
464 };
465 }
466}
467#[cfg_attr(
468 portable_atomic_no_cfg_target_has_atomic,
469 cfg(not(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(not(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 }
493 #[macro_export]
494 macro_rules! cfg_no_atomic_cas {
495 ($($tt:tt)*) => {
496 $($tt)*
497 };
498 }
499 #[cfg_attr(
501 any(target_arch = "riscv32", target_arch = "riscv64"),
502 cfg(not(any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo")))
503 )]
504 macro_rules! cfg_has_atomic_cas_or_amo32 {
505 ($($tt:tt)*) => {};
506 }
507 #[cfg_attr(
508 any(target_arch = "riscv32", target_arch = "riscv64"),
509 cfg(not(any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo")))
510 )]
511 macro_rules! cfg_no_atomic_cas_or_amo32 {
512 ($($tt:tt)*) => {
513 $($tt)*
514 };
515 }
516 #[cfg(all(
517 any(target_arch = "riscv32", target_arch = "riscv64"),
518 any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo"),
519 ))]
520 macro_rules! cfg_has_atomic_cas_or_amo32 {
521 ($($tt:tt)*) => {
522 $($tt)*
523 };
524 }
525 #[cfg(all(
526 any(target_arch = "riscv32", target_arch = "riscv64"),
527 any(target_feature = "zaamo", portable_atomic_target_feature = "zaamo"),
528 ))]
529 macro_rules! cfg_no_atomic_cas_or_amo32 {
530 ($($tt:tt)*) => {};
531 }
532 #[cfg_attr(
533 any(target_arch = "riscv32", target_arch = "riscv64"),
534 cfg(not(any(target_feature = "zabha", portable_atomic_target_feature = "zabha")))
535 )]
536 #[allow(unused_macros)]
537 macro_rules! cfg_has_atomic_cas_or_amo8 {
538 ($($tt:tt)*) => {};
539 }
540 #[cfg_attr(
541 any(target_arch = "riscv32", target_arch = "riscv64"),
542 cfg(not(any(target_feature = "zabha", portable_atomic_target_feature = "zabha")))
543 )]
544 #[cfg_attr(target_arch = "bpf", allow(unused_macros))]
545 macro_rules! cfg_no_atomic_cas_or_amo8 {
546 ($($tt:tt)*) => {
547 $($tt)*
548 };
549 }
550 #[cfg(all(
551 any(target_arch = "riscv32", target_arch = "riscv64"),
552 any(target_feature = "zabha", portable_atomic_target_feature = "zabha"),
553 ))]
554 macro_rules! cfg_has_atomic_cas_or_amo8 {
555 ($($tt:tt)*) => {
556 $($tt)*
557 };
558 }
559 #[cfg(all(
560 any(target_arch = "riscv32", target_arch = "riscv64"),
561 any(target_feature = "zabha", portable_atomic_target_feature = "zabha"),
562 ))]
563 macro_rules! cfg_no_atomic_cas_or_amo8 {
564 ($($tt:tt)*) => {};
565 }
566}
567
568mod check {
570 crate::cfg_has_atomic_8! { type _Atomic8 = (); }
571 crate::cfg_no_atomic_8! { type _Atomic8 = (); }
572 crate::cfg_has_atomic_16! { type _Atomic16 = (); }
573 crate::cfg_no_atomic_16! { type _Atomic16 = (); }
574 crate::cfg_has_atomic_32! { type _Atomic32 = (); }
575 crate::cfg_no_atomic_32! { type _Atomic32 = (); }
576 crate::cfg_has_atomic_64! { type _Atomic64 = (); }
577 crate::cfg_no_atomic_64! { type _Atomic64 = (); }
578 crate::cfg_has_atomic_128! { type _Atomic128 = (); }
579 crate::cfg_no_atomic_128! { type _Atomic128 = (); }
580 crate::cfg_has_atomic_ptr! { type _AtomicPtr = (); }
581 crate::cfg_no_atomic_ptr! { type _AtomicPtr = (); }
582 crate::cfg_has_atomic_cas! { type __AtomicPtr = (); }
583 crate::cfg_no_atomic_cas! { type __AtomicPtr = (); }
584 #[allow(unused_imports)]
585 use self::{
586 __AtomicPtr as _, _Atomic8 as _, _Atomic16 as _, _Atomic32 as _, _Atomic64 as _,
587 _Atomic128 as _, _AtomicPtr as _,
588 };
589}