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