From 058514e54419533d577bb2ffdeb5dab9b6f87a92 Mon Sep 17 00:00:00 2001 From: niluxv <34834616+niluxv@users.noreply.github.com> Date: Sun, 23 Oct 2022 22:38:41 +0000 Subject: [PATCH] Fix compilation of libc backend without std (#430) --- src/backend/libc/io/epoll.rs | 2 +- src/backend/libc/io/io_slice.rs | 2 ++ src/net/addr.rs | 43 ++++++++++++++++++++++++++------- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/backend/libc/io/epoll.rs b/src/backend/libc/io/epoll.rs index a927972b..3205a613 100644 --- a/src/backend/libc/io/epoll.rs +++ b/src/backend/libc/io/epoll.rs @@ -261,7 +261,7 @@ impl<'context, T: AsFd + Into + From> Context for Owning<'cont // being released, so we can create a new `OwnedFd` that assumes // ownership. let raw_fd = target.consume().as_raw_fd(); - unsafe { T::from(io_lifetimes::OwnedFd::from_raw_fd(raw_fd).into()) } + unsafe { T::from(OwnedFd::from_raw_fd(raw_fd).into()) } } } diff --git a/src/backend/libc/io/io_slice.rs b/src/backend/libc/io/io_slice.rs index 81c504d2..de1ef434 100644 --- a/src/backend/libc/io/io_slice.rs +++ b/src/backend/libc/io/io_slice.rs @@ -2,6 +2,8 @@ //! library/std/src/sys/unix/io.rs //! dca3f1b786efd27be3b325ed1e01e247aa589c3b. +#![allow(missing_docs)] + use super::super::c; use core::marker::PhantomData; use core::slice; diff --git a/src/net/addr.rs b/src/net/addr.rs index 0308dee1..2bc08046 100644 --- a/src/net/addr.rs +++ b/src/net/addr.rs @@ -447,15 +447,40 @@ impl SocketAddrV6 { #[cfg_attr(staged_api, stable(feature = "rust1", since = "1.0.0"))] #[must_use] pub fn new(ip: Ipv6Addr, port: u16, flowinfo: u32, scope_id: u32) -> SocketAddrV6 { - SocketAddrV6 { - inner: sockaddr_in6_new( - c::AF_INET6 as c::sa_family_t, - port.to_be(), - flowinfo, - ip.inner, - scope_id, - ), - } + #[cfg(any( + target_os = "dragonfly", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + ))] + let inner = sockaddr_in6_new( + core::mem::size_of::() as u8, + c::AF_INET6 as c::sa_family_t, + port.to_be(), + flowinfo, + ip.inner, + scope_id, + ); + #[cfg(not(any( + target_os = "dragonfly", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + )))] + let inner = sockaddr_in6_new( + c::AF_INET6 as c::sa_family_t, + port.to_be(), + flowinfo, + ip.inner, + scope_id, + ); + SocketAddrV6 { inner } } /// Returns the IP address associated with this socket address.