1 #![allow(unused_macros)] 2 3 macro_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 16 /// Enables enter::block_on. 17 macro_rules! cfg_block_on { 18 ($($item:item)*) => { 19 $( 20 #[cfg(any( 21 feature = "fs", 22 feature = "net", 23 feature = "io-std", 24 feature = "rt", 25 ))] 26 $item 27 )* 28 } 29 } 30 31 /// Enables internal `AtomicWaker` impl. 32 macro_rules! cfg_atomic_waker_impl { 33 ($($item:item)*) => { 34 $( 35 #[cfg(any( 36 feature = "net", 37 feature = "process", 38 feature = "rt", 39 feature = "signal", 40 feature = "time", 41 ))] 42 #[cfg(not(loom))] 43 $item 44 )* 45 } 46 } 47 48 macro_rules! cfg_aio { 49 ($($item:item)*) => { 50 $( 51 #[cfg(all(any(docsrs, target_os = "freebsd"), feature = "net"))] 52 #[cfg_attr(docsrs, 53 doc(cfg(all(target_os = "freebsd", feature = "net"))) 54 )] 55 $item 56 )* 57 } 58 } 59 60 macro_rules! cfg_fs { 61 ($($item:item)*) => { 62 $( 63 #[cfg(feature = "fs")] 64 #[cfg(not(tokio_wasi))] 65 #[cfg_attr(docsrs, doc(cfg(feature = "fs")))] 66 $item 67 )* 68 } 69 } 70 71 macro_rules! cfg_io_blocking { 72 ($($item:item)*) => { 73 $( #[cfg(any( 74 feature = "io-std", 75 feature = "fs", 76 all(windows, feature = "process"), 77 ))] $item )* 78 } 79 } 80 81 macro_rules! cfg_io_driver { 82 ($($item:item)*) => { 83 $( 84 #[cfg(any( 85 feature = "net", 86 all(unix, feature = "process"), 87 all(unix, feature = "signal"), 88 ))] 89 #[cfg_attr(docsrs, doc(cfg(any( 90 feature = "net", 91 all(unix, feature = "process"), 92 all(unix, feature = "signal"), 93 ))))] 94 $item 95 )* 96 } 97 } 98 99 macro_rules! cfg_io_driver_impl { 100 ( $( $item:item )* ) => { 101 $( 102 #[cfg(any( 103 feature = "net", 104 all(unix, feature = "process"), 105 all(unix, feature = "signal"), 106 ))] 107 $item 108 )* 109 } 110 } 111 112 macro_rules! cfg_not_io_driver { 113 ($($item:item)*) => { 114 $( 115 #[cfg(not(any( 116 feature = "net", 117 all(unix, feature = "process"), 118 all(unix, feature = "signal"), 119 )))] 120 $item 121 )* 122 } 123 } 124 125 macro_rules! cfg_io_readiness { 126 ($($item:item)*) => { 127 $( 128 #[cfg(feature = "net")] 129 $item 130 )* 131 } 132 } 133 134 macro_rules! cfg_io_std { 135 ($($item:item)*) => { 136 $( 137 #[cfg(feature = "io-std")] 138 #[cfg_attr(docsrs, doc(cfg(feature = "io-std")))] 139 $item 140 )* 141 } 142 } 143 144 macro_rules! cfg_io_util { 145 ($($item:item)*) => { 146 $( 147 #[cfg(feature = "io-util")] 148 #[cfg_attr(docsrs, doc(cfg(feature = "io-util")))] 149 $item 150 )* 151 } 152 } 153 154 macro_rules! cfg_not_io_util { 155 ($($item:item)*) => { 156 $( #[cfg(not(feature = "io-util"))] $item )* 157 } 158 } 159 160 macro_rules! cfg_loom { 161 ($($item:item)*) => { 162 $( #[cfg(loom)] $item )* 163 } 164 } 165 166 macro_rules! cfg_not_loom { 167 ($($item:item)*) => { 168 $( #[cfg(not(loom))] $item )* 169 } 170 } 171 172 macro_rules! cfg_macros { 173 ($($item:item)*) => { 174 $( 175 #[cfg(feature = "macros")] 176 #[cfg_attr(docsrs, doc(cfg(feature = "macros")))] 177 $item 178 )* 179 } 180 } 181 182 macro_rules! cfg_metrics { 183 ($($item:item)*) => { 184 $( 185 // For now, metrics is only disabled in loom tests. 186 // When stabilized, it might have a dedicated feature flag. 187 #[cfg(all(tokio_unstable, not(loom)))] 188 #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] 189 $item 190 )* 191 } 192 } 193 194 macro_rules! cfg_not_metrics { 195 ($($item:item)*) => { 196 $( 197 #[cfg(not(all(tokio_unstable, not(loom))))] 198 $item 199 )* 200 } 201 } 202 203 macro_rules! cfg_not_rt_and_metrics_and_net { 204 ($($item:item)*) => { 205 $( #[cfg(not(all(feature = "net", feature = "rt", all(tokio_unstable, not(loom)))))]$item )* 206 } 207 } 208 209 macro_rules! cfg_net_or_process { 210 ($($item:item)*) => { 211 $( 212 #[cfg(any(feature = "net", feature = "process"))] 213 #[cfg_attr(docsrs, doc(cfg(any(feature = "net", feature = "process"))))] 214 $item 215 )* 216 } 217 } 218 219 macro_rules! cfg_net { 220 ($($item:item)*) => { 221 $( 222 #[cfg(feature = "net")] 223 #[cfg_attr(docsrs, doc(cfg(feature = "net")))] 224 $item 225 )* 226 } 227 } 228 229 macro_rules! cfg_net_unix { 230 ($($item:item)*) => { 231 $( 232 #[cfg(all(unix, feature = "net"))] 233 #[cfg_attr(docsrs, doc(cfg(all(unix, feature = "net"))))] 234 $item 235 )* 236 } 237 } 238 239 macro_rules! cfg_net_windows { 240 ($($item:item)*) => { 241 $( 242 #[cfg(all(any(all(doc, docsrs), windows), feature = "net"))] 243 #[cfg_attr(docsrs, doc(cfg(all(windows, feature = "net"))))] 244 $item 245 )* 246 } 247 } 248 249 macro_rules! cfg_process { 250 ($($item:item)*) => { 251 $( 252 #[cfg(feature = "process")] 253 #[cfg_attr(docsrs, doc(cfg(feature = "process")))] 254 #[cfg(not(loom))] 255 #[cfg(not(tokio_wasi))] 256 $item 257 )* 258 } 259 } 260 261 macro_rules! cfg_process_driver { 262 ($($item:item)*) => { 263 #[cfg(unix)] 264 #[cfg(not(loom))] 265 cfg_process! { $($item)* } 266 } 267 } 268 269 macro_rules! cfg_not_process_driver { 270 ($($item:item)*) => { 271 $( 272 #[cfg(not(all(unix, not(loom), feature = "process")))] 273 $item 274 )* 275 } 276 } 277 278 macro_rules! cfg_signal { 279 ($($item:item)*) => { 280 $( 281 #[cfg(feature = "signal")] 282 #[cfg_attr(docsrs, doc(cfg(feature = "signal")))] 283 #[cfg(not(loom))] 284 #[cfg(not(tokio_wasi))] 285 $item 286 )* 287 } 288 } 289 290 macro_rules! cfg_signal_internal { 291 ($($item:item)*) => { 292 $( 293 #[cfg(any(feature = "signal", all(unix, feature = "process")))] 294 #[cfg(not(loom))] 295 $item 296 )* 297 } 298 } 299 300 macro_rules! cfg_signal_internal_and_unix { 301 ($($item:item)*) => { 302 #[cfg(unix)] 303 cfg_signal_internal! { $($item)* } 304 } 305 } 306 307 macro_rules! cfg_not_signal_internal { 308 ($($item:item)*) => { 309 $( 310 #[cfg(any(loom, not(unix), not(any(feature = "signal", all(unix, feature = "process")))))] 311 $item 312 )* 313 } 314 } 315 316 macro_rules! cfg_sync { 317 ($($item:item)*) => { 318 $( 319 #[cfg(feature = "sync")] 320 #[cfg_attr(docsrs, doc(cfg(feature = "sync")))] 321 $item 322 )* 323 } 324 } 325 326 macro_rules! cfg_not_sync { 327 ($($item:item)*) => { 328 $( #[cfg(not(feature = "sync"))] $item )* 329 } 330 } 331 332 macro_rules! cfg_rt { 333 ($($item:item)*) => { 334 $( 335 #[cfg(feature = "rt")] 336 #[cfg_attr(docsrs, doc(cfg(feature = "rt")))] 337 $item 338 )* 339 } 340 } 341 342 macro_rules! cfg_not_rt { 343 ($($item:item)*) => { 344 $( #[cfg(not(feature = "rt"))] $item )* 345 } 346 } 347 348 macro_rules! cfg_rt_multi_thread { 349 ($($item:item)*) => { 350 $( 351 #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] 352 #[cfg_attr(docsrs, doc(cfg(feature = "rt-multi-thread")))] 353 $item 354 )* 355 } 356 } 357 358 macro_rules! cfg_not_rt_multi_thread { 359 ($($item:item)*) => { 360 $( #[cfg(not(feature = "rt-multi-thread"))] $item )* 361 } 362 } 363 364 macro_rules! cfg_test_util { 365 ($($item:item)*) => { 366 $( 367 #[cfg(feature = "test-util")] 368 #[cfg_attr(docsrs, doc(cfg(feature = "test-util")))] 369 $item 370 )* 371 } 372 } 373 374 macro_rules! cfg_not_test_util { 375 ($($item:item)*) => { 376 $( #[cfg(not(feature = "test-util"))] $item )* 377 } 378 } 379 380 macro_rules! cfg_time { 381 ($($item:item)*) => { 382 $( 383 #[cfg(feature = "time")] 384 #[cfg_attr(docsrs, doc(cfg(feature = "time")))] 385 $item 386 )* 387 } 388 } 389 390 macro_rules! cfg_not_time { 391 ($($item:item)*) => { 392 $( #[cfg(not(feature = "time"))] $item )* 393 } 394 } 395 396 macro_rules! cfg_trace { 397 ($($item:item)*) => { 398 $( 399 #[cfg(all(tokio_unstable, feature = "tracing"))] 400 #[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))] 401 $item 402 )* 403 }; 404 } 405 406 macro_rules! cfg_unstable { 407 ($($item:item)*) => { 408 $( 409 #[cfg(tokio_unstable)] 410 #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] 411 $item 412 )* 413 }; 414 } 415 416 macro_rules! cfg_not_trace { 417 ($($item:item)*) => { 418 $( 419 #[cfg(any(not(tokio_unstable), not(feature = "tracing")))] 420 $item 421 )* 422 } 423 } 424 425 macro_rules! cfg_coop { 426 ($($item:item)*) => { 427 $( 428 #[cfg(any( 429 feature = "fs", 430 feature = "io-std", 431 feature = "net", 432 feature = "process", 433 feature = "rt", 434 feature = "signal", 435 feature = "sync", 436 feature = "time", 437 ))] 438 $item 439 )* 440 } 441 } 442 443 macro_rules! cfg_not_coop { 444 ($($item:item)*) => { 445 $( 446 #[cfg(not(any( 447 feature = "fs", 448 feature = "io-std", 449 feature = "net", 450 feature = "process", 451 feature = "rt", 452 feature = "signal", 453 feature = "sync", 454 feature = "time", 455 )))] 456 $item 457 )* 458 } 459 } 460 461 macro_rules! cfg_has_atomic_u64 { 462 ($($item:item)*) => { 463 $( 464 #[cfg_attr( 465 not(tokio_no_target_has_atomic), 466 cfg(all(target_has_atomic = "64", not(tokio_no_atomic_u64)) 467 ))] 468 #[cfg_attr( 469 tokio_no_target_has_atomic, 470 cfg(not(tokio_no_atomic_u64)) 471 )] 472 $item 473 )* 474 } 475 } 476 477 macro_rules! cfg_not_has_atomic_u64 { 478 ($($item:item)*) => { 479 $( 480 #[cfg_attr( 481 not(tokio_no_target_has_atomic), 482 cfg(any(not(target_has_atomic = "64"), tokio_no_atomic_u64) 483 ))] 484 #[cfg_attr( 485 tokio_no_target_has_atomic, 486 cfg(tokio_no_atomic_u64) 487 )] 488 $item 489 )* 490 } 491 } 492 493 macro_rules! cfg_has_const_mutex_new { 494 ($($item:item)*) => { 495 $( 496 #[cfg(all( 497 not(all(loom, test)), 498 any( 499 feature = "parking_lot", 500 not(tokio_no_const_mutex_new) 501 ) 502 ))] 503 $item 504 )* 505 } 506 } 507 508 macro_rules! cfg_not_has_const_mutex_new { 509 ($($item:item)*) => { 510 $( 511 #[cfg(not(all( 512 not(all(loom, test)), 513 any( 514 feature = "parking_lot", 515 not(tokio_no_const_mutex_new) 516 ) 517 )))] 518 $item 519 )* 520 } 521 } 522 523 macro_rules! cfg_not_wasi { 524 ($($item:item)*) => { 525 $( 526 #[cfg(not(tokio_wasi))] 527 $item 528 )* 529 } 530 } 531 532 macro_rules! cfg_is_wasm_not_wasi { 533 ($($item:item)*) => { 534 $( 535 #[cfg(tokio_wasm_not_wasi)] 536 $item 537 )* 538 } 539 } 540