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

Fix compilation on Hermit #1802

Merged
merged 2 commits into from
Jun 14, 2024
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: 5 additions & 1 deletion src/io_source.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::ops::{Deref, DerefMut};
#[cfg(any(unix, target_os = "hermit", target_os = "wasi"))]
#[cfg(any(unix, target_os = "wasi"))]
use std::os::fd::AsRawFd;
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::AsRawFd;
#[cfg(windows)]
use std::os::windows::io::AsRawSocket;
#[cfg(debug_assertions)]
Expand Down
6 changes: 5 additions & 1 deletion src/net/tcp/listener.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::net::{self, SocketAddr};
#[cfg(any(unix, target_os = "hermit", target_os = "wasi"))]
#[cfg(any(unix, target_os = "wasi"))]
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
use std::{fmt, io};
Expand Down
6 changes: 5 additions & 1 deletion src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::fmt;
use std::io::{self, IoSlice, IoSliceMut, Read, Write};
use std::net::{self, Shutdown, SocketAddr};
#[cfg(any(unix, target_os = "hermit", target_os = "wasi"))]
#[cfg(any(unix, target_os = "wasi"))]
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};

Expand Down
6 changes: 5 additions & 1 deletion src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
//! [portability guidelines]: ../struct.Poll.html#portability

use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
#[cfg(any(unix, target_os = "hermit", target_os = "wasi"))]
#[cfg(any(unix, target_os = "wasi"))]
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
use std::{fmt, io, net};
Expand Down
12 changes: 8 additions & 4 deletions src/sys/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ cfg_net! {

cfg_io_source! {
use std::io;
#[cfg(any(unix))]
use std::os::fd::RawFd;
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::RawFd;
#[cfg(windows)]
use std::os::windows::io::RawSocket;
#[cfg(unix)]
use std::os::fd::RawFd;

#[cfg(any(windows, unix))]
#[cfg(any(windows, unix, target_os = "hermit"))]
use crate::{Registry, Token, Interest};

pub(crate) struct IoSourceState;
Expand All @@ -46,7 +50,7 @@ cfg_io_source! {
}
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "hermit"))]
impl IoSourceState {
pub fn register(
&mut self,
Expand Down
2 changes: 1 addition & 1 deletion src/sys/shell/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) fn listen(_: &net::TcpListener, _: u32) -> io::Result<()> {
os_required!();
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "hermit"))]
pub(crate) fn set_reuseaddr(_: &net::TcpListener, _: bool) -> io::Result<()> {
os_required!();
}
Expand Down
5 changes: 5 additions & 0 deletions src/sys/unix/selector/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

use std::collections::HashMap;
use std::fmt::{Debug, Formatter};
#[cfg(not(target_os = "hermit"))]
use std::os::fd::{AsRawFd, RawFd};
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::{AsRawFd, RawFd};
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::{Arc, Condvar, Mutex};
use std::time::Duration;
Expand Down
5 changes: 5 additions & 0 deletions src/sys/unix/sourcefd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use std::io;
#[cfg(not(target_os = "hermit"))]
use std::os::fd::RawFd;
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::RawFd;

use crate::{event, Interest, Registry, Token};

Expand Down
5 changes: 5 additions & 0 deletions src/sys/unix/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ use std::convert::TryInto;
use std::io;
use std::mem::{size_of, MaybeUninit};
use std::net::{self, SocketAddr};
#[cfg(not(target_os = "hermit"))]
use std::os::fd::{AsRawFd, FromRawFd};
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::{AsRawFd, FromRawFd};

use crate::sys::unix::net::{new_socket, socket_addr, to_socket_addr};

Expand Down
5 changes: 5 additions & 0 deletions src/sys/unix/udp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use std::io;
use std::mem;
use std::net::{self, SocketAddr};
#[cfg(not(target_os = "hermit"))]
use std::os::fd::{AsRawFd, FromRawFd};
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::{AsRawFd, FromRawFd};

use crate::sys::unix::net::{new_ip_socket, socket_addr};

Expand Down
5 changes: 5 additions & 0 deletions src/sys/unix/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ pub use self::fdbased::Waker;
mod eventfd {
use std::fs::File;
use std::io::{self, Read, Write};
#[cfg(not(target_os = "hermit"))]
use std::os::fd::{AsRawFd, FromRawFd, RawFd};
// TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
// can use `std::os::fd` and be merged with the above.
#[cfg(target_os = "hermit")]
use std::os::hermit::io::{AsRawFd, FromRawFd, RawFd};

/// Waker backed by `eventfd`.
///
Expand Down