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 #[cfg_attr(
524 docsrs,
525 doc(cfg(all(
526 tokio_unstable,
527 feature = "taskdump",
528 feature = "rt",
529 target_os = "linux",
530 any(
531 target_arch = "aarch64",
532 target_arch = "x86",
533 target_arch = "x86_64"
534 )
535 )))
536 )]
537 $item
538 )*
539 };
540}
541
542macro_rules! cfg_not_taskdump {
543 ($($item:item)*) => {
544 $(
545 #[cfg(not(all(
546 tokio_unstable,
547 feature = "taskdump",
548 feature = "rt",
549 target_os = "linux",
550 any(
551 target_arch = "aarch64",
552 target_arch = "x86",
553 target_arch = "x86_64"
554 )
555 )))]
556 $item
557 )*
558 };
559}
560
561macro_rules! cfg_test_util {
562 ($($item:item)*) => {
563 $(
564 #[cfg(feature = "test-util")]
565 #[cfg_attr(docsrs, doc(cfg(feature = "test-util")))]
566 $item
567 )*
568 }
569}
570
571macro_rules! cfg_not_test_util {
572 ($($item:item)*) => {
573 $( #[cfg(not(feature = "test-util"))] $item )*
574 }
575}
576
577macro_rules! cfg_time {
578 ($($item:item)*) => {
579 $(
580 #[cfg(feature = "time")]
581 #[cfg_attr(docsrs, doc(cfg(feature = "time")))]
582 $item
583 )*
584 }
585}
586
587macro_rules! cfg_not_time {
588 ($($item:item)*) => {
589 $( #[cfg(not(feature = "time"))] $item )*
590 }
591}
592
593macro_rules! cfg_trace {
594 ($($item:item)*) => {
595 $(
596 #[cfg(all(tokio_unstable, feature = "tracing"))]
597 #[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
598 $item
599 )*
600 };
601}
602
603macro_rules! cfg_unstable {
604 ($($item:item)*) => {
605 $(
606 #[cfg(tokio_unstable)]
607 #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
608 $item
609 )*
610 };
611}
612
613macro_rules! cfg_not_trace {
614 ($($item:item)*) => {
615 $(
616 #[cfg(any(not(tokio_unstable), not(feature = "tracing")))]
617 $item
618 )*
619 }
620}
621
622macro_rules! cfg_coop {
623 ($($item:item)*) => {
624 $(
625 #[cfg(any(
626 feature = "fs",
627 feature = "io-std",
628 feature = "net",
629 feature = "process",
630 feature = "rt",
631 feature = "signal",
632 feature = "sync",
633 feature = "time",
634 ))]
635 $item
636 )*
637 }
638}
639
640macro_rules! cfg_not_coop {
641 ($($item:item)*) => {
642 $(
643 #[cfg(not(any(
644 feature = "fs",
645 feature = "io-std",
646 feature = "net",
647 feature = "process",
648 feature = "rt",
649 feature = "signal",
650 feature = "sync",
651 feature = "time",
652 )))]
653 $item
654 )*
655 }
656}
657
658macro_rules! cfg_has_atomic_u64 {
659 ($($item:item)*) => {
660 $(
661 #[cfg(target_has_atomic = "64")]
662 $item
663 )*
664 }
665}
666
667macro_rules! cfg_not_has_atomic_u64 {
668 ($($item:item)*) => {
669 $(
670 #[cfg(not(target_has_atomic = "64"))]
671 $item
672 )*
673 }
674}
675
676macro_rules! cfg_has_const_mutex_new {
677 ($($item:item)*) => {
678 $(
679 #[cfg(not(all(loom, test)))]
680 $item
681 )*
682 }
683}
684
685macro_rules! cfg_not_has_const_mutex_new {
686 ($($item:item)*) => {
687 $(
688 #[cfg(all(loom, test))]
689 $item
690 )*
691 }
692}
693
694macro_rules! cfg_not_wasi {
695 ($($item:item)*) => {
696 $(
697 #[cfg(not(target_os = "wasi"))]
698 $item
699 )*
700 }
701}
702
703macro_rules! cfg_not_wasip1 {
704 ($($item:item)*) => {
705 $(
706 #[cfg(not(all(target_os = "wasi", target_env = "p1")))]
707 $item
708 )*
709 }
710}
711
712macro_rules! cfg_is_wasm_not_wasi {
713 ($($item:item)*) => {
714 $(
715 #[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
716 $item
717 )*
718 }
719}
720
721macro_rules! cfg_metrics_variant {
724 (stable: {$($stable_code:tt)*}, unstable: {$($unstable_code:tt)*}) => {
725 cfg_not_unstable_metrics! {
726 $($stable_code)*
727 }
728
729 cfg_unstable_metrics! {
730 $($unstable_code)*
731 }
732 }
733}
734
735macro_rules! cfg_io_uring {
736 ($($item:item)*) => {
737 $(
738 #[cfg(all(
739 tokio_unstable,
740 feature = "io-uring",
741 feature = "rt",
742 feature = "fs",
743 target_os = "linux",
744 ))]
745 $item
746 )*
747 };
748}