diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/socket2/src | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/socket2/src')
-rw-r--r-- | vendor/socket2/src/lib.rs | 22 | ||||
-rw-r--r-- | vendor/socket2/src/sockaddr.rs | 14 | ||||
-rw-r--r-- | vendor/socket2/src/socket.rs | 42 | ||||
-rw-r--r-- | vendor/socket2/src/sys/unix.rs | 71 |
4 files changed, 121 insertions, 28 deletions
diff --git a/vendor/socket2/src/lib.rs b/vendor/socket2/src/lib.rs index a2e2ffcb8..aa932a2c3 100644 --- a/vendor/socket2/src/lib.rs +++ b/vendor/socket2/src/lib.rs @@ -205,13 +205,16 @@ impl Type { pub const DGRAM: Type = Type(sys::SOCK_DGRAM); /// Type corresponding to `SOCK_SEQPACKET`. - #[cfg(feature = "all")] - #[cfg_attr(docsrs, doc(cfg(feature = "all")))] + #[cfg(all(feature = "all", not(target_os = "espidf")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "espidf")))))] pub const SEQPACKET: Type = Type(sys::SOCK_SEQPACKET); /// Type corresponding to `SOCK_RAW`. - #[cfg(all(feature = "all", not(target_os = "redox")))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "redox")))))] + #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) + )] pub const RAW: Type = Type(sys::SOCK_RAW); } @@ -280,6 +283,7 @@ impl RecvFlags { /// /// On Unix this corresponds to the `MSG_TRUNC` flag. /// On Windows this corresponds to the `WSAEMSGSIZE` error code. + #[cfg(not(target_os = "espidf"))] pub const fn is_truncated(self) -> bool { self.0 & sys::MSG_TRUNC != 0 } @@ -327,13 +331,15 @@ impl<'a> DerefMut for MaybeUninitSlice<'a> { /// See [`Socket::set_tcp_keepalive`]. #[derive(Debug, Clone)] pub struct TcpKeepalive { - #[cfg_attr(target_os = "openbsd", allow(dead_code))] + #[cfg_attr(any(target_os = "openbsd", target_os = "vita"), allow(dead_code))] time: Option<Duration>, #[cfg(not(any( target_os = "openbsd", target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] interval: Option<Duration>, #[cfg(not(any( @@ -342,6 +348,8 @@ pub struct TcpKeepalive { target_os = "solaris", target_os = "windows", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] retries: Option<u32>, } @@ -356,6 +364,8 @@ impl TcpKeepalive { target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] interval: None, #[cfg(not(any( @@ -364,6 +374,8 @@ impl TcpKeepalive { target_os = "solaris", target_os = "windows", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] retries: None, } diff --git a/vendor/socket2/src/sockaddr.rs b/vendor/socket2/src/sockaddr.rs index 9ce638e9a..e72101872 100644 --- a/vendor/socket2/src/sockaddr.rs +++ b/vendor/socket2/src/sockaddr.rs @@ -234,9 +234,14 @@ impl From<SocketAddrV4> for SockAddr { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", + target_os = "nto", + target_os = "espidf", + target_os = "vita", ))] sin_len: 0, + #[cfg(target_os = "vita")] + sin_vport: addr.port().to_be(), }; let mut storage = MaybeUninit::<sockaddr_storage>::zeroed(); // Safety: A `sockaddr_in` is memory compatible with a `sockaddr_storage` @@ -273,9 +278,14 @@ impl From<SocketAddrV6> for SockAddr { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", + target_os = "nto", + target_os = "espidf", + target_os = "vita", ))] sin6_len: 0, + #[cfg(target_os = "vita")] + sin6_vport: addr.port().to_be(), #[cfg(any(target_os = "solaris", target_os = "illumos"))] __sin6_src_id: 0, }; diff --git a/vendor/socket2/src/socket.rs b/vendor/socket2/src/socket.rs index 69d0478dd..90649d9d3 100644 --- a/vendor/socket2/src/socket.rs +++ b/vendor/socket2/src/socket.rs @@ -729,6 +729,8 @@ fn set_common_flags(socket: Socket) -> io::Result<Socket> { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "espidf", + target_os = "vita", )) ))] socket._set_cloexec(true)?; @@ -1042,8 +1044,11 @@ impl Socket { /// For more information about this option, see [`set_header_included`]. /// /// [`set_header_included`]: Socket::set_header_included - #[cfg(all(feature = "all", not(target_os = "redox")))] - #[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))] + #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) + )] pub fn header_included(&self) -> io::Result<bool> { unsafe { getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_HDRINCL) @@ -1062,8 +1067,11 @@ impl Socket { /// [raw(7)]: https://man7.org/linux/man-pages/man7/raw.7.html /// [`IP_TTL`]: Socket::set_ttl /// [`IP_TOS`]: Socket::set_tos - #[cfg(all(feature = "all", not(target_os = "redox")))] - #[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))] + #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) + )] pub fn set_header_included(&self, included: bool) -> io::Result<()> { unsafe { setsockopt( @@ -1166,6 +1174,8 @@ impl Socket { target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] pub fn join_multicast_v4_n( &self, @@ -1196,6 +1206,8 @@ impl Socket { target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] pub fn leave_multicast_v4_n( &self, @@ -1228,6 +1240,8 @@ impl Socket { target_os = "redox", target_os = "fuchsia", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] pub fn join_ssm_v4( &self, @@ -1263,6 +1277,8 @@ impl Socket { target_os = "redox", target_os = "fuchsia", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] pub fn leave_ssm_v4( &self, @@ -1439,6 +1455,8 @@ impl Socket { target_os = "solaris", target_os = "windows", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] pub fn set_recv_tos(&self, recv_tos: bool) -> io::Result<()> { let recv_tos = if recv_tos { 1 } else { 0 }; @@ -1468,6 +1486,8 @@ impl Socket { target_os = "solaris", target_os = "windows", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] pub fn recv_tos(&self) -> io::Result<bool> { unsafe { @@ -1684,14 +1704,24 @@ impl Socket { doc, all( feature = "all", - not(any(windows, target_os = "haiku", target_os = "openbsd")) + not(any( + windows, + target_os = "haiku", + target_os = "openbsd", + target_os = "vita" + )) ) ))] #[cfg_attr( docsrs, doc(cfg(all( feature = "all", - not(any(windows, target_os = "haiku", target_os = "openbsd")) + not(any( + windows, + target_os = "haiku", + target_os = "openbsd", + target_os = "vita" + )) ))) )] pub fn keepalive_time(&self) -> io::Result<Duration> { diff --git a/vendor/socket2/src/sys/unix.rs b/vendor/socket2/src/sys/unix.rs index 74da8cc20..ec7c3e2e4 100644 --- a/vendor/socket2/src/sys/unix.rs +++ b/vendor/socket2/src/sys/unix.rs @@ -60,9 +60,9 @@ pub(crate) use libc::c_int; // Used in `Domain`. pub(crate) use libc::{AF_INET, AF_INET6}; // Used in `Type`. -#[cfg(all(feature = "all", not(target_os = "redox")))] +#[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] pub(crate) use libc::SOCK_RAW; -#[cfg(feature = "all")] +#[cfg(all(feature = "all", not(target_os = "espidf")))] pub(crate) use libc::SOCK_SEQPACKET; pub(crate) use libc::{SOCK_DGRAM, SOCK_STREAM}; // Used in `Protocol`. @@ -72,8 +72,10 @@ pub(crate) use libc::{ sa_family_t, sockaddr, sockaddr_in, sockaddr_in6, sockaddr_storage, socklen_t, }; // Used in `RecvFlags`. +#[cfg(not(any(target_os = "redox", target_os = "espidf")))] +pub(crate) use libc::MSG_TRUNC; #[cfg(not(target_os = "redox"))] -pub(crate) use libc::{MSG_TRUNC, SO_OOBINLINE}; +pub(crate) use libc::SO_OOBINLINE; // Used in `Socket`. #[cfg(not(target_os = "nto"))] pub(crate) use libc::ipv6_mreq as Ipv6Mreq; @@ -89,6 +91,8 @@ pub(crate) use libc::IP_HDRINCL; target_os = "solaris", target_os = "haiku", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] pub(crate) use libc::IP_RECVTOS; #[cfg(not(any( @@ -117,6 +121,8 @@ pub(crate) use libc::{ target_os = "redox", target_os = "fuchsia", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] pub(crate) use libc::{ ip_mreq_source as IpMreqSource, IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP, @@ -171,6 +177,7 @@ use libc::TCP_KEEPALIVE as KEEPALIVE_TIME; target_os = "haiku", target_os = "openbsd", target_os = "nto", + target_os = "vita", )))] use libc::TCP_KEEPIDLE as KEEPALIVE_TIME; @@ -232,6 +239,8 @@ type IovLen = usize; target_os = "solaris", target_os = "nto", target_vendor = "apple", + target_os = "espidf", + target_os = "vita", ))] type IovLen = c_int; @@ -370,10 +379,11 @@ impl_debug!( Type, libc::SOCK_STREAM, libc::SOCK_DGRAM, - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "redox", target_os = "espidf")))] libc::SOCK_RAW, - #[cfg(not(any(target_os = "redox", target_os = "haiku")))] + #[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "espidf")))] libc::SOCK_RDM, + #[cfg(not(target_os = "espidf"))] libc::SOCK_SEQPACKET, /* TODO: add these optional bit OR-ed flags: #[cfg(any( @@ -417,6 +427,7 @@ impl RecvFlags { /// a record is terminated by sending a message with the end-of-record flag set. /// /// On Unix this corresponds to the MSG_EOR flag. + #[cfg(not(target_os = "espidf"))] pub const fn is_end_of_record(self) -> bool { self.0 & libc::MSG_EOR != 0 } @@ -435,11 +446,13 @@ impl RecvFlags { #[cfg(not(target_os = "redox"))] impl std::fmt::Debug for RecvFlags { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("RecvFlags") - .field("is_end_of_record", &self.is_end_of_record()) - .field("is_out_of_band", &self.is_out_of_band()) - .field("is_truncated", &self.is_truncated()) - .finish() + let mut s = f.debug_struct("RecvFlags"); + #[cfg(not(target_os = "espidf"))] + s.field("is_end_of_record", &self.is_end_of_record()); + s.field("is_out_of_band", &self.is_out_of_band()); + #[cfg(not(target_os = "espidf"))] + s.field("is_truncated", &self.is_truncated()); + s.finish() } } @@ -704,6 +717,7 @@ pub(crate) fn try_clone(fd: Socket) -> io::Result<Socket> { syscall!(fcntl(fd, libc::F_DUPFD_CLOEXEC, 0)) } +#[cfg(not(target_os = "vita"))] pub(crate) fn set_nonblocking(fd: Socket, nonblocking: bool) -> io::Result<()> { if nonblocking { fcntl_add(fd, libc::F_GETFL, libc::F_SETFL, libc::O_NONBLOCK) @@ -712,6 +726,18 @@ pub(crate) fn set_nonblocking(fd: Socket, nonblocking: bool) -> io::Result<()> { } } +#[cfg(target_os = "vita")] +pub(crate) fn set_nonblocking(fd: Socket, nonblocking: bool) -> io::Result<()> { + unsafe { + setsockopt( + fd, + libc::SOL_SOCKET, + libc::SO_NONBLOCK, + nonblocking as libc::c_int, + ) + } +} + pub(crate) fn shutdown(fd: Socket, how: Shutdown) -> io::Result<()> { let how = match how { Shutdown::Write => libc::SHUT_WR, @@ -914,7 +940,7 @@ fn into_timeval(duration: Option<Duration>) -> libc::timeval { } #[cfg(feature = "all")] -#[cfg(not(any(target_os = "haiku", target_os = "openbsd")))] +#[cfg(not(any(target_os = "haiku", target_os = "openbsd", target_os = "vita")))] pub(crate) fn keepalive_time(fd: Socket) -> io::Result<Duration> { unsafe { getsockopt::<c_int>(fd, IPPROTO_TCP, KEEPALIVE_TIME) @@ -924,7 +950,12 @@ pub(crate) fn keepalive_time(fd: Socket) -> io::Result<Duration> { #[allow(unused_variables)] pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Result<()> { - #[cfg(not(any(target_os = "haiku", target_os = "openbsd", target_os = "nto")))] + #[cfg(not(any( + target_os = "haiku", + target_os = "openbsd", + target_os = "nto", + target_os = "vita" + )))] if let Some(time) = keepalive.time { let secs = into_secs(time); unsafe { setsockopt(fd, libc::IPPROTO_TCP, KEEPALIVE_TIME, secs)? } @@ -960,12 +991,18 @@ pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Res Ok(()) } -#[cfg(not(any(target_os = "haiku", target_os = "openbsd", target_os = "nto")))] +#[cfg(not(any( + target_os = "haiku", + target_os = "openbsd", + target_os = "nto", + target_os = "vita" +)))] fn into_secs(duration: Duration) -> c_int { min(duration.as_secs(), c_int::max_value() as u64) as c_int } /// Add `flag` to the current set flags of `F_GETFD`. +#[cfg(not(target_os = "vita"))] fn fcntl_add(fd: Socket, get_cmd: c_int, set_cmd: c_int, flag: c_int) -> io::Result<()> { let previous = syscall!(fcntl(fd, get_cmd))?; let new = previous | flag; @@ -978,6 +1015,7 @@ fn fcntl_add(fd: Socket, get_cmd: c_int, set_cmd: c_int, flag: c_int) -> io::Res } /// Remove `flag` to the current set flags of `F_GETFD`. +#[cfg(not(target_os = "vita"))] fn fcntl_remove(fd: Socket, get_cmd: c_int, set_cmd: c_int, flag: c_int) -> io::Result<()> { let previous = syscall!(fcntl(fd, get_cmd))?; let new = previous & !flag; @@ -1056,6 +1094,8 @@ pub(crate) fn from_in6_addr(addr: in6_addr) -> Ipv6Addr { target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", + target_os = "vita", )))] pub(crate) fn to_mreqn( multiaddr: &Ipv4Addr, @@ -1142,12 +1182,13 @@ impl crate::Socket { /// # Notes /// /// On supported platforms you can use [`Type::cloexec`]. - #[cfg(feature = "all")] - #[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))] + #[cfg(all(feature = "all", not(target_os = "vita")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix, not(target_os = "vita")))))] pub fn set_cloexec(&self, close_on_exec: bool) -> io::Result<()> { self._set_cloexec(close_on_exec) } + #[cfg(not(target_os = "vita"))] pub(crate) fn _set_cloexec(&self, close_on_exec: bool) -> io::Result<()> { if close_on_exec { fcntl_add( |