summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend/libc/net
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/rustix/src/backend/libc/net
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/backend/libc/net')
-rw-r--r--vendor/rustix/src/backend/libc/net/addr.rs136
-rw-r--r--vendor/rustix/src/backend/libc/net/ext.rs23
-rw-r--r--vendor/rustix/src/backend/libc/net/read_sockaddr.rs57
-rw-r--r--vendor/rustix/src/backend/libc/net/send_recv.rs34
-rw-r--r--vendor/rustix/src/backend/libc/net/syscalls.rs95
-rw-r--r--vendor/rustix/src/backend/libc/net/types.rs349
-rw-r--r--vendor/rustix/src/backend/libc/net/write_sockaddr.rs30
7 files changed, 158 insertions, 566 deletions
diff --git a/vendor/rustix/src/backend/libc/net/addr.rs b/vendor/rustix/src/backend/libc/net/addr.rs
index ba64ed279..d00a48626 100644
--- a/vendor/rustix/src/backend/libc/net/addr.rs
+++ b/vendor/rustix/src/backend/libc/net/addr.rs
@@ -20,14 +20,7 @@ use core::slice;
#[doc(alias = "sockaddr_un")]
pub struct SocketAddrUnix {
pub(crate) unix: c::sockaddr_un,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
len: c::socklen_t,
}
@@ -50,28 +43,14 @@ impl SocketAddrUnix {
unix.sun_path[i] = *b as c::c_char;
}
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
{
unix.sun_len = (offsetof_sun_path() + bytes.len()).try_into().unwrap();
}
Ok(Self {
unix,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
len: (offsetof_sun_path() + bytes.len()).try_into().unwrap(),
})
}
@@ -92,49 +71,19 @@ impl SocketAddrUnix {
let len = len.try_into().unwrap();
Ok(Self {
unix,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
len,
})
}
fn init() -> c::sockaddr_un {
c::sockaddr_un {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sun_len: 0,
sun_family: c::AF_UNIX as _,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
sun_path: [0; 104],
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
sun_path: [0; 108],
#[cfg(target_os = "haiku")]
sun_path: [0; 126],
@@ -148,7 +97,7 @@ impl SocketAddrUnix {
if len != 0 && self.unix.sun_path[0] != b'\0' as c::c_char {
let end = len as usize - offsetof_sun_path();
let bytes = &self.unix.sun_path[..end];
- // Safety: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`. And
+ // SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`. And
// `from_bytes_with_nul_unchecked` since the string is NUL-terminated.
unsafe {
Some(CStr::from_bytes_with_nul_unchecked(slice::from_raw_parts(
@@ -169,7 +118,7 @@ impl SocketAddrUnix {
if len != 0 && self.unix.sun_path[0] == b'\0' as c::c_char {
let end = len as usize - offsetof_sun_path();
let bytes = &self.unix.sun_path[1..end];
- // Safety: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`.
+ // SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`.
unsafe { Some(slice::from_raw_parts(bytes.as_ptr().cast(), bytes.len())) }
} else {
None
@@ -178,25 +127,11 @@ impl SocketAddrUnix {
#[inline]
pub(crate) fn addr_len(&self) -> c::socklen_t {
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
{
self.len
}
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
{
c::socklen_t::from(self.unix.sun_len)
}
@@ -274,54 +209,15 @@ pub type SocketAddrStorage = c::sockaddr_storage;
#[inline]
pub(crate) fn offsetof_sun_path() -> usize {
let z = c::sockaddr_un {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sun_len: 0_u8,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sun_family: 0_u8,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
sun_family: 0_u16,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
sun_path: [0; 104],
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
sun_path: [0; 108],
#[cfg(target_os = "haiku")]
sun_path: [0; 126],
diff --git a/vendor/rustix/src/backend/libc/net/ext.rs b/vendor/rustix/src/backend/libc/net/ext.rs
index 1c8f9f65c..f4ad316dd 100644
--- a/vendor/rustix/src/backend/libc/net/ext.rs
+++ b/vendor/rustix/src/backend/libc/net/ext.rs
@@ -130,16 +130,7 @@ pub(crate) fn sockaddr_in6_sin6_scope_id(addr: c::sockaddr_in6) -> u32 {
#[cfg(not(windows))]
#[inline]
pub(crate) const fn sockaddr_in6_new(
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
- sin6_len: u8,
+ #[cfg(any(bsd, target_os = "haiku"))] sin6_len: u8,
sin6_family: c::sa_family_t,
sin6_port: u16,
sin6_flowinfo: u32,
@@ -147,22 +138,14 @@ pub(crate) const fn sockaddr_in6_new(
sin6_scope_id: u32,
) -> c::sockaddr_in6 {
c::sockaddr_in6 {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sin6_len,
sin6_family,
sin6_port,
sin6_flowinfo,
sin6_addr,
sin6_scope_id,
- #[cfg(any(target_os = "illumos", target_os = "solaris"))]
+ #[cfg(solarish)]
__sin6_src_id: 0,
}
}
diff --git a/vendor/rustix/src/backend/libc/net/read_sockaddr.rs b/vendor/rustix/src/backend/libc/net/read_sockaddr.rs
index 5a946fbeb..575102c27 100644
--- a/vendor/rustix/src/backend/libc/net/read_sockaddr.rs
+++ b/vendor/rustix/src/backend/libc/net/read_sockaddr.rs
@@ -13,32 +13,11 @@ use core::mem::size_of;
// This must match the header of `sockaddr`.
#[repr(C)]
struct sockaddr_header {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sa_len: u8,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
ss_family: u8,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
ss_family: u16,
}
@@ -46,35 +25,11 @@ struct sockaddr_header {
unsafe fn read_ss_family(storage: *const c::sockaddr_storage) -> u16 {
// Assert that we know the layout of `sockaddr`.
let _ = c::sockaddr {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sa_len: 0_u8,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sa_family: 0_u8,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
sa_family: 0_u16,
#[cfg(not(target_os = "haiku"))]
sa_data: [0; 14],
diff --git a/vendor/rustix/src/backend/libc/net/send_recv.rs b/vendor/rustix/src/backend/libc/net/send_recv.rs
index 8d1cc8ab7..114807808 100644
--- a/vendor/rustix/src/backend/libc/net/send_recv.rs
+++ b/vendor/rustix/src/backend/libc/net/send_recv.rs
@@ -6,16 +6,10 @@ bitflags! {
pub struct SendFlags: i32 {
/// `MSG_CONFIRM`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
const CONFIRM = c::MSG_CONFIRM;
/// `MSG_DONTROUTE`
@@ -28,19 +22,13 @@ bitflags! {
const EOT = c::MSG_EOR;
/// `MSG_MORE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
const MORE = c::MSG_MORE;
- #[cfg(not(any(windows, target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows)))]
/// `MSG_NOSIGNAL`
const NOSIGNAL = c::MSG_NOSIGNAL;
/// `MSG_OOB`
@@ -51,7 +39,7 @@ bitflags! {
bitflags! {
/// `MSG_*`
pub struct RecvFlags: i32 {
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "ios", target_os = "macos", target_os = "solaris")))]
+ #[cfg(not(any(apple, solarish, windows, target_os = "haiku")))]
/// `MSG_CMSG_CLOEXEC`
const CMSG_CLOEXEC = c::MSG_CMSG_CLOEXEC;
/// `MSG_DONTWAIT`
@@ -59,16 +47,10 @@ bitflags! {
const DONTWAIT = c::MSG_DONTWAIT;
/// `MSG_ERRQUEUE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
const ERRQUEUE = c::MSG_ERRQUEUE;
/// `MSG_OOB`
diff --git a/vendor/rustix/src/backend/libc/net/syscalls.rs b/vendor/rustix/src/backend/libc/net/syscalls.rs
index 3d8a849c7..ed4494394 100644
--- a/vendor/rustix/src/backend/libc/net/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/net/syscalls.rs
@@ -251,10 +251,9 @@ pub(crate) fn accept(sockfd: BorrowedFd<'_>) -> io::Result<OwnedFd> {
}
#[cfg(not(any(
+ apple,
windows,
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
target_os = "wasi",
)))]
@@ -288,10 +287,9 @@ pub(crate) fn acceptfrom(sockfd: BorrowedFd<'_>) -> io::Result<(OwnedFd, Option<
}
#[cfg(not(any(
+ apple,
windows,
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
target_os = "wasi",
)))]
@@ -317,14 +315,14 @@ pub(crate) fn acceptfrom_with(
/// Darwin lacks `accept4`, but does have `accept`. We define
/// `AcceptFlags` to have no flags, so we can discard it here.
-#[cfg(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos"))]
+#[cfg(any(apple, windows, target_os = "haiku"))]
pub(crate) fn accept_with(sockfd: BorrowedFd<'_>, _flags: AcceptFlags) -> io::Result<OwnedFd> {
accept(sockfd)
}
/// Darwin lacks `accept4`, but does have `accept`. We define
/// `AcceptFlags` to have no flags, so we can discard it here.
-#[cfg(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos"))]
+#[cfg(any(apple, windows, target_os = "haiku"))]
pub(crate) fn acceptfrom_with(
sockfd: BorrowedFd<'_>,
_flags: AcceptFlags,
@@ -555,11 +553,12 @@ pub(crate) mod sockopt {
return Err(io::Errno::INVAL);
}
- let tv_sec = timeout.as_secs().try_into();
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- let tv_sec = tv_sec.unwrap_or(c::c_long::MAX);
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- let tv_sec = tv_sec.unwrap_or(i64::MAX);
+ // Rust's musl libc bindings deprecated `time_t` while they
+ // transition to 64-bit `time_t`. What we want here is just
+ // "whatever type `timeval`'s `tv_sec` is", so we're ok using
+ // the deprecated type.
+ #[allow(deprecated)]
+ let tv_sec = timeout.as_secs().try_into().unwrap_or(c::time_t::MAX);
// `subsec_micros` rounds down, so we use `subsec_nanos` and
// manually round up.
@@ -635,6 +634,28 @@ pub(crate) mod sockopt {
}
}
+ #[cfg(any(apple, target_os = "freebsd"))]
+ #[inline]
+ pub(crate) fn getsockopt_nosigpipe(fd: BorrowedFd<'_>) -> io::Result<bool> {
+ getsockopt(fd, c::SOL_SOCKET, c::SO_NOSIGPIPE).map(to_bool)
+ }
+
+ #[cfg(any(apple, target_os = "freebsd"))]
+ #[inline]
+ pub(crate) fn setsockopt_nosigpipe(fd: BorrowedFd<'_>, val: bool) -> io::Result<()> {
+ setsockopt(fd, c::SOL_SOCKET, c::SO_NOSIGPIPE, from_bool(val))
+ }
+
+ #[inline]
+ pub(crate) fn get_socket_error(fd: BorrowedFd<'_>) -> io::Result<Result<(), crate::io::Errno>> {
+ let err: c::c_int = getsockopt(fd, c::SOL_SOCKET as _, c::SO_ERROR)?;
+ Ok(if err == 0 {
+ Ok(())
+ } else {
+ Err(crate::io::Errno::from_raw_os_error(err))
+ })
+ }
+
#[inline]
pub(crate) fn set_ip_ttl(fd: BorrowedFd<'_>, ttl: u32) -> io::Result<()> {
setsockopt(fd, c::IPPROTO_IP as _, c::IP_TTL, ttl)
@@ -735,31 +756,9 @@ pub(crate) mod sockopt {
multiaddr: &Ipv6Addr,
interface: u32,
) -> io::Result<()> {
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(bsd, solarish, target_os = "haiku", target_os = "l4re")))]
use c::IPV6_ADD_MEMBERSHIP;
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- ))]
+ #[cfg(any(bsd, solarish, target_os = "haiku", target_os = "l4re"))]
use c::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP;
let mreq = to_ipv6mr(multiaddr, interface);
@@ -782,31 +781,9 @@ pub(crate) mod sockopt {
multiaddr: &Ipv6Addr,
interface: u32,
) -> io::Result<()> {
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(bsd, solarish, target_os = "haiku", target_os = "l4re")))]
use c::IPV6_DROP_MEMBERSHIP;
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- ))]
+ #[cfg(any(bsd, solarish, target_os = "haiku", target_os = "l4re"))]
use c::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP;
let mreq = to_ipv6mr(multiaddr, interface);
diff --git a/vendor/rustix/src/backend/libc/net/types.rs b/vendor/rustix/src/backend/libc/net/types.rs
index 19d97e7c7..54f60ca50 100644
--- a/vendor/rustix/src/backend/libc/net/types.rs
+++ b/vendor/rustix/src/backend/libc/net/types.rs
@@ -62,16 +62,10 @@ impl AddressFamily {
pub const INET6: Self = Self(c::AF_INET6 as _);
/// `AF_NETLINK`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const NETLINK: Self = Self(c::AF_NETLINK as _);
/// `AF_UNIX`, aka `AF_LOCAL`
@@ -79,16 +73,10 @@ impl AddressFamily {
pub const UNIX: Self = Self(c::AF_UNIX as _);
/// `AF_AX25`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const AX25: Self = Self(c::AF_AX25 as _);
/// `AF_IPX`
@@ -97,70 +85,41 @@ impl AddressFamily {
pub const APPLETALK: Self = Self(c::AF_APPLETALK as _);
/// `AF_NETROM`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const NETROM: Self = Self(c::AF_NETROM as _);
/// `AF_BRIDGE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const BRIDGE: Self = Self(c::AF_BRIDGE as _);
/// `AF_ATMPVC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ATMPVC: Self = Self(c::AF_ATMPVC as _);
/// `AF_X25`
#[cfg(not(any(
+ bsd,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
)))]
pub const X25: Self = Self(c::AF_X25 as _);
/// `AF_ROSE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ROSE: Self = Self(c::AF_ROSE as _);
/// `AF_DECnet`
@@ -169,110 +128,64 @@ impl AddressFamily {
pub const DECnet: Self = Self(c::AF_DECnet as _);
/// `AF_NETBEUI`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const NETBEUI: Self = Self(c::AF_NETBEUI as _);
/// `AF_SECURITY`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const SECURITY: Self = Self(c::AF_SECURITY as _);
/// `AF_KEY`
#[cfg(not(any(
+ bsd,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
)))]
pub const KEY: Self = Self(c::AF_KEY as _);
/// `AF_PACKET`
#[cfg(not(any(
+ bsd,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
)))]
pub const PACKET: Self = Self(c::AF_PACKET as _);
/// `AF_ASH`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ASH: Self = Self(c::AF_ASH as _);
/// `AF_ECONET`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ECONET: Self = Self(c::AF_ECONET as _);
/// `AF_ATMSVC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ATMSVC: Self = Self(c::AF_ATMSVC as _);
/// `AF_RDS`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const RDS: Self = Self(c::AF_RDS as _);
/// `AF_SNA`
@@ -280,147 +193,87 @@ impl AddressFamily {
pub const SNA: Self = Self(c::AF_SNA as _);
/// `AF_IRDA`
#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ solarish,
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const IRDA: Self = Self(c::AF_IRDA as _);
/// `AF_PPPOX`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const PPPOX: Self = Self(c::AF_PPPOX as _);
/// `AF_WANPIPE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const WANPIPE: Self = Self(c::AF_WANPIPE as _);
/// `AF_LLC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const LLC: Self = Self(c::AF_LLC as _);
/// `AF_CAN`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const CAN: Self = Self(c::AF_CAN as _);
/// `AF_TIPC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const TIPC: Self = Self(c::AF_TIPC as _);
/// `AF_BLUETOOTH`
- #[cfg(not(any(windows, target_os = "illumos", target_os = "ios", target_os = "macos", target_os = "solaris")))]
+ #[cfg(not(any(apple, solarish, windows)))]
pub const BLUETOOTH: Self = Self(c::AF_BLUETOOTH as _);
/// `AF_IUCV`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const IUCV: Self = Self(c::AF_IUCV as _);
/// `AF_RXRPC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const RXRPC: Self = Self(c::AF_RXRPC as _);
/// `AF_ISDN`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const ISDN: Self = Self(c::AF_ISDN as _);
/// `AF_PHONET`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const PHONET: Self = Self(c::AF_PHONET as _);
/// `AF_IEEE802154`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const IEEE802154: Self = Self(c::AF_IEEE802154 as _);
@@ -453,164 +306,134 @@ impl Protocol {
/// `IPPROTO_ICMP`
pub const ICMP: Self = Self(c::IPPROTO_ICMP as _);
/// `IPPROTO_IGMP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const IGMP: Self = Self(c::IPPROTO_IGMP as _);
/// `IPPROTO_IPIP`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const IPIP: Self = Self(c::IPPROTO_IPIP as _);
/// `IPPROTO_TCP`
pub const TCP: Self = Self(c::IPPROTO_TCP as _);
/// `IPPROTO_EGP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const EGP: Self = Self(c::IPPROTO_EGP as _);
/// `IPPROTO_PUP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const PUP: Self = Self(c::IPPROTO_PUP as _);
/// `IPPROTO_UDP`
pub const UDP: Self = Self(c::IPPROTO_UDP as _);
/// `IPPROTO_IDP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const IDP: Self = Self(c::IPPROTO_IDP as _);
/// `IPPROTO_TP`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const TP: Self = Self(c::IPPROTO_TP as _);
/// `IPPROTO_DCCP`
#[cfg(not(any(
+ apple,
+ solarish,
windows,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
target_os = "openbsd",
- target_os = "solaris",
)))]
pub const DCCP: Self = Self(c::IPPROTO_DCCP as _);
/// `IPPROTO_IPV6`
pub const IPV6: Self = Self(c::IPPROTO_IPV6 as _);
/// `IPPROTO_RSVP`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const RSVP: Self = Self(c::IPPROTO_RSVP as _);
/// `IPPROTO_GRE`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const GRE: Self = Self(c::IPPROTO_GRE as _);
/// `IPPROTO_ESP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const ESP: Self = Self(c::IPPROTO_ESP as _);
/// `IPPROTO_AH`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const AH: Self = Self(c::IPPROTO_AH as _);
/// `IPPROTO_MTP`
#[cfg(not(any(
+ solarish,
+ netbsdlike,
windows,
target_os = "haiku",
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const MTP: Self = Self(c::IPPROTO_MTP as _);
/// `IPPROTO_BEETPH`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const BEETPH: Self = Self(c::IPPROTO_BEETPH as _);
/// `IPPROTO_ENCAP`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const ENCAP: Self = Self(c::IPPROTO_ENCAP as _);
/// `IPPROTO_PIM`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const PIM: Self = Self(c::IPPROTO_PIM as _);
/// `IPPROTO_COMP`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const COMP: Self = Self(c::IPPROTO_COMP as _);
/// `IPPROTO_SCTP`
- #[cfg(not(any(target_os = "dragonfly", target_os = "haiku", target_os = "illumos", target_os = "openbsd", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "dragonfly", target_os = "haiku", target_os = "openbsd")))]
pub const SCTP: Self = Self(c::IPPROTO_SCTP as _);
/// `IPPROTO_UDPLITE`
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
windows,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const UDPLITE: Self = Self(c::IPPROTO_UDPLITE as _);
/// `IPPROTO_MPLS`
#[cfg(not(any(
+ apple,
+ solarish,
windows,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
target_os = "netbsd",
- target_os = "solaris",
)))]
pub const MPLS: Self = Self(c::IPPROTO_MPLS as _);
/// `IPPROTO_RAW`
pub const RAW: Self = Self(c::IPPROTO_RAW as _);
/// `IPPROTO_MPTCP`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "android",
- target_os = "dragonfly",
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const MPTCP: Self = Self(c::IPPROTO_MPTCP as _);
/// `IPPROTO_FRAGMENT`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const FRAGMENT: Self = Self(c::IPPROTO_FRAGMENT as _);
/// `IPPROTO_ICMPV6`
pub const ICMPV6: Self = Self(c::IPPROTO_ICMPV6 as _);
/// `IPPROTO_MH`
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
windows,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const MH: Self = Self(c::IPPROTO_MH as _);
/// `IPPROTO_ROUTING`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const ROUTING: Self = Self(c::IPPROTO_ROUTING as _);
/// Constructs a `Protocol` from a raw integer.
@@ -647,11 +470,11 @@ bitflags! {
/// [`acceptfrom_with`]: crate::net::acceptfrom_with
pub struct AcceptFlags: c::c_int {
/// `SOCK_NONBLOCK`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows, target_os = "haiku")))]
const NONBLOCK = c::SOCK_NONBLOCK;
/// `SOCK_CLOEXEC`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows, target_os = "haiku")))]
const CLOEXEC = c::SOCK_CLOEXEC;
}
}
@@ -662,11 +485,11 @@ bitflags! {
/// [`socket`]: crate::net::socket
pub struct SocketFlags: c::c_int {
/// `SOCK_NONBLOCK`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows, target_os = "haiku")))]
const NONBLOCK = c::SOCK_NONBLOCK;
/// `SOCK_CLOEXEC`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows, target_os = "haiku")))]
const CLOEXEC = c::SOCK_CLOEXEC;
}
}
diff --git a/vendor/rustix/src/backend/libc/net/write_sockaddr.rs b/vendor/rustix/src/backend/libc/net/write_sockaddr.rs
index f44284a0b..f8ab62966 100644
--- a/vendor/rustix/src/backend/libc/net/write_sockaddr.rs
+++ b/vendor/rustix/src/backend/libc/net/write_sockaddr.rs
@@ -23,15 +23,7 @@ pub(crate) unsafe fn write_sockaddr(
pub(crate) unsafe fn encode_sockaddr_v4(v4: &SocketAddrV4) -> c::sockaddr_in {
c::sockaddr_in {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sin_len: size_of::<c::sockaddr_in>() as _,
sin_family: c::AF_INET as _,
sin_port: u16::to_be(v4.port()),
@@ -50,15 +42,7 @@ unsafe fn write_sockaddr_v4(v4: &SocketAddrV4, storage: *mut SocketAddrStorage)
}
pub(crate) unsafe fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
{
sockaddr_in6_new(
size_of::<c::sockaddr_in6>() as _,
@@ -69,15 +53,7 @@ pub(crate) unsafe fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 {
v6.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",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
{
sockaddr_in6_new(
c::AF_INET6 as _,