Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ pin-project-lite = "0.2.11"

# Everything else is optional...
bytes = { version = "1.2.1", optional = true }
mio = { version = "1.0.1", optional = true, default-features = false }
# TODO dicej: switch to upstream once WASIp2 support is merged:
mio = { git = "https://github.com/dicej/mio", branch = "wasip2-draft", optional = true, default-features = false }
parking_lot = { version = "0.12.0", optional = true }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
Expand All @@ -106,7 +107,7 @@ tracing = { version = "0.1.29", default-features = false, features = ["std"], op
[target.'cfg(all(tokio_uring, target_os = "linux"))'.dependencies]
io-uring = { version = "0.7.6", default-features = false }
libc = { version = "0.2.168" }
mio = { version = "1.0.1", default-features = false, features = ["os-poll", "os-ext"] }
mio = { git = "https://github.com/dicej/mio", branch = "wasip2-draft", optional = true, default-features = false }
slab = "0.4.9"

# Currently unstable. The API exposed by these features may be broken at any time.
Expand Down
1 change: 1 addition & 0 deletions tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#![cfg_attr(docsrs, allow(unused_attributes))]
#![cfg_attr(loom, allow(dead_code, unreachable_pub))]
#![cfg_attr(windows, allow(rustdoc::broken_intra_doc_links))]
#![cfg_attr(all(target_os = "wasi", target_env = "p2"), feature(wasip2))]

//! A runtime for writing reliable network applications without compromising speed.
//!
Expand Down
9 changes: 9 additions & 0 deletions tokio/src/macros/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,15 @@ macro_rules! cfg_not_wasi {
}
}

macro_rules! cfg_not_wasip1 {
($($item:item)*) => {
$(
#[cfg(any(not(target_os = "wasi"), target_env = "p2"))]
$item
)*
}
}

macro_rules! cfg_is_wasm_not_wasi {
($($item:item)*) => {
$(
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//! [`AsyncFd`]: crate::io::unix::AsyncFd

mod addr;
cfg_not_wasi! {
cfg_not_wasip1! {
#[cfg(feature = "net")]
pub(crate) use addr::to_socket_addrs;
}
Expand Down
7 changes: 5 additions & 2 deletions tokio/src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
cfg_not_wasi! {
use std::time::Duration;
}

cfg_not_wasip1! {
use crate::net::{to_socket_addrs, ToSocketAddrs};
use std::future::poll_fn;
use std::time::Duration;
}

use crate::io::{AsyncRead, AsyncWrite, Interest, PollEvented, ReadBuf, Ready};
Expand Down Expand Up @@ -73,7 +76,7 @@ cfg_net! {
}

impl TcpStream {
cfg_not_wasi! {
cfg_not_wasip1! {
/// Opens a TCP connection to a remote host.
///
/// `addr` is an address of the remote host. Anything which implements the
Expand Down
Loading