Skip to content

Commit 4e5f089

Browse files
authored
refactor: cfg for socket/sockopt.rs (#2225)
1 parent 51adb30 commit 4e5f089

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

src/sys/socket/sockopt.rs

+12-26
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use cfg_if::cfg_if;
77
use libc::{self, c_int, c_void, socklen_t};
88
use std::ffi::{OsStr, OsString};
99
use std::mem::{self, MaybeUninit};
10-
#[cfg(target_family = "unix")]
1110
use std::os::unix::ffi::OsStrExt;
1211
use std::os::unix::io::{AsFd, AsRawFd};
1312

@@ -329,9 +328,7 @@ cfg_if! {
329328
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
330329
/// Leave an IPv6 multicast group.
331330
Ipv6DropMembership, SetOnly, libc::IPPROTO_IPV6, libc::IPV6_DROP_MEMBERSHIP, super::Ipv6MembershipRequest);
332-
} else if #[cfg(any(bsd,
333-
target_os = "illumos",
334-
target_os = "solaris"))] {
331+
} else if #[cfg(any(bsd, solarish))] {
335332
#[cfg(feature = "net")]
336333
sockopt_impl!(
337334
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
@@ -403,7 +400,7 @@ sockopt_impl!(
403400
libc::IPV6_TCLASS,
404401
libc::c_int
405402
);
406-
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
403+
#[cfg(any(linux_android, target_os = "fuchsia"))]
407404
#[cfg(feature = "net")]
408405
sockopt_impl!(
409406
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
@@ -512,12 +509,7 @@ sockopt_impl!(
512509
libc::TCP_KEEPALIVE,
513510
u32
514511
);
515-
#[cfg(any(
516-
target_os = "android",
517-
target_os = "dragonfly",
518-
target_os = "freebsd",
519-
target_os = "linux"
520-
))]
512+
#[cfg(any(freebsdlike, linux_android))]
521513
#[cfg(feature = "net")]
522514
sockopt_impl!(
523515
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
@@ -556,7 +548,7 @@ sockopt_impl!(
556548
libc::TCP_KEEPCNT,
557549
u32
558550
);
559-
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
551+
#[cfg(any(linux_android, target_os = "fuchsia"))]
560552
sockopt_impl!(
561553
#[allow(missing_docs)]
562554
// Not documented by Linux!
@@ -826,12 +818,7 @@ sockopt_impl!(
826818
libc::TCP_CONGESTION,
827819
OsString<[u8; TCP_CA_NAME_MAX]>
828820
);
829-
#[cfg(any(
830-
target_os = "android",
831-
apple_targets,
832-
target_os = "linux",
833-
target_os = "netbsd",
834-
))]
821+
#[cfg(any(linux_android, apple_targets, target_os = "netbsd"))]
835822
#[cfg(feature = "net")]
836823
sockopt_impl!(
837824
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
@@ -844,10 +831,9 @@ sockopt_impl!(
844831
bool
845832
);
846833
#[cfg(any(
847-
target_os = "android",
834+
linux_android,
848835
target_os = "freebsd",
849836
apple_targets,
850-
target_os = "linux",
851837
target_os = "netbsd",
852838
target_os = "openbsd",
853839
))]
@@ -896,7 +882,7 @@ sockopt_impl!(
896882
libc::IP_RECVDSTADDR,
897883
bool
898884
);
899-
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
885+
#[cfg(any(linux_android, target_os = "freebsd"))]
900886
#[cfg(feature = "net")]
901887
sockopt_impl!(
902888
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
@@ -942,7 +928,7 @@ sockopt_impl!(
942928
libc::SO_TXTIME,
943929
libc::sock_txtime
944930
);
945-
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
931+
#[cfg(any(linux_android, target_os = "fuchsia"))]
946932
sockopt_impl!(
947933
/// Indicates that an unsigned 32-bit value ancillary message (cmsg) should
948934
/// be attached to received skbs indicating the number of packets dropped by
@@ -990,7 +976,7 @@ sockopt_impl!(
990976
libc::IP_MTU,
991977
libc::c_int
992978
);
993-
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
979+
#[cfg(any(linux_android, target_os = "freebsd"))]
994980
sockopt_impl!(
995981
/// Set or retrieve the current time-to-live field that is used in every
996982
/// packet sent from this socket.
@@ -1000,7 +986,7 @@ sockopt_impl!(
1000986
libc::IP_TTL,
1001987
libc::c_int
1002988
);
1003-
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
989+
#[cfg(any(linux_android, target_os = "freebsd"))]
1004990
sockopt_impl!(
1005991
/// Set the unicast hop limit for the socket.
1006992
Ipv6Ttl,
@@ -1009,7 +995,7 @@ sockopt_impl!(
1009995
libc::IPV6_UNICAST_HOPS,
1010996
libc::c_int
1011997
);
1012-
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
998+
#[cfg(any(linux_android, target_os = "freebsd"))]
1013999
#[cfg(feature = "net")]
10141000
sockopt_impl!(
10151001
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
@@ -1030,7 +1016,7 @@ sockopt_impl!(
10301016
libc::IP_DONTFRAG,
10311017
bool
10321018
);
1033-
#[cfg(any(target_os = "android", apple_targets, target_os = "linux",))]
1019+
#[cfg(any(linux_android, apple_targets))]
10341020
sockopt_impl!(
10351021
/// Set "don't fragment packet" flag on the IPv6 packet.
10361022
Ipv6DontFrag,

0 commit comments

Comments
 (0)