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