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