Disable unix::net::ancillary on BSD.

This commit is contained in:
Mara Bos 2022-05-05 21:01:07 +02:00 committed by Josh Triplett
parent f80e454450
commit 8b9f8e25ba
6 changed files with 33 additions and 173 deletions

View file

@ -1,3 +1,5 @@
// FIXME: This is currently disabled on *BSD.
use super::{sockaddr_un, SocketAddr}; use super::{sockaddr_un, SocketAddr};
use crate::io::{self, IoSlice, IoSliceMut}; use crate::io::{self, IoSlice, IoSliceMut};
use crate::marker::PhantomData; use crate::marker::PhantomData;

View file

@ -1,24 +1,7 @@
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
doc,
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary}; use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
use super::{sockaddr_un, SocketAddr}; use super::{sockaddr_un, SocketAddr};
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
use crate::io::{IoSlice, IoSliceMut}; use crate::io::{IoSlice, IoSliceMut};
use crate::net::Shutdown; use crate::net::Shutdown;
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
@ -403,7 +386,8 @@ impl UnixDatagram {
/// ///
/// # Examples /// # Examples
/// ///
/// ```no_run #[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
/// #![feature(unix_socket_ancillary_data)] /// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixDatagram, SocketAncillary, AncillaryData}; /// use std::os::unix::net::{UnixDatagram, SocketAncillary, AncillaryData};
/// use std::io::IoSliceMut; /// use std::io::IoSliceMut;
@ -433,15 +417,7 @@ impl UnixDatagram {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn recv_vectored_with_ancillary_from( pub fn recv_vectored_with_ancillary_from(
&self, &self,
@ -460,7 +436,8 @@ impl UnixDatagram {
/// ///
/// # Examples /// # Examples
/// ///
/// ```no_run #[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
/// #![feature(unix_socket_ancillary_data)] /// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixDatagram, SocketAncillary, AncillaryData}; /// use std::os::unix::net::{UnixDatagram, SocketAncillary, AncillaryData};
/// use std::io::IoSliceMut; /// use std::io::IoSliceMut;
@ -490,15 +467,7 @@ impl UnixDatagram {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn recv_vectored_with_ancillary( pub fn recv_vectored_with_ancillary(
&self, &self,
@ -609,7 +578,8 @@ impl UnixDatagram {
/// ///
/// # Examples /// # Examples
/// ///
/// ```no_run #[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
/// #![feature(unix_socket_ancillary_data)] /// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixDatagram, SocketAncillary}; /// use std::os::unix::net::{UnixDatagram, SocketAncillary};
/// use std::io::IoSlice; /// use std::io::IoSlice;
@ -633,15 +603,7 @@ impl UnixDatagram {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn send_vectored_with_ancillary_to<P: AsRef<Path>>( pub fn send_vectored_with_ancillary_to<P: AsRef<Path>>(
&self, &self,
@ -658,7 +620,8 @@ impl UnixDatagram {
/// ///
/// # Examples /// # Examples
/// ///
/// ```no_run #[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
/// #![feature(unix_socket_ancillary_data)] /// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixDatagram, SocketAncillary}; /// use std::os::unix::net::{UnixDatagram, SocketAncillary};
/// use std::io::IoSlice; /// use std::io::IoSlice;
@ -682,15 +645,7 @@ impl UnixDatagram {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn send_vectored_with_ancillary( pub fn send_vectored_with_ancillary(
&self, &self,

View file

@ -1,27 +1,11 @@
//! Unix-specific networking functionality. //! Unix-specific networking functionality.
#![allow(irrefutable_let_patterns)]
#![stable(feature = "unix_socket", since = "1.10.0")] #![stable(feature = "unix_socket", since = "1.10.0")]
mod addr; mod addr;
#[doc(cfg(any( #[doc(cfg(any(target_os = "android", target_os = "linux")))]
target_os = "android", #[cfg(any(doc, target_os = "android", target_os = "linux"))]
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
)))]
#[cfg(any(
doc,
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
mod ancillary; mod ancillary;
mod datagram; mod datagram;
mod listener; mod listener;
@ -31,16 +15,7 @@ mod tests;
#[stable(feature = "unix_socket", since = "1.10.0")] #[stable(feature = "unix_socket", since = "1.10.0")]
pub use self::addr::*; pub use self::addr::*;
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
doc,
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub use self::ancillary::*; pub use self::ancillary::*;
#[stable(feature = "unix_socket", since = "1.10.0")] #[stable(feature = "unix_socket", since = "1.10.0")]

View file

@ -1,13 +1,4 @@
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
doc,
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary}; use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
use super::{sockaddr_un, SocketAddr}; use super::{sockaddr_un, SocketAddr};
use crate::fmt; use crate::fmt;
@ -511,7 +502,8 @@ impl UnixStream {
/// ///
/// # Examples /// # Examples
/// ///
/// ```no_run #[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
/// #![feature(unix_socket_ancillary_data)] /// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixStream, SocketAncillary, AncillaryData}; /// use std::os::unix::net::{UnixStream, SocketAncillary, AncillaryData};
/// use std::io::IoSliceMut; /// use std::io::IoSliceMut;
@ -541,15 +533,7 @@ impl UnixStream {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn recv_vectored_with_ancillary( pub fn recv_vectored_with_ancillary(
&self, &self,
@ -567,7 +551,8 @@ impl UnixStream {
/// ///
/// # Examples /// # Examples
/// ///
/// ```no_run #[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
/// #![feature(unix_socket_ancillary_data)] /// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixStream, SocketAncillary}; /// use std::os::unix::net::{UnixStream, SocketAncillary};
/// use std::io::IoSlice; /// use std::io::IoSlice;
@ -591,15 +576,7 @@ impl UnixStream {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[cfg(any( #[cfg(any(doc, target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn send_vectored_with_ancillary( pub fn send_vectored_with_ancillary(
&self, &self,

View file

@ -1,24 +1,7 @@
use super::*; use super::*;
use crate::io::prelude::*; use crate::io::prelude::*;
use crate::io::{self, ErrorKind, IoSlice, IoSliceMut}; use crate::io::{self, ErrorKind, IoSlice, IoSliceMut};
#[cfg(any( #[cfg(any(target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
use crate::os::unix::io::AsRawFd; use crate::os::unix::io::AsRawFd;
use crate::sys_common::io::test::tmpdir; use crate::sys_common::io::test::tmpdir;
use crate::thread; use crate::thread;
@ -618,15 +601,7 @@ fn test_unix_datagram_peek_from() {
assert_eq!(msg, &buf[..]); assert_eq!(msg, &buf[..]);
} }
#[cfg(any( #[cfg(any(target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[test] #[test]
fn test_send_vectored_fds_unix_stream() { fn test_send_vectored_fds_unix_stream() {
let (s1, s2) = or_panic!(UnixStream::pair()); let (s1, s2) = or_panic!(UnixStream::pair());
@ -664,7 +639,7 @@ fn test_send_vectored_fds_unix_stream() {
} }
} }
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))] #[cfg(any(target_os = "android", target_os = "linux",))]
#[test] #[test]
fn test_send_vectored_with_ancillary_to_unix_datagram() { fn test_send_vectored_with_ancillary_to_unix_datagram() {
fn getpid() -> libc::pid_t { fn getpid() -> libc::pid_t {
@ -731,15 +706,7 @@ fn test_send_vectored_with_ancillary_to_unix_datagram() {
} }
} }
#[cfg(any( #[cfg(any(target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[test] #[test]
fn test_send_vectored_with_ancillary_unix_datagram() { fn test_send_vectored_with_ancillary_unix_datagram() {
let dir = tmpdir(); let dir = tmpdir();

View file

@ -289,15 +289,7 @@ impl Socket {
self.recv_from_with_flags(buf, 0) self.recv_from_with_flags(buf, 0)
} }
#[cfg(any( #[cfg(any(target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
pub fn recv_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> { pub fn recv_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> {
let n = cvt(unsafe { libc::recvmsg(self.as_raw_fd(), msg, libc::MSG_CMSG_CLOEXEC) })?; let n = cvt(unsafe { libc::recvmsg(self.as_raw_fd(), msg, libc::MSG_CMSG_CLOEXEC) })?;
Ok(n as usize) Ok(n as usize)
@ -320,15 +312,7 @@ impl Socket {
self.0.is_write_vectored() self.0.is_write_vectored()
} }
#[cfg(any( #[cfg(any(target_os = "android", target_os = "linux"))]
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
pub fn send_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> { pub fn send_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> {
let n = cvt(unsafe { libc::sendmsg(self.as_raw_fd(), msg, 0) })?; let n = cvt(unsafe { libc::sendmsg(self.as_raw_fd(), msg, 0) })?;
Ok(n as usize) Ok(n as usize)