Skip to content

Commit 9e26dc7

Browse files
committed
Auto merge of #96742 - m-ou-se:bsd-no-ancillary, r=joshtriplett
Disable unix::net::ancillary on BSD. See #76915 (comment)
2 parents 8bf9c20 + 8b9f8e2 commit 9e26dc7

File tree

6 files changed

+33
-173
lines changed

6 files changed

+33
-173
lines changed

library/std/src/os/unix/net/ancillary.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// FIXME: This is currently disabled on *BSD.
2+
13
use super::{sockaddr_un, SocketAddr};
24
use crate::io::{self, IoSlice, IoSliceMut};
35
use crate::marker::PhantomData;

library/std/src/os/unix/net/datagram.rs

+14-59
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
#[cfg(any(
2-
doc,
3-
target_os = "android",
4-
target_os = "dragonfly",
5-
target_os = "emscripten",
6-
target_os = "freebsd",
7-
target_os = "linux",
8-
target_os = "netbsd",
9-
target_os = "openbsd",
10-
))]
1+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
112
use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
123
use super::{sockaddr_un, SocketAddr};
13-
#[cfg(any(
14-
target_os = "android",
15-
target_os = "dragonfly",
16-
target_os = "emscripten",
17-
target_os = "freebsd",
18-
target_os = "linux",
19-
target_os = "netbsd",
20-
target_os = "openbsd",
21-
))]
4+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
225
use crate::io::{IoSlice, IoSliceMut};
236
use crate::net::Shutdown;
247
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
@@ -403,7 +386,8 @@ impl UnixDatagram {
403386
///
404387
/// # Examples
405388
///
406-
/// ```no_run
389+
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
390+
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
407391
/// #![feature(unix_socket_ancillary_data)]
408392
/// use std::os::unix::net::{UnixDatagram, SocketAncillary, AncillaryData};
409393
/// use std::io::IoSliceMut;
@@ -433,15 +417,7 @@ impl UnixDatagram {
433417
/// Ok(())
434418
/// }
435419
/// ```
436-
#[cfg(any(
437-
target_os = "android",
438-
target_os = "dragonfly",
439-
target_os = "emscripten",
440-
target_os = "freebsd",
441-
target_os = "linux",
442-
target_os = "netbsd",
443-
target_os = "openbsd",
444-
))]
420+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
445421
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
446422
pub fn recv_vectored_with_ancillary_from(
447423
&self,
@@ -460,7 +436,8 @@ impl UnixDatagram {
460436
///
461437
/// # Examples
462438
///
463-
/// ```no_run
439+
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
440+
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
464441
/// #![feature(unix_socket_ancillary_data)]
465442
/// use std::os::unix::net::{UnixDatagram, SocketAncillary, AncillaryData};
466443
/// use std::io::IoSliceMut;
@@ -490,15 +467,7 @@ impl UnixDatagram {
490467
/// Ok(())
491468
/// }
492469
/// ```
493-
#[cfg(any(
494-
target_os = "android",
495-
target_os = "dragonfly",
496-
target_os = "emscripten",
497-
target_os = "freebsd",
498-
target_os = "linux",
499-
target_os = "netbsd",
500-
target_os = "openbsd",
501-
))]
470+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
502471
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
503472
pub fn recv_vectored_with_ancillary(
504473
&self,
@@ -609,7 +578,8 @@ impl UnixDatagram {
609578
///
610579
/// # Examples
611580
///
612-
/// ```no_run
581+
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
582+
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
613583
/// #![feature(unix_socket_ancillary_data)]
614584
/// use std::os::unix::net::{UnixDatagram, SocketAncillary};
615585
/// use std::io::IoSlice;
@@ -633,15 +603,7 @@ impl UnixDatagram {
633603
/// Ok(())
634604
/// }
635605
/// ```
636-
#[cfg(any(
637-
target_os = "android",
638-
target_os = "dragonfly",
639-
target_os = "emscripten",
640-
target_os = "freebsd",
641-
target_os = "linux",
642-
target_os = "netbsd",
643-
target_os = "openbsd",
644-
))]
606+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
645607
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
646608
pub fn send_vectored_with_ancillary_to<P: AsRef<Path>>(
647609
&self,
@@ -658,7 +620,8 @@ impl UnixDatagram {
658620
///
659621
/// # Examples
660622
///
661-
/// ```no_run
623+
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
624+
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
662625
/// #![feature(unix_socket_ancillary_data)]
663626
/// use std::os::unix::net::{UnixDatagram, SocketAncillary};
664627
/// use std::io::IoSlice;
@@ -682,15 +645,7 @@ impl UnixDatagram {
682645
/// Ok(())
683646
/// }
684647
/// ```
685-
#[cfg(any(
686-
target_os = "android",
687-
target_os = "dragonfly",
688-
target_os = "emscripten",
689-
target_os = "freebsd",
690-
target_os = "linux",
691-
target_os = "netbsd",
692-
target_os = "openbsd",
693-
))]
648+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
694649
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
695650
pub fn send_vectored_with_ancillary(
696651
&self,

library/std/src/os/unix/net/mod.rs

+4-29
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
//! Unix-specific networking functionality.
22
3+
#![allow(irrefutable_let_patterns)]
34
#![stable(feature = "unix_socket", since = "1.10.0")]
45

56
mod addr;
6-
#[doc(cfg(any(
7-
target_os = "android",
8-
target_os = "dragonfly",
9-
target_os = "emscripten",
10-
target_os = "freebsd",
11-
target_os = "linux",
12-
target_os = "netbsd",
13-
target_os = "openbsd",
14-
)))]
15-
#[cfg(any(
16-
doc,
17-
target_os = "android",
18-
target_os = "dragonfly",
19-
target_os = "emscripten",
20-
target_os = "freebsd",
21-
target_os = "linux",
22-
target_os = "netbsd",
23-
target_os = "openbsd",
24-
))]
7+
#[doc(cfg(any(target_os = "android", target_os = "linux")))]
8+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
259
mod ancillary;
2610
mod datagram;
2711
mod listener;
@@ -31,16 +15,7 @@ mod tests;
3115

3216
#[stable(feature = "unix_socket", since = "1.10.0")]
3317
pub use self::addr::*;
34-
#[cfg(any(
35-
doc,
36-
target_os = "android",
37-
target_os = "dragonfly",
38-
target_os = "emscripten",
39-
target_os = "freebsd",
40-
target_os = "linux",
41-
target_os = "netbsd",
42-
target_os = "openbsd",
43-
))]
18+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
4419
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
4520
pub use self::ancillary::*;
4621
#[stable(feature = "unix_socket", since = "1.10.0")]

library/std/src/os/unix/net/stream.rs

+7-30
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
#[cfg(any(
2-
doc,
3-
target_os = "android",
4-
target_os = "dragonfly",
5-
target_os = "emscripten",
6-
target_os = "freebsd",
7-
target_os = "linux",
8-
target_os = "netbsd",
9-
target_os = "openbsd",
10-
))]
1+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
112
use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
123
use super::{sockaddr_un, SocketAddr};
134
use crate::fmt;
@@ -511,7 +502,8 @@ impl UnixStream {
511502
///
512503
/// # Examples
513504
///
514-
/// ```no_run
505+
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
506+
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
515507
/// #![feature(unix_socket_ancillary_data)]
516508
/// use std::os::unix::net::{UnixStream, SocketAncillary, AncillaryData};
517509
/// use std::io::IoSliceMut;
@@ -541,15 +533,7 @@ impl UnixStream {
541533
/// Ok(())
542534
/// }
543535
/// ```
544-
#[cfg(any(
545-
target_os = "android",
546-
target_os = "dragonfly",
547-
target_os = "emscripten",
548-
target_os = "freebsd",
549-
target_os = "linux",
550-
target_os = "netbsd",
551-
target_os = "openbsd",
552-
))]
536+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
553537
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
554538
pub fn recv_vectored_with_ancillary(
555539
&self,
@@ -567,7 +551,8 @@ impl UnixStream {
567551
///
568552
/// # Examples
569553
///
570-
/// ```no_run
554+
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
555+
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
571556
/// #![feature(unix_socket_ancillary_data)]
572557
/// use std::os::unix::net::{UnixStream, SocketAncillary};
573558
/// use std::io::IoSlice;
@@ -591,15 +576,7 @@ impl UnixStream {
591576
/// Ok(())
592577
/// }
593578
/// ```
594-
#[cfg(any(
595-
target_os = "android",
596-
target_os = "dragonfly",
597-
target_os = "emscripten",
598-
target_os = "freebsd",
599-
target_os = "linux",
600-
target_os = "netbsd",
601-
target_os = "openbsd",
602-
))]
579+
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
603580
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
604581
pub fn send_vectored_with_ancillary(
605582
&self,

library/std/src/os/unix/net/tests.rs

+4-37
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
use super::*;
22
use crate::io::prelude::*;
33
use crate::io::{self, ErrorKind, IoSlice, IoSliceMut};
4-
#[cfg(any(
5-
target_os = "android",
6-
target_os = "dragonfly",
7-
target_os = "emscripten",
8-
target_os = "freebsd",
9-
target_os = "linux",
10-
target_os = "netbsd",
11-
target_os = "openbsd",
12-
))]
13-
#[cfg(any(
14-
target_os = "android",
15-
target_os = "dragonfly",
16-
target_os = "emscripten",
17-
target_os = "freebsd",
18-
target_os = "linux",
19-
target_os = "netbsd",
20-
target_os = "openbsd",
21-
))]
4+
#[cfg(any(target_os = "android", target_os = "linux"))]
225
use crate::os::unix::io::AsRawFd;
236
use crate::sys_common::io::test::tmpdir;
247
use crate::thread;
@@ -618,15 +601,7 @@ fn test_unix_datagram_peek_from() {
618601
assert_eq!(msg, &buf[..]);
619602
}
620603

621-
#[cfg(any(
622-
target_os = "android",
623-
target_os = "dragonfly",
624-
target_os = "emscripten",
625-
target_os = "freebsd",
626-
target_os = "linux",
627-
target_os = "netbsd",
628-
target_os = "openbsd",
629-
))]
604+
#[cfg(any(target_os = "android", target_os = "linux"))]
630605
#[test]
631606
fn test_send_vectored_fds_unix_stream() {
632607
let (s1, s2) = or_panic!(UnixStream::pair());
@@ -664,7 +639,7 @@ fn test_send_vectored_fds_unix_stream() {
664639
}
665640
}
666641

667-
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))]
642+
#[cfg(any(target_os = "android", target_os = "linux",))]
668643
#[test]
669644
fn test_send_vectored_with_ancillary_to_unix_datagram() {
670645
fn getpid() -> libc::pid_t {
@@ -731,15 +706,7 @@ fn test_send_vectored_with_ancillary_to_unix_datagram() {
731706
}
732707
}
733708

734-
#[cfg(any(
735-
target_os = "android",
736-
target_os = "dragonfly",
737-
target_os = "emscripten",
738-
target_os = "freebsd",
739-
target_os = "linux",
740-
target_os = "netbsd",
741-
target_os = "openbsd",
742-
))]
709+
#[cfg(any(target_os = "android", target_os = "linux"))]
743710
#[test]
744711
fn test_send_vectored_with_ancillary_unix_datagram() {
745712
let dir = tmpdir();

library/std/src/sys/unix/net.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,7 @@ impl Socket {
289289
self.recv_from_with_flags(buf, 0)
290290
}
291291

292-
#[cfg(any(
293-
target_os = "android",
294-
target_os = "dragonfly",
295-
target_os = "emscripten",
296-
target_os = "freebsd",
297-
target_os = "linux",
298-
target_os = "netbsd",
299-
target_os = "openbsd",
300-
))]
292+
#[cfg(any(target_os = "android", target_os = "linux"))]
301293
pub fn recv_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> {
302294
let n = cvt(unsafe { libc::recvmsg(self.as_raw_fd(), msg, libc::MSG_CMSG_CLOEXEC) })?;
303295
Ok(n as usize)
@@ -320,15 +312,7 @@ impl Socket {
320312
self.0.is_write_vectored()
321313
}
322314

323-
#[cfg(any(
324-
target_os = "android",
325-
target_os = "dragonfly",
326-
target_os = "emscripten",
327-
target_os = "freebsd",
328-
target_os = "linux",
329-
target_os = "netbsd",
330-
target_os = "openbsd",
331-
))]
315+
#[cfg(any(target_os = "android", target_os = "linux"))]
332316
pub fn send_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> {
333317
let n = cvt(unsafe { libc::sendmsg(self.as_raw_fd(), msg, 0) })?;
334318
Ok(n as usize)

0 commit comments

Comments
 (0)