From 355f6eea142ca717d9643d8ac316360353df3b42 Mon Sep 17 00:00:00 2001 From: Joey de Waal Date: Fri, 25 Oct 2024 22:12:50 +0200 Subject: [PATCH] fix: use std::os::fd on HermitOS --- src/io_source.rs | 6 +----- src/net/tcp/listener.rs | 6 +----- src/net/tcp/stream.rs | 6 +----- src/net/udp.rs | 6 +----- src/sys/shell/mod.rs | 6 +----- src/sys/unix/selector/poll.rs | 5 ----- src/sys/unix/sourcefd.rs | 5 ----- src/sys/unix/tcp.rs | 5 ----- src/sys/unix/udp.rs | 5 ----- src/sys/unix/waker/eventfd.rs | 5 ----- src/sys/unix/waker/pipe.rs | 5 ----- 11 files changed, 5 insertions(+), 55 deletions(-) diff --git a/src/io_source.rs b/src/io_source.rs index cd57653ab..d121ea3eb 100644 --- a/src/io_source.rs +++ b/src/io_source.rs @@ -1,10 +1,6 @@ use std::ops::{Deref, DerefMut}; -#[cfg(any(unix, target_os = "wasi"))] +#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))] use std::os::fd::AsRawFd; -// TODO: once 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)] diff --git a/src/net/tcp/listener.rs b/src/net/tcp/listener.rs index 2e27a7641..9ba149b60 100644 --- a/src/net/tcp/listener.rs +++ b/src/net/tcp/listener.rs @@ -1,10 +1,6 @@ use std::net::{self, SocketAddr}; -#[cfg(any(unix, target_os = "wasi"))] +#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))] use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -// TODO: once 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, OwnedFd, RawFd}; #[cfg(windows)] use std::os::windows::io::{ AsRawSocket, AsSocket, BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket, RawSocket, diff --git a/src/net/tcp/stream.rs b/src/net/tcp/stream.rs index f3db74fab..aec152588 100644 --- a/src/net/tcp/stream.rs +++ b/src/net/tcp/stream.rs @@ -1,12 +1,8 @@ use std::fmt; use std::io::{self, IoSlice, IoSliceMut, Read, Write}; use std::net::{self, Shutdown, SocketAddr}; -#[cfg(any(unix, target_os = "wasi"))] +#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))] use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -// TODO: once 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, OwnedFd, RawFd}; #[cfg(windows)] use std::os::windows::io::{ AsRawSocket, AsSocket, BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket, RawSocket, diff --git a/src/net/udp.rs b/src/net/udp.rs index e5013ba5b..43150ca85 100644 --- a/src/net/udp.rs +++ b/src/net/udp.rs @@ -8,12 +8,8 @@ //! [portability guidelines]: ../struct.Poll.html#portability use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr}; -#[cfg(any(unix, target_os = "wasi"))] +#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))] use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -// TODO: once 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, OwnedFd, RawFd}; #[cfg(windows)] use std::os::windows::io::{ AsRawSocket, AsSocket, BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket, RawSocket, diff --git a/src/sys/shell/mod.rs b/src/sys/shell/mod.rs index aa1c6220f..01f1aa708 100644 --- a/src/sys/shell/mod.rs +++ b/src/sys/shell/mod.rs @@ -21,12 +21,8 @@ cfg_net! { cfg_io_source! { use std::io; - #[cfg(any(unix))] + #[cfg(any(unix, target_os = "hermit"))] use std::os::fd::RawFd; - // TODO: once 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; diff --git a/src/sys/unix/selector/poll.rs b/src/sys/unix/selector/poll.rs index ac282c627..ceb038dbe 100644 --- a/src/sys/unix/selector/poll.rs +++ b/src/sys/unix/selector/poll.rs @@ -5,12 +5,7 @@ use std::collections::HashMap; use std::fmt::{Debug, Formatter}; -#[cfg(not(target_os = "hermit"))] use std::os::fd::{AsRawFd, RawFd}; -// TODO: once 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; diff --git a/src/sys/unix/sourcefd.rs b/src/sys/unix/sourcefd.rs index 1cac89abd..313b97f34 100644 --- a/src/sys/unix/sourcefd.rs +++ b/src/sys/unix/sourcefd.rs @@ -1,10 +1,5 @@ use std::io; -#[cfg(not(target_os = "hermit"))] use std::os::fd::RawFd; -// TODO: once 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}; diff --git a/src/sys/unix/tcp.rs b/src/sys/unix/tcp.rs index f8dfa5817..fe939d96a 100644 --- a/src/sys/unix/tcp.rs +++ b/src/sys/unix/tcp.rs @@ -2,12 +2,7 @@ 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 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}; diff --git a/src/sys/unix/udp.rs b/src/sys/unix/udp.rs index 80a09f63d..7ad7ed991 100644 --- a/src/sys/unix/udp.rs +++ b/src/sys/unix/udp.rs @@ -1,12 +1,7 @@ use std::io; use std::mem; use std::net::{self, SocketAddr}; -#[cfg(not(target_os = "hermit"))] use std::os::fd::{AsRawFd, FromRawFd}; -// TODO: once 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}; diff --git a/src/sys/unix/waker/eventfd.rs b/src/sys/unix/waker/eventfd.rs index af185efdb..0ffdf2090 100644 --- a/src/sys/unix/waker/eventfd.rs +++ b/src/sys/unix/waker/eventfd.rs @@ -1,11 +1,6 @@ use std::fs::File; use std::io::{self, Read, Write}; -#[cfg(not(target_os = "hermit"))] use std::os::fd::{AsRawFd, FromRawFd, RawFd}; -// TODO: once 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}; use crate::sys::Selector; use crate::{Interest, Token}; diff --git a/src/sys/unix/waker/pipe.rs b/src/sys/unix/waker/pipe.rs index dc54744d2..6e5892d04 100644 --- a/src/sys/unix/waker/pipe.rs +++ b/src/sys/unix/waker/pipe.rs @@ -1,11 +1,6 @@ use std::fs::File; use std::io::{self, Read, Write}; -#[cfg(not(target_os = "hermit"))] use std::os::fd::{AsRawFd, FromRawFd, RawFd}; -// TODO: once 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}; use crate::sys::unix::pipe; use crate::sys::Selector;