From 4efdaa4140c15272b503e11ec47d9cca8517de21 Mon Sep 17 00:00:00 2001 From: Carl Wachter Date: Tue, 21 May 2024 10:40:29 +0200 Subject: [PATCH] Removed newlib exclusion for network features --- src/executor/mod.rs | 20 ++++++-------------- src/fd/mod.rs | 26 +++++++++++++------------- src/syscalls/mod.rs | 2 +- src/syscalls/socket.rs | 14 +++++++------- 4 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/executor/mod.rs b/src/executor/mod.rs index 40a911f3ef..ddfb6b4126 100644 --- a/src/executor/mod.rs +++ b/src/executor/mod.rs @@ -20,25 +20,17 @@ use hermit_sync::without_interrupts; use smoltcp::time::Instant; use crate::arch::core_local::*; -#[cfg(all( - any(feature = "tcp", feature = "udp"), - not(feature = "pci"), - not(feature = "newlib") -))] +#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "pci")))] use crate::drivers::mmio::get_network_driver; -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] use crate::drivers::net::NetworkDriver; -#[cfg(all( - any(feature = "tcp", feature = "udp"), - feature = "pci", - not(feature = "newlib") -))] +#[cfg(all(any(feature = "tcp", feature = "udp"), feature = "pci"))] use crate::drivers::pci::get_network_driver; -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] use crate::executor::network::network_delay; use crate::executor::task::AsyncTask; use crate::fd::IoError; -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] use crate::scheduler::PerCoreSchedulerExt; use crate::synch::futex::*; @@ -97,7 +89,7 @@ where } pub fn init() { - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] crate::executor::network::init(); } diff --git a/src/fd/mod.rs b/src/fd/mod.rs index a910bb6deb..660e303e29 100644 --- a/src/fd/mod.rs +++ b/src/fd/mod.rs @@ -7,7 +7,7 @@ use core::time::Duration; use async_trait::async_trait; use dyn_clone::DynClone; -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; use crate::arch::kernel::core_local::core_scheduler; @@ -15,7 +15,7 @@ use crate::executor::{block_on, poll_on}; use crate::fs::{DirectoryEntry, FileAttr, SeekWhence}; mod eventfd; -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] pub(crate) mod socket; pub(crate) mod stdio; @@ -207,56 +207,56 @@ pub(crate) trait ObjectInterface: Sync + Send + core::fmt::Debug + DynClone { } /// `accept` a connection on a socket - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn accept(&self) -> Result { Err(IoError::EINVAL) } /// initiate a connection on a socket - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn connect(&self, _endpoint: IpEndpoint) -> Result<(), IoError> { Err(IoError::EINVAL) } /// `bind` a name to a socket - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn bind(&self, _name: IpListenEndpoint) -> Result<(), IoError> { Err(IoError::EINVAL) } /// `listen` for connections on a socket - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn listen(&self, _backlog: i32) -> Result<(), IoError> { Err(IoError::EINVAL) } /// `setsockopt` sets options on sockets - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn setsockopt(&self, _opt: SocketOption, _optval: bool) -> Result<(), IoError> { Err(IoError::EINVAL) } /// `getsockopt` gets options on sockets - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn getsockopt(&self, _opt: SocketOption) -> Result { Err(IoError::EINVAL) } /// `getsockname` gets socket name - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn getsockname(&self) -> Option { None } /// `getpeername` get address of connected peer - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] #[allow(dead_code)] fn getpeername(&self) -> Option { None } /// receive a message from a socket - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn recvfrom(&self, _buffer: &mut [u8]) -> Result<(usize, IpEndpoint), IoError> { Err(IoError::ENOSYS) } @@ -268,13 +268,13 @@ pub(crate) trait ObjectInterface: Sync + Send + core::fmt::Debug + DynClone { /// If a peer address has been prespecified, either the message shall /// be sent to the address specified by dest_addr (overriding the pre-specified peer /// address). - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn sendto(&self, _buffer: &[u8], _endpoint: IpEndpoint) -> Result { Err(IoError::ENOSYS) } /// shut down part of a full-duplex connection - #[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] + #[cfg(any(feature = "tcp", feature = "udp"))] fn shutdown(&self, _how: i32) -> Result<(), IoError> { Err(IoError::ENOSYS) } diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index 0a9a9c9523..93dcd0e395 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -38,7 +38,7 @@ mod processor; #[cfg(feature = "newlib")] mod recmutex; mod semaphore; -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] pub mod socket; mod spinlock; mod system; diff --git a/src/syscalls/socket.rs b/src/syscalls/socket.rs index 5d937d601b..3a2a118724 100644 --- a/src/syscalls/socket.rs +++ b/src/syscalls/socket.rs @@ -5,7 +5,7 @@ use core::ffi::{c_char, c_void}; use core::mem::size_of; use core::ops::DerefMut; -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] use smoltcp::wire::{IpAddress, IpEndpoint, IpListenEndpoint}; use crate::errno::*; @@ -102,7 +102,7 @@ pub struct sockaddr_in { pub sin_zero: [c_char; 8], } -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] impl From for IpListenEndpoint { fn from(addr: sockaddr_in) -> IpListenEndpoint { let port = u16::from_be(addr.sin_port); @@ -118,7 +118,7 @@ impl From for IpListenEndpoint { } } -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] impl From for IpEndpoint { fn from(addr: sockaddr_in) -> IpEndpoint { let port = u16::from_be(addr.sin_port); @@ -129,7 +129,7 @@ impl From for IpEndpoint { } } -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] impl From for sockaddr_in { fn from(endpoint: IpEndpoint) -> Self { match endpoint.addr { @@ -162,7 +162,7 @@ pub struct sockaddr_in6 { pub sin6_scope_id: u32, } -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] impl From for IpListenEndpoint { fn from(addr: sockaddr_in6) -> IpListenEndpoint { let port = u16::from_be(addr.sin6_port); @@ -184,7 +184,7 @@ impl From for IpListenEndpoint { } } -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] impl From for IpEndpoint { fn from(addr: sockaddr_in6) -> IpEndpoint { let port = u16::from_be(addr.sin6_port); @@ -202,7 +202,7 @@ impl From for IpEndpoint { } } -#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))] +#[cfg(any(feature = "tcp", feature = "udp"))] impl From for sockaddr_in6 { fn from(endpoint: IpEndpoint) -> Self { match endpoint.addr {