Skip to content

Commit 145254d

Browse files
aym-vThomasdezeeuw
authored andcommitted
conditionally include methods
1 parent e045bd1 commit 145254d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/socket.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,12 @@ impl Socket {
11751175
///
11761176
/// NOTE: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
11771177
/// documents that not all versions of windows support `IP_TOS`.
1178+
#[cfg(not(any(
1179+
target_os = "fuschia",
1180+
target_os = "redox",
1181+
target_os = "solaris",
1182+
target_os = "illumos",
1183+
)))]
11781184
pub fn set_tos(&self, tos: u32) -> io::Result<()> {
11791185
unsafe { setsockopt(self.inner, sys::IPPROTO_IP, sys::IP_TOS, tos as c_int) }
11801186
}
@@ -1186,6 +1192,12 @@ impl Socket {
11861192
/// NOTE: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
11871193
/// documents that not all versions of windows support `IP_TOS`.
11881194
/// [`set_tos`]: Socket::set_tos
1195+
#[cfg(not(any(
1196+
target_os = "fuschia",
1197+
target_os = "redox",
1198+
target_os = "solaris",
1199+
target_os = "illumos",
1200+
)))]
11891201
pub fn tos(&self) -> io::Result<u32> {
11901202
unsafe {
11911203
getsockopt::<c_int>(self.inner, sys::IPPROTO_IP, sys::IP_TOS).map(|tos| tos as u32)

src/sys/unix.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ pub(crate) use libc::{
7575
#[cfg(not(target_os = "redox"))]
7676
pub(crate) use libc::{MSG_TRUNC, SO_OOBINLINE};
7777
// Used in `Socket`.
78+
#[cfg(not(any(
79+
target_os = "fuschia",
80+
target_os = "redox",
81+
target_os = "solaris",
82+
target_os = "illumos",
83+
)))]
84+
pub(crate) use libc::IP_TOS;
7885
#[cfg(not(target_vendor = "apple"))]
7986
pub(crate) use libc::SO_LINGER;
8087
#[cfg(target_vendor = "apple")]
@@ -83,7 +90,7 @@ pub(crate) use libc::{
8390
ip_mreq as IpMreq, ipv6_mreq as Ipv6Mreq, linger, IPPROTO_IP, IPPROTO_IPV6,
8491
IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY,
8592
IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_IF, IP_MULTICAST_LOOP, IP_MULTICAST_TTL,
86-
IP_TOS, IP_TTL, MSG_OOB, MSG_PEEK, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_KEEPALIVE, SO_RCVBUF,
93+
IP_TTL, MSG_OOB, MSG_PEEK, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_KEEPALIVE, SO_RCVBUF,
8794
SO_RCVTIMEO, SO_REUSEADDR, SO_SNDBUF, SO_SNDTIMEO, SO_TYPE, TCP_NODELAY,
8895
};
8996
#[cfg(not(any(

0 commit comments

Comments
 (0)