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