Fix compilation of libc backend without std (#430)

This commit is contained in:
niluxv
2022-10-23 22:38:41 +00:00
committed by GitHub
parent 1d62edeade
commit 058514e544
3 changed files with 37 additions and 10 deletions
+1 -1
View File
@@ -261,7 +261,7 @@ impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> 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()) }
}
}
+2
View File
@@ -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;
+34 -9
View File
@@ -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::<c::sockaddr_in6>() 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.