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