Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable rustix::net on Redox. #1302

Merged
merged 1 commit into from
Jan 31, 2025
Merged
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
6 changes: 3 additions & 3 deletions src/backend/libc/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub(super) fn ret_discarded_char_ptr(raw: *mut c::c_char) -> io::Result<()> {
}

/// Convert the buffer-length argument value of a `send` or `recv` call.
#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(windows, target_os = "wasi")))]
#[inline]
pub(super) fn send_recv_len(len: usize) -> usize {
len
Expand All @@ -168,7 +168,7 @@ pub(super) fn send_recv_len(len: usize) -> i32 {
}

/// Convert the return value of a `send` or `recv` call.
#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(windows, target_os = "wasi")))]
#[inline]
pub(super) fn ret_send_recv(len: isize) -> io::Result<usize> {
ret_usize(len)
Expand All @@ -183,7 +183,7 @@ pub(super) fn ret_send_recv(len: i32) -> io::Result<usize> {

/// Convert the value to the `msg_iovlen` field of a `msghdr` struct.
#[cfg(all(
not(any(windows, target_os = "espidf", target_os = "redox", target_os = "wasi")),
not(any(windows, target_os = "espidf", target_os = "wasi")),
any(
target_os = "android",
all(
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub(crate) mod mm;
#[cfg(linux_kernel)]
#[cfg(feature = "mount")]
pub(crate) mod mount;
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
#[cfg(not(target_os = "wasi"))]
#[cfg(feature = "net")]
pub(crate) mod net;
#[cfg(not(any(windows, target_os = "espidf")))]
Expand Down
9 changes: 1 addition & 8 deletions src/backend/libc/net/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
pub(crate) mod addr;
pub(crate) mod ext;
#[cfg(not(any(
windows,
target_os = "espidf",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
)))]
#[cfg(not(any(windows, target_os = "espidf", target_os = "redox", target_os = "vita")))]
pub(crate) mod msghdr;
#[cfg(linux_kernel)]
pub(crate) mod netdevice;
pub(crate) mod read_sockaddr;
pub(crate) mod send_recv;
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
pub(crate) mod sockopt;
pub(crate) mod syscalls;
pub(crate) mod write_sockaddr;
6 changes: 5 additions & 1 deletion src/backend/libc/net/send_recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ bitflags! {
target_os = "nto",
target_os = "haiku",
target_os = "hurd",
target_os = "redox",
target_os = "vita",
)))]
const CONFIRM = bitcast!(c::MSG_CONFIRM);
Expand All @@ -40,10 +41,11 @@ bitflags! {
target_os = "haiku",
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "vita",
)))]
const MORE = bitcast!(c::MSG_MORE);
#[cfg(not(any(apple, windows, target_os = "vita")))]
#[cfg(not(any(apple, windows, target_os = "redox", target_os = "vita")))]
/// `MSG_NOSIGNAL`
const NOSIGNAL = bitcast!(c::MSG_NOSIGNAL);
/// `MSG_OOB`
Expand Down Expand Up @@ -72,6 +74,7 @@ bitflags! {
target_os = "espidf",
target_os = "haiku",
target_os = "nto",
target_os = "redox",
target_os = "vita",
)))]
const CMSG_CLOEXEC = bitcast!(c::MSG_CMSG_CLOEXEC);
Expand All @@ -88,6 +91,7 @@ bitflags! {
target_os = "haiku",
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "vita",
)))]
const ERRQUEUE = bitcast!(c::MSG_ERRQUEUE);
Expand Down
30 changes: 26 additions & 4 deletions src/backend/libc/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ pub(crate) fn ipv6_original_dst(fd: BorrowedFd<'_>) -> io::Result<SocketAddrV6>
windows,
target_os = "espidf",
target_os = "haiku",
target_os = "redox",
target_os = "vita"
)))]
#[inline]
Expand All @@ -818,6 +819,7 @@ pub(crate) fn set_ipv6_tclass(fd: BorrowedFd<'_>, value: u32) -> io::Result<()>
windows,
target_os = "espidf",
target_os = "haiku",
target_os = "redox",
target_os = "vita"
)))]
#[inline]
Expand All @@ -836,13 +838,23 @@ pub(crate) fn tcp_nodelay(fd: BorrowedFd<'_>) -> io::Result<bool> {
}

#[inline]
#[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))]
#[cfg(not(any(
target_os = "openbsd",
target_os = "haiku",
target_os = "nto",
target_os = "redox"
)))]
pub(crate) fn set_tcp_keepcnt(fd: BorrowedFd<'_>, count: u32) -> io::Result<()> {
setsockopt(fd, c::IPPROTO_TCP, c::TCP_KEEPCNT, count)
}

#[inline]
#[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))]
#[cfg(not(any(
target_os = "openbsd",
target_os = "haiku",
target_os = "nto",
target_os = "redox"
)))]
pub(crate) fn tcp_keepcnt(fd: BorrowedFd<'_>) -> io::Result<u32> {
getsockopt(fd, c::IPPROTO_TCP, c::TCP_KEEPCNT)
}
Expand All @@ -862,14 +874,24 @@ pub(crate) fn tcp_keepidle(fd: BorrowedFd<'_>) -> io::Result<Duration> {
}

#[inline]
#[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))]
#[cfg(not(any(
target_os = "openbsd",
target_os = "haiku",
target_os = "nto",
target_os = "redox"
)))]
pub(crate) fn set_tcp_keepintvl(fd: BorrowedFd<'_>, duration: Duration) -> io::Result<()> {
let secs: c::c_uint = duration_to_secs(duration)?;
setsockopt(fd, c::IPPROTO_TCP, c::TCP_KEEPINTVL, secs)
}

#[inline]
#[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))]
#[cfg(not(any(
target_os = "openbsd",
target_os = "haiku",
target_os = "nto",
target_os = "redox"
)))]
pub(crate) fn tcp_keepintvl(fd: BorrowedFd<'_>) -> io::Result<Duration> {
let secs: c::c_uint = getsockopt(fd, c::IPPROTO_TCP, c::TCP_KEEPINTVL)?;
Ok(Duration::from_secs(secs as u64))
Expand Down
Loading