1#![allow(unused_macros)]
2
3macro_rules! feature {
25 (
26 #![$meta:meta]
27 $($item:item)*
28 ) => {
29 $(
30 #[cfg($meta)]
31 #[cfg_attr(docsrs, doc(cfg($meta)))]
32 $item
33 )*
34 }
35}
36
37macro_rules! cfg_windows {
40 ($($item:item)*) => {
41 $(
42 #[cfg(any(all(doc, docsrs), windows))]
43 #[cfg_attr(docsrs, doc(cfg(windows)))]
44 $item
45 )*
46 }
47}
48
49macro_rules! cfg_unix {
52 ($($item:item)*) => {
53 $(
54 #[cfg(any(all(doc, docsrs), unix))]
55 #[cfg_attr(docsrs, doc(cfg(unix)))]
56 $item
57 )*
58 }
59}
60
61macro_rules! cfg_unix_or_wasi {
64 ($($item:item)*) => {
65 $(
66 #[cfg(any(all(doc, docsrs), unix, target_os = "wasi"))]
67 #[cfg_attr(docsrs, doc(cfg(any(unix, target_os = "wasi"))))]
68 $item
69 )*
70 }
71}
72
73macro_rules! cfg_unstable_windows {
76 ($($item:item)*) => {
77 $(
78 #[cfg(all(any(all(doc, docsrs), windows), tokio_unstable))]
79 #[cfg_attr(docsrs, doc(cfg(all(windows, tokio_unstable))))]
80 $item
81 )*
82 }
83}
84
85macro_rules! cfg_block_on {
87 ($($item:item)*) => {
88 $(
89 #[cfg(any(
90 feature = "fs",
91 feature = "net",
92 feature = "io-std",
93 feature = "rt",
94 ))]
95 $item
96 )*
97 }
98}
99
100macro_rules! cfg_atomic_waker_impl {
102 ($($item:item)*) => {
103 $(
104 #[cfg(any(
105 feature = "net",
106 feature = "process",
107 feature = "rt",
108 feature = "signal",
109 feature = "time",
110 ))]
111 #[cfg(not(loom))]
112 $item
113 )*
114 }
115}
116
117macro_rules! cfg_aio {
118 ($($item:item)*) => {
119 $(
120 #[cfg(all(any(docsrs, target_os = "freebsd"), feature = "net"))]
121 #[cfg_attr(docsrs,
122 doc(cfg(all(target_os = "freebsd", feature = "net")))
123 )]
124 $item
125 )*
126 }
127}
128
129macro_rules! cfg_fs {
130 ($($item:item)*) => {
131 $(
132 #[cfg(feature = "fs")]
133 #[cfg_attr(docsrs, doc(cfg(feature = "fs")))]
134 $item
135 )*
136 }
137}
138
139macro_rules! cfg_io_blocking {
140 ($($item:item)*) => {
141 $( #[cfg(any(
142 feature = "io-std",
143 feature = "fs",
144 all(windows, feature = "process"),
145 ))] $item )*
146 }
147}
148
149macro_rules! cfg_io_driver {
150 ($($item:item)*) => {
151 $(
152 #[cfg(any(
153 feature = "net",
154 all(unix, feature = "process"),
155 all(unix, feature = "signal"),
156 all(
157 tokio_unstable,
158 feature = "io-uring",
159 feature = "rt",
160 feature = "fs",
161 target_os = "linux"
162 )
163 ))]
164 #[cfg_attr(docsrs, doc(cfg(any(
165 feature = "net",
166 all(unix, feature = "process"),
167 all(unix, feature = "signal"),
168 all(
169 tokio_unstable,
170 feature = "io-uring",
171 feature = "rt",
172 feature = "fs",
173 target_os = "linux"
174 )
175 ))))]
176 $item
177 )*
178 }
179}
180
181macro_rules! cfg_io_driver_impl {
182 ( $( $item:item )* ) => {
183 $(
184 #[cfg(any(
185 feature = "net",
186 all(unix, feature = "process"),
187 all(unix, feature = "signal"),
188 all(
189 tokio_unstable,
190 feature = "io-uring",
191 feature = "rt",
192 feature = "fs",
193 target_os = "linux"
194 )
195 ))]
196 $item
197 )*
198 }
199}
200
201macro_rules! cfg_not_io_driver {
202 ($($item:item)*) => {
203 $(
204 #[cfg(not(any(
205 feature = "net",
206 all(unix, feature = "process"),
207 all(unix, feature = "signal"),
208 all(
209 tokio_unstable,
210 feature = "io-uring",
211 feature = "rt",
212 feature = "fs",
213 target_os = "linux"
214 )
215 )))]
216 $item
217 )*
218 }
219}
220
221macro_rules! cfg_io_readiness {
222 ($($item:item)*) => {
223 $(
224 #[cfg(feature = "net")]
225 $item
226 )*
227 }
228}
229
230macro_rules! cfg_io_std {
231 ($($item:item)*) => {
232 $(
233 #[cfg(feature = "io-std")]
234 #[cfg_attr(docsrs, doc(cfg(feature = "io-std")))]
235 $item
236 )*
237 }
238}
239
240macro_rules! cfg_io_util {
241 ($($item:item)*) => {
242 $(
243 #[cfg(feature = "io-util")]
244 #[cfg_attr(docsrs, doc(cfg(feature = "io-util")))]
245 $item
246 )*
247 }
248}
249
250macro_rules! cfg_not_io_util {
251 ($($item:item)*) => {
252 $( #[cfg(not(feature = "io-util"))] $item )*
253 }
254}
255
256macro_rules! cfg_loom {
257 ($($item:item)*) => {
258 $( #[cfg(loom)] $item )*
259 }
260}
261
262macro_rules! cfg_not_loom {
263 ($($item:item)*) => {
264 $( #[cfg(not(loom))] $item )*
265 }
266}
267
268macro_rules! cfg_macros {
269 ($($item:item)*) => {
270 $(
271 #[cfg(feature = "macros")]
272 #[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
273 $item
274 )*
275 }
276}
277
278macro_rules! cfg_unstable_metrics {
279 ($($item:item)*) => {
280 $(
281 #[cfg(tokio_unstable)]
282 #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
283 $item
284 )*
285 }
286}
287
288macro_rules! cfg_64bit_metrics {
290 ($($item:item)*) => {
291 $(
292 #[cfg(target_has_atomic = "64")]
293 #[cfg_attr(docsrs, doc(cfg(target_has_atomic = "64")))]
294 $item
295 )*
296 }
297}
298
299macro_rules! cfg_no_64bit_metrics {
300 ($($item:item)*) => {
301 $(
302 #[cfg(not(target_has_atomic = "64"))]
303 $item
304 )*
305 }
306}
307
308macro_rules! cfg_not_unstable_metrics {
309 ($($item:item)*) => {
310 $(
311 #[cfg(not(tokio_unstable))]
312 $item
313 )*
314 }
315}
316
317macro_rules! cfg_not_rt_and_metrics_and_net {
318 ($($item:item)*) => {
319 $( #[cfg(not(all(feature = "net", feature = "rt", tokio_unstable)))]$item )*
320 }
321}
322
323macro_rules! cfg_net_or_process {
324 ($($item:item)*) => {
325 $(
326 #[cfg(any(feature = "net", feature = "process"))]
327 #[cfg_attr(docsrs, doc(cfg(any(feature = "net", feature = "process"))))]
328 $item
329 )*
330 }
331}
332
333macro_rules! cfg_net {
334 ($($item:item)*) => {
335 $(
336 #[cfg(feature = "net")]
337 #[cfg_attr(docsrs, doc(cfg(feature = "net")))]
338 $item
339 )*
340 }
341}
342
343macro_rules! cfg_net_or_uring {
344 ($($item:item)*) => {
345 $(
346 #[cfg(any(
347 feature = "net",
348 all(
349 tokio_unstable,
350 feature = "io-uring",
351 feature = "rt",
352 feature = "fs",
353 target_os = "linux",
354 )
355 ))]
356 #[cfg_attr(
357 docsrs,
358 doc(cfg(any(
359 feature = "net",
360 all(
361 tokio_unstable,
362 feature = "io-uring",
363 feature = "rt",
364 feature = "fs",
365 target_os = "linux",
366 )
367 )))
368 )]
369 $item
370 )*
371 }
372}
373
374macro_rules! cfg_net_unix {
375 ($($item:item)*) => {
376 $(
377 #[cfg(all(unix, feature = "net"))]
378 #[cfg_attr(docsrs, doc(cfg(all(unix, feature = "net"))))]
379 $item
380 )*
381 }
382}
383
384macro_rules! cfg_net_windows {
385 ($($item:item)*) => {
386 $(
387 #[cfg(all(any(all(doc, docsrs), windows), feature = "net"))]
388 #[cfg_attr(docsrs, doc(cfg(all(windows, feature = "net"))))]
389 $item
390 )*
391 }
392}
393
394macro_rules! cfg_process {
395 ($($item:item)*) => {
396 $(
397 #[cfg(feature = "process")]
398 #[cfg_attr(docsrs, doc(cfg(feature = "process")))]
399 #[cfg(not(loom))]
400 #[cfg(not(target_os = "wasi"))]
401 $item
402 )*
403 }
404}
405
406macro_rules! cfg_process_driver {
407 ($($item:item)*) => {
408 #[cfg(unix)]
409 #[cfg(not(loom))]
410 cfg_process! { $($item)* }
411 }
412}
413
414macro_rules! cfg_not_process_driver {
415 ($($item:item)*) => {
416 $(
417 #[cfg(not(all(unix, not(loom), feature = "process")))]
418 $item
419 )*
420 }
421}
422
423macro_rules! cfg_signal {
424 ($($item:item)*) => {
425 $(
426 #[cfg(feature = "signal")]
427 #[cfg_attr(docsrs, doc(cfg(feature = "signal")))]
428 #[cfg(not(loom))]
429 #[cfg(not(target_os = "wasi"))]
430 $item
431 )*
432 }
433}
434
435macro_rules! cfg_signal_internal {
436 ($($item:item)*) => {
437 $(
438 #[cfg(any(feature = "signal", all(unix, feature = "process")))]
439 #[cfg(not(loom))]
440 $item
441 )*
442 }
443}
444
445macro_rules! cfg_signal_internal_and_unix {
446 ($($item:item)*) => {
447 #[cfg(unix)]
448 cfg_signal_internal! { $($item)* }
449 }
450}
451
452macro_rules! cfg_not_signal_internal {
453 ($($item:item)*) => {
454 $(
455 #[cfg(any(loom, not(unix), not(any(feature = "signal", all(unix, feature = "process")))))]
456 $item
457 )*
458 }
459}
460
461macro_rules! cfg_sync {
462 ($($item:item)*) => {
463 $(
464 #[cfg(feature = "sync")]
465 #[cfg_attr(docsrs, doc(cfg(feature = "sync")))]
466 $item
467 )*
468 }
469}
470
471macro_rules! cfg_not_sync {
472 ($($item:item)*) => {
473 $( #[cfg(not(feature = "sync"))] $item )*
474 }
475}
476
477macro_rules! cfg_rt {
478 ($($item:item)*) => {
479 $(
480 #[cfg(feature = "rt")]
481 #[cfg_attr(docsrs, doc(cfg(feature = "rt")))]
482 $item
483 )*
484 }
485}
486
487macro_rules! cfg_not_rt {
488 ($($item:item)*) => {
489 $( #[cfg(not(feature = "rt"))] $item )*
490 }
491}
492
493macro_rules! cfg_rt_multi_thread {
494 ($($item:item)*) => {
495 $(
496 #[cfg(feature = "rt-multi-thread")]
497 #[cfg_attr(docsrs, doc(cfg(feature = "rt-multi-thread")))]
498 $item
499 )*
500 }
501}
502
503macro_rules! cfg_not_rt_multi_thread {
504 ($($item:item)*) => {
505 $( #[cfg(not(feature = "rt-multi-thread"))] $item )*
506 }
507}
508
509macro_rules! cfg_taskdump {
510 ($($item:item)*) => {
511 $(
512 #[cfg(all(
513 tokio_unstable,
514 feature = "taskdump",
515 feature = "rt",
516 target_os = "linux",
517 any(
518 target_arch = "aarch64",
519 target_arch = "x86",
520 target_arch = "x86_64"
521 )
522 ))]
523 $item
524 )*
525 };
526}
527
528macro_rules! cfg_not_taskdump {
529 ($($item:item)*) => {
530 $(
531 #[cfg(not(all(
532 tokio_unstable,
533 feature = "taskdump",
534 feature = "rt",
535 target_os = "linux",
536 any(
537 target_arch = "aarch64",
538 target_arch = "x86",
539 target_arch = "x86_64"
540 )
541 )))]
542 $item
543 )*
544 };
545}
546
547macro_rules! cfg_test_util {
548 ($($item:item)*) => {
549 $(
550 #[cfg(feature = "test-util")]
551 #[cfg_attr(docsrs, doc(cfg(feature = "test-util")))]
552 $item
553 )*
554 }
555}
556
557macro_rules! cfg_not_test_util {
558 ($($item:item)*) => {
559 $( #[cfg(not(feature = "test-util"))] $item )*
560 }
561}
562
563macro_rules! cfg_time {
564 ($($item:item)*) => {
565 $(
566 #[cfg(feature = "time")]
567 #[cfg_attr(docsrs, doc(cfg(feature = "time")))]
568 $item
569 )*
570 }
571}
572
573macro_rules! cfg_not_time {
574 ($($item:item)*) => {
575 $( #[cfg(not(feature = "time"))] $item )*
576 }
577}
578
579macro_rules! cfg_trace {
580 ($($item:item)*) => {
581 $(
582 #[cfg(all(tokio_unstable, feature = "tracing"))]
583 #[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
584 $item
585 )*
586 };
587}
588
589macro_rules! cfg_unstable {
590 ($($item:item)*) => {
591 $(
592 #[cfg(tokio_unstable)]
593 #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
594 $item
595 )*
596 };
597}
598
599macro_rules! cfg_not_trace {
600 ($($item:item)*) => {
601 $(
602 #[cfg(any(not(tokio_unstable), not(feature = "tracing")))]
603 $item
604 )*
605 }
606}
607
608macro_rules! cfg_coop {
609 ($($item:item)*) => {
610 $(
611 #[cfg(any(
612 feature = "fs",
613 feature = "io-std",
614 feature = "net",
615 feature = "process",
616 feature = "rt",
617 feature = "signal",
618 feature = "sync",
619 feature = "time",
620 ))]
621 $item
622 )*
623 }
624}
625
626macro_rules! cfg_not_coop {
627 ($($item:item)*) => {
628 $(
629 #[cfg(not(any(
630 feature = "fs",
631 feature = "io-std",
632 feature = "net",
633 feature = "process",
634 feature = "rt",
635 feature = "signal",
636 feature = "sync",
637 feature = "time",
638 )))]
639 $item
640 )*
641 }
642}
643
644macro_rules! cfg_has_atomic_u64 {
645 ($($item:item)*) => {
646 $(
647 #[cfg(target_has_atomic = "64")]
648 $item
649 )*
650 }
651}
652
653macro_rules! cfg_not_has_atomic_u64 {
654 ($($item:item)*) => {
655 $(
656 #[cfg(not(target_has_atomic = "64"))]
657 $item
658 )*
659 }
660}
661
662macro_rules! cfg_has_const_mutex_new {
663 ($($item:item)*) => {
664 $(
665 #[cfg(not(all(loom, test)))]
666 $item
667 )*
668 }
669}
670
671macro_rules! cfg_not_has_const_mutex_new {
672 ($($item:item)*) => {
673 $(
674 #[cfg(all(loom, test))]
675 $item
676 )*
677 }
678}
679
680macro_rules! cfg_not_wasi {
681 ($($item:item)*) => {
682 $(
683 #[cfg(not(target_os = "wasi"))]
684 $item
685 )*
686 }
687}
688
689macro_rules! cfg_not_wasip1 {
690 ($($item:item)*) => {
691 $(
692 #[cfg(not(all(target_os = "wasi", target_env = "p1")))]
693 $item
694 )*
695 }
696}
697
698macro_rules! cfg_is_wasm_not_wasi {
699 ($($item:item)*) => {
700 $(
701 #[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
702 $item
703 )*
704 }
705}
706
707macro_rules! cfg_metrics_variant {
710 (stable: {$($stable_code:tt)*}, unstable: {$($unstable_code:tt)*}) => {
711 cfg_not_unstable_metrics! {
712 $($stable_code)*
713 }
714
715 cfg_unstable_metrics! {
716 $($unstable_code)*
717 }
718 }
719}
720
721macro_rules! cfg_io_uring {
722 ($($item:item)*) => {
723 $(
724 #[cfg(all(
725 tokio_unstable,
726 feature = "io-uring",
727 feature = "rt",
728 feature = "fs",
729 target_os = "linux",
730 ))]
731 $item
732 )*
733 };
734}