Skip to content

Commit 700a130

Browse files
committed
Fix ancillary definitions
1 parent 56a9a8d commit 700a130

File tree

10 files changed

+60
-40
lines changed

10 files changed

+60
-40
lines changed

library/std/src/os/cygwin/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Cygwin-specific definitions
22
#![stable(feature = "raw_ext", since = "1.1.0")]
33
pub mod fs;
4+
pub mod net;
45
pub(crate) mod raw;

library/std/src/os/cygwin/net.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Cygwin-specific networking functionality.
2+
3+
#![stable(feature = "unix_socket_abstract", since = "1.70.0")]
4+
5+
#[stable(feature = "unix_socket_abstract", since = "1.70.0")]
6+
pub use crate::os::net::linux_ext::addr::SocketAddrExt;
7+
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
8+
pub use crate::os::net::linux_ext::socket::UnixSocketExt;
9+
#[unstable(feature = "tcp_quickack", issue = "96256")]
10+
pub use crate::os::net::linux_ext::tcp::TcpStreamExt;

library/std/src/os/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,5 @@ pub mod xous;
185185
#[cfg(any(unix, target_os = "hermit", target_os = "trusty", target_os = "wasi", doc))]
186186
pub mod fd;
187187

188-
#[cfg(any(target_os = "linux", target_os = "android", doc))]
188+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin", doc))]
189189
mod net;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::ffi::OsStr;
2-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
2+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
33
use crate::os::net::linux_ext;
44
use crate::os::unix::ffi::OsStrExt;
55
use crate::path::Path;

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use crate::sys::net::Socket;
1616
not(target_os = "linux"),
1717
not(target_os = "android"),
1818
not(target_os = "netbsd"),
19-
not(target_os = "freebsd")
19+
not(target_os = "freebsd"),
20+
not(target_os = "cygwin"),
2021
))]
2122
#[allow(non_camel_case_types)]
2223
mod libc {
@@ -195,14 +196,15 @@ impl<'a, T> Iterator for AncillaryDataIter<'a, T> {
195196
not(target_os = "android"),
196197
not(target_os = "linux"),
197198
not(target_os = "netbsd"),
198-
not(target_os = "freebsd")
199+
not(target_os = "freebsd"),
200+
not(target_os = "cygwin"),
199201
))]
200202
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
201203
#[derive(Clone)]
202204
pub struct SocketCred(());
203205

204206
/// Unix credential.
205-
#[cfg(any(target_os = "android", target_os = "linux",))]
207+
#[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))]
206208
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
207209
#[derive(Clone)]
208210
pub struct SocketCred(libc::ucred);
@@ -217,8 +219,8 @@ pub struct SocketCred(libc::sockcred);
217219
#[derive(Clone)]
218220
pub struct SocketCred(libc::sockcred2);
219221

220-
#[doc(cfg(any(target_os = "android", target_os = "linux")))]
221-
#[cfg(any(target_os = "android", target_os = "linux"))]
222+
#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin")))]
223+
#[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))]
222224
impl SocketCred {
223225
/// Creates a Unix credential struct.
224226
///
@@ -407,15 +409,16 @@ impl<'a> Iterator for ScmRights<'a> {
407409
not(target_os = "android"),
408410
not(target_os = "linux"),
409411
not(target_os = "netbsd"),
410-
not(target_os = "freebsd")
412+
not(target_os = "freebsd"),
413+
not(target_os = "cygwin"),
411414
))]
412415
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
413416
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, ()>);
414417

415418
/// This control message contains unix credentials.
416419
///
417420
/// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_CREDENTIALS` or `SCM_CREDS`.
418-
#[cfg(any(target_os = "android", target_os = "linux",))]
421+
#[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))]
419422
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
420423
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::ucred>);
421424

@@ -432,7 +435,8 @@ pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::sockcred>);
432435
target_os = "android",
433436
target_os = "linux",
434437
target_os = "netbsd",
435-
target_os = "freebsd"
438+
target_os = "freebsd",
439+
target_os = "cygwin",
436440
))]
437441
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
438442
impl<'a> Iterator for ScmCredentials<'a> {
@@ -460,7 +464,8 @@ pub enum AncillaryData<'a> {
460464
target_os = "android",
461465
target_os = "linux",
462466
target_os = "netbsd",
463-
target_os = "freebsd"
467+
target_os = "freebsd",
468+
target_os = "cygwin",
464469
))]
465470
ScmCredentials(ScmCredentials<'a>),
466471
}
@@ -489,7 +494,8 @@ impl<'a> AncillaryData<'a> {
489494
target_os = "android",
490495
target_os = "linux",
491496
target_os = "netbsd",
492-
target_os = "freebsd"
497+
target_os = "freebsd",
498+
target_os = "cygwin",
493499
))]
494500
unsafe fn as_credentials(data: &'a [u8]) -> Self {
495501
let ancillary_data_iter = AncillaryDataIter::new(data);
@@ -507,7 +513,7 @@ impl<'a> AncillaryData<'a> {
507513
match (*cmsg).cmsg_level {
508514
libc::SOL_SOCKET => match (*cmsg).cmsg_type {
509515
libc::SCM_RIGHTS => Ok(AncillaryData::as_rights(data)),
510-
#[cfg(any(target_os = "android", target_os = "linux",))]
516+
#[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))]
511517
libc::SCM_CREDENTIALS => Ok(AncillaryData::as_credentials(data)),
512518
#[cfg(target_os = "freebsd")]
513519
libc::SCM_CREDS2 => Ok(AncillaryData::as_credentials(data)),
@@ -729,7 +735,8 @@ impl<'a> SocketAncillary<'a> {
729735
target_os = "android",
730736
target_os = "linux",
731737
target_os = "netbsd",
732-
target_os = "freebsd"
738+
target_os = "freebsd",
739+
target_os = "cygwin",
733740
))]
734741
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
735742
pub fn add_creds(&mut self, creds: &[SocketCred]) -> bool {

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
use libc::MSG_NOSIGNAL;
1515

1616
use super::{SocketAddr, sockaddr_un};
17-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
17+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
1818
use super::{SocketAncillary, recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to};
19-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
19+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
2020
use crate::io::{IoSlice, IoSliceMut};
2121
use crate::net::Shutdown;
2222
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
@@ -397,8 +397,8 @@ impl UnixDatagram {
397397
///
398398
/// # Examples
399399
///
400-
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
401-
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
400+
#[cfg_attr(any(target_os = "android", target_os = "linux", target_os = "cygwin"), doc = "```no_run")]
401+
#[cfg_attr(not(any(target_os = "android", target_os = "linux", target_os = "cygwin")), doc = "```ignore")]
402402
/// #![feature(unix_socket_ancillary_data)]
403403
/// use std::os::unix::net::{UnixDatagram, SocketAncillary, AncillaryData};
404404
/// use std::io::IoSliceMut;
@@ -428,7 +428,7 @@ impl UnixDatagram {
428428
/// Ok(())
429429
/// }
430430
/// ```
431-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
431+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
432432
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
433433
pub fn recv_vectored_with_ancillary_from(
434434
&self,
@@ -447,8 +447,8 @@ impl UnixDatagram {
447447
///
448448
/// # Examples
449449
///
450-
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
451-
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
450+
#[cfg_attr(any(target_os = "android", target_os = "linux", target_os = "cygwin"), doc = "```no_run")]
451+
#[cfg_attr(not(any(target_os = "android", target_os = "linux", target_os = "cygwin")), doc = "```ignore")]
452452
/// #![feature(unix_socket_ancillary_data)]
453453
/// use std::os::unix::net::{UnixDatagram, SocketAncillary, AncillaryData};
454454
/// use std::io::IoSliceMut;
@@ -478,7 +478,7 @@ impl UnixDatagram {
478478
/// Ok(())
479479
/// }
480480
/// ```
481-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
481+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
482482
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
483483
pub fn recv_vectored_with_ancillary(
484484
&self,
@@ -588,8 +588,8 @@ impl UnixDatagram {
588588
///
589589
/// # Examples
590590
///
591-
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
592-
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
591+
#[cfg_attr(any(target_os = "android", target_os = "linux", target_os = "cygwin"), doc = "```no_run")]
592+
#[cfg_attr(not(any(target_os = "android", target_os = "linux", target_os = "cygwin")), doc = "```ignore")]
593593
/// #![feature(unix_socket_ancillary_data)]
594594
/// use std::os::unix::net::{UnixDatagram, SocketAncillary};
595595
/// use std::io::IoSlice;
@@ -613,7 +613,7 @@ impl UnixDatagram {
613613
/// Ok(())
614614
/// }
615615
/// ```
616-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
616+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
617617
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
618618
pub fn send_vectored_with_ancillary_to<P: AsRef<Path>>(
619619
&self,
@@ -630,8 +630,8 @@ impl UnixDatagram {
630630
///
631631
/// # Examples
632632
///
633-
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
634-
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
633+
#[cfg_attr(any(target_os = "android", target_os = "linux", target_os = "cygwin"), doc = "```no_run")]
634+
#[cfg_attr(not(any(target_os = "android", target_os = "linux", target_os = "cygwin")), doc = "```ignore")]
635635
/// #![feature(unix_socket_ancillary_data)]
636636
/// use std::os::unix::net::{UnixDatagram, SocketAncillary};
637637
/// use std::io::IoSlice;
@@ -655,7 +655,7 @@ impl UnixDatagram {
655655
/// Ok(())
656656
/// }
657657
/// ```
658-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
658+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
659659
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
660660
pub fn send_vectored_with_ancillary(
661661
&self,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#![stable(feature = "unix_socket", since = "1.10.0")]
55

66
mod addr;
7-
#[doc(cfg(any(target_os = "android", target_os = "linux")))]
8-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
7+
#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin")))]
8+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
99
mod ancillary;
1010
mod datagram;
1111
mod listener;
@@ -27,7 +27,7 @@ mod ucred;
2727

2828
#[stable(feature = "unix_socket", since = "1.10.0")]
2929
pub use self::addr::*;
30-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
30+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
3131
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
3232
pub use self::ancillary::*;
3333
#[stable(feature = "unix_socket", since = "1.10.0")]

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{SocketAddr, sockaddr_un};
2-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
2+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
33
use super::{SocketAncillary, recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to};
44
#[cfg(any(
55
target_os = "android",
@@ -485,8 +485,8 @@ impl UnixStream {
485485
///
486486
/// # Examples
487487
///
488-
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
489-
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
488+
#[cfg_attr(any(target_os = "android", target_os = "linux", target_os = "cygwin"), doc = "```no_run")]
489+
#[cfg_attr(not(any(target_os = "android", target_os = "linux", target_os = "cygwin")), doc = "```ignore")]
490490
/// #![feature(unix_socket_ancillary_data)]
491491
/// use std::os::unix::net::{UnixStream, SocketAncillary, AncillaryData};
492492
/// use std::io::IoSliceMut;
@@ -516,7 +516,7 @@ impl UnixStream {
516516
/// Ok(())
517517
/// }
518518
/// ```
519-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
519+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
520520
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
521521
pub fn recv_vectored_with_ancillary(
522522
&self,
@@ -534,8 +534,8 @@ impl UnixStream {
534534
///
535535
/// # Examples
536536
///
537-
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
538-
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
537+
#[cfg_attr(any(target_os = "android", target_os = "linux", target_os = "cygwin"), doc = "```no_run")]
538+
#[cfg_attr(not(any(target_os = "android", target_os = "linux", target_os = "cygwin")), doc = "```ignore")]
539539
/// #![feature(unix_socket_ancillary_data)]
540540
/// use std::os::unix::net::{UnixStream, SocketAncillary};
541541
/// use std::io::IoSlice;
@@ -559,7 +559,7 @@ impl UnixStream {
559559
/// Ok(())
560560
/// }
561561
/// ```
562-
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
562+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))]
563563
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
564564
pub fn send_vectored_with_ancillary(
565565
&self,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use crate::io::{self, ErrorKind, IoSlice, IoSliceMut};
55
use crate::os::android::net::{SocketAddrExt, UnixSocketExt};
66
#[cfg(target_os = "linux")]
77
use crate::os::linux::net::{SocketAddrExt, UnixSocketExt};
8+
#[cfg(target_os = "cygwin")]
9+
use crate::os::cygwin::net::{SocketAddrExt, UnixSocketExt};
810
#[cfg(any(target_os = "android", target_os = "linux"))]
911
use crate::os::unix::io::AsRawFd;
1012
use crate::test_helpers::tmpdir;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl Socket {
348348
self.recv_from_with_flags(buf, 0)
349349
}
350350

351-
#[cfg(any(target_os = "android", target_os = "linux"))]
351+
#[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))]
352352
pub fn recv_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> {
353353
let n = cvt(unsafe { libc::recvmsg(self.as_raw_fd(), msg, libc::MSG_CMSG_CLOEXEC) })?;
354354
Ok(n as usize)
@@ -371,7 +371,7 @@ impl Socket {
371371
self.0.is_write_vectored()
372372
}
373373

374-
#[cfg(any(target_os = "android", target_os = "linux"))]
374+
#[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))]
375375
pub fn send_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> {
376376
let n = cvt(unsafe { libc::sendmsg(self.as_raw_fd(), msg, 0) })?;
377377
Ok(n as usize)

0 commit comments

Comments
 (0)