Skip to content

Commit 83dfd90

Browse files
authored
refactor: apply the netbsdlike alias for src/* (#2231)
* refactor: apply the netbsdlike alias for src/* * remove openbsd
1 parent 0bb23ca commit 83dfd90

17 files changed

+66
-216
lines changed

src/errno.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ cfg_if! {
1212
unsafe fn errno_location() -> *mut c_int {
1313
unsafe { libc::__error() }
1414
}
15-
} else if #[cfg(any(target_os = "android",
16-
target_os = "netbsd",
17-
target_os = "openbsd"))] {
15+
} else if #[cfg(any(target_os = "android", netbsdlike))] {
1816
unsafe fn errno_location() -> *mut c_int {
1917
unsafe { libc::__errno() }
2018
}

src/fcntl.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ libc_bitflags!(
9999
#[cfg(not(solarish))]
100100
O_DIRECTORY;
101101
/// Implicitly follow each `write()` with an `fdatasync()`.
102-
#[cfg(any(linux_android,
103-
apple_targets,
104-
target_os = "netbsd",
105-
target_os = "openbsd"))]
102+
#[cfg(any(linux_android, apple_targets, netbsdlike))]
106103
O_DSYNC;
107104
/// Error out if a file was not created.
108105
O_EXCL;
@@ -150,7 +147,7 @@ libc_bitflags!(
150147
/// This should not be combined with `O_WRONLY` or `O_RDONLY`.
151148
O_RDWR;
152149
/// Similar to `O_DSYNC` but applies to `read`s instead.
153-
#[cfg(any(target_os = "linux", target_os = "netbsd", target_os = "openbsd"))]
150+
#[cfg(any(target_os = "linux", netbsdlike))]
154151
O_RSYNC;
155152
/// Skip search permission checks.
156153
#[cfg(target_os = "netbsd")]

src/features.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ mod os {
9999

100100
#[cfg(any(
101101
freebsdlike, // FreeBSD since 10.0 DragonFlyBSD since ???
102+
netbsdlike, // NetBSD since 6.0 OpenBSD since 5.7
102103
target_os = "illumos", // Since ???
103-
target_os = "netbsd", // Since 6.0
104-
target_os = "openbsd", // Since 5.7
105104
target_os = "redox", // Since 1-july-2020
106105
))]
107106
mod os {

src/mount/bsd.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ libc_bitflags!(
6161
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
6262
MNT_SNAPSHOT;
6363
/// Using soft updates.
64-
#[cfg(any(
65-
freebsdlike,
66-
target_os = "netbsd",
67-
target_os = "openbsd"
68-
))]
64+
#[cfg(any(freebsdlike, netbsdlike))]
6965
MNT_SOFTDEP;
7066
/// Directories with the SUID bit set chown new files to their own
7167
/// owner.

src/mount/mod.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,8 @@ mod linux;
55
#[cfg(linux_android)]
66
pub use self::linux::*;
77

8-
#[cfg(any(
9-
freebsdlike,
10-
target_os = "macos",
11-
target_os = "netbsd",
12-
target_os = "openbsd"
13-
))]
8+
#[cfg(any(freebsdlike, netbsdlike, target_os = "macos"))]
149
mod bsd;
1510

16-
#[cfg(any(
17-
freebsdlike,
18-
target_os = "macos",
19-
target_os = "netbsd",
20-
target_os = "openbsd"
21-
))]
11+
#[cfg(any(freebsdlike, netbsdlike, target_os = "macos"))]
2212
pub use self::bsd::*;

src/net/if_.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ libc_bitflags!(
7272
#[cfg(any(linux_android, target_os = "fuchsia"))]
7373
IFF_MASTER;
7474
/// transmission in progress, tx hardware queue is full
75-
#[cfg(any(target_os = "freebsd",
76-
apple_targets,
77-
target_os = "netbsd",
78-
target_os = "openbsd"))]
75+
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
7976
IFF_OACTIVE;
8077
/// Protocol code on board.
8178
#[cfg(solarish)]
@@ -85,10 +82,7 @@ libc_bitflags!(
8582
#[cfg(any(linux_android, target_os = "fuchsia"))]
8683
IFF_SLAVE;
8784
/// Can't hear own transmissions.
88-
#[cfg(any(freebsdlike,
89-
target_os = "macos",
90-
target_os = "netbsd",
91-
target_os = "openbsd"))]
85+
#[cfg(any(freebsdlike, netbsdlike, target_os = "macos"))]
9286
IFF_SIMPLEX;
9387
/// Supports multicast. (see
9488
/// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))

src/sys/aio.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ libc_enum! {
5555
/// on supported operating systems only, do it like `fdatasync`
5656
#[cfg(any(apple_targets,
5757
target_os = "linux",
58-
target_os = "netbsd",
59-
target_os = "openbsd"))]
58+
netbsdlike))]
6059
O_DSYNC
6160
}
6261
impl TryFrom<i32>

src/sys/mman.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ libc_bitflags! {
134134
/// Rename private pages to a file.
135135
///
136136
/// This was removed in FreeBSD 11 and is unused in DragonFlyBSD.
137-
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
137+
#[cfg(netbsdlike)]
138138
MAP_RENAME;
139139
/// Region may contain semaphores.
140-
#[cfg(any(freebsdlike, target_os = "netbsd", target_os = "openbsd"))]
140+
#[cfg(any(freebsdlike, netbsdlike))]
141141
MAP_HASSEMAPHORE;
142142
/// Region grows down, like a stack.
143143
#[cfg(any(linux_android, freebsdlike, target_os = "openbsd"))]

src/sys/mod.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ feature! {
6666
pub mod pthread;
6767
}
6868

69-
#[cfg(any(
70-
linux_android,
71-
freebsdlike,
72-
target_os = "macos",
73-
target_os = "netbsd",
74-
target_os = "openbsd"
75-
))]
69+
#[cfg(any(linux_android, freebsdlike, target_os = "macos", netbsdlike))]
7670
feature! {
7771
#![feature = "ptrace"]
7872
#[allow(missing_docs)]

src/sys/ptrace/mod.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,8 @@ mod linux;
66
#[cfg(linux_android)]
77
pub use self::linux::*;
88

9-
#[cfg(any(
10-
freebsdlike,
11-
target_os = "macos",
12-
target_os = "netbsd",
13-
target_os = "openbsd"
14-
))]
9+
#[cfg(any(freebsdlike, netbsdlike, target_os = "macos"))]
1510
mod bsd;
1611

17-
#[cfg(any(
18-
freebsdlike,
19-
target_os = "macos",
20-
target_os = "netbsd",
21-
target_os = "openbsd"
22-
))]
12+
#[cfg(any(freebsdlike, netbsdlike, target_os = "macos"))]
2313
pub use self::bsd::*;

src/sys/resource.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ libc_enum! {
4747
), repr(i32))]
4848
#[non_exhaustive]
4949
pub enum Resource {
50-
#[cfg(not(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
50+
#[cfg(not(any(target_os = "freebsd", netbsdlike)))]
5151
/// The maximum amount (in bytes) of virtual memory the process is
5252
/// allowed to map.
5353
RLIMIT_AS,
@@ -74,12 +74,7 @@ libc_enum! {
7474
/// this process may establish.
7575
RLIMIT_LOCKS,
7676

77-
#[cfg(any(
78-
linux_android,
79-
target_os = "freebsd",
80-
target_os = "openbsd",
81-
target_os = "netbsd"
82-
))]
77+
#[cfg(any(linux_android, target_os = "freebsd", netbsdlike))]
8378
/// The maximum size (in bytes) which a process may lock into memory
8479
/// using the mlock(2) system call.
8580
RLIMIT_MEMLOCK,
@@ -97,8 +92,7 @@ libc_enum! {
9792
#[cfg(any(
9893
linux_android,
9994
target_os = "freebsd",
100-
target_os = "netbsd",
101-
target_os = "openbsd",
95+
netbsdlike,
10296
target_os = "aix",
10397
))]
10498
/// The maximum number of simultaneous processes for this user id.
@@ -111,8 +105,7 @@ libc_enum! {
111105

112106
#[cfg(any(linux_android,
113107
target_os = "freebsd",
114-
target_os = "netbsd",
115-
target_os = "openbsd",
108+
netbsdlike,
116109
target_os = "aix",
117110
))]
118111
/// When there is memory pressure and swap is available, prioritize

src/sys/socket/addr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub enum AddressFamily {
209209
#[cfg(bsd)]
210210
Chaos = libc::AF_CHAOS,
211211
/// Novell and Xerox protocol
212-
#[cfg(any(apple_targets, target_os = "netbsd", target_os = "openbsd"))]
212+
#[cfg(any(apple_targets, netbsdlike))]
213213
Ns = libc::AF_NS,
214214
#[allow(missing_docs)] // Not documented anywhere that I can find
215215
#[cfg(bsd)]

src/sys/socket/mod.rs

+19-50
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,14 @@ libc_bitflags! {
255255
/// Set non-blocking mode on the new socket
256256
#[cfg(any(linux_android,
257257
freebsdlike,
258-
target_os = "illumos",
259-
target_os = "netbsd",
260-
target_os = "openbsd"))]
258+
netbsdlike,
259+
target_os = "illumos"))]
261260
SOCK_NONBLOCK;
262261
/// Set close-on-exec on the new descriptor
263262
#[cfg(any(linux_android,
264263
freebsdlike,
265-
target_os = "illumos",
266-
target_os = "netbsd",
267-
target_os = "openbsd"))]
264+
netbsdlike,
265+
target_os = "illumos"))]
268266
SOCK_CLOEXEC;
269267
/// Return `EPIPE` instead of raising `SIGPIPE`
270268
#[cfg(target_os = "netbsd")]
@@ -329,28 +327,23 @@ libc_bitflags! {
329327
/// [open(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html).
330328
///
331329
/// Only used in [`recvmsg`](fn.recvmsg.html) function.
332-
#[cfg(any(linux_android,
333-
freebsdlike,
334-
target_os = "netbsd",
335-
target_os = "openbsd"))]
330+
#[cfg(any(linux_android, freebsdlike, netbsdlike))]
336331
MSG_CMSG_CLOEXEC;
337332
/// Requests not to send `SIGPIPE` errors when the other end breaks the connection.
338333
/// (For more details, see [send(2)](https://linux.die.net/man/2/send)).
339334
#[cfg(any(linux_android,
340335
freebsdlike,
341336
solarish,
337+
netbsdlike,
342338
target_os = "fuchsia",
343-
target_os = "haiku",
344-
target_os = "netbsd",
345-
target_os = "openbsd"))]
339+
target_os = "haiku"))]
346340
MSG_NOSIGNAL;
347341
/// Turns on [`MSG_DONTWAIT`] after the first message has been received (only for
348342
/// `recvmmsg()`).
349343
#[cfg(any(linux_android,
344+
netbsdlike,
350345
target_os = "fuchsia",
351-
target_os = "netbsd",
352346
target_os = "freebsd",
353-
target_os = "openbsd",
354347
target_os = "solaris"))]
355348
MSG_WAITFORONE;
356349
}
@@ -755,21 +748,11 @@ pub enum ControlMessageOwned {
755748
#[cfg(feature = "net")]
756749
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
757750
Ipv6PacketInfo(libc::in6_pktinfo),
758-
#[cfg(any(
759-
target_os = "freebsd",
760-
apple_targets,
761-
target_os = "netbsd",
762-
target_os = "openbsd",
763-
))]
751+
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
764752
#[cfg(feature = "net")]
765753
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
766754
Ipv4RecvIf(libc::sockaddr_dl),
767-
#[cfg(any(
768-
target_os = "freebsd",
769-
apple_targets,
770-
target_os = "netbsd",
771-
target_os = "openbsd",
772-
))]
755+
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
773756
#[cfg(feature = "net")]
774757
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
775758
Ipv4RecvDstAddr(libc::in_addr),
@@ -948,23 +931,13 @@ impl ControlMessageOwned {
948931
let info = unsafe { ptr::read_unaligned(p as *const libc::in_pktinfo) };
949932
ControlMessageOwned::Ipv4PacketInfo(info)
950933
}
951-
#[cfg(any(
952-
target_os = "freebsd",
953-
apple_targets,
954-
target_os = "netbsd",
955-
target_os = "openbsd",
956-
))]
934+
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
957935
#[cfg(feature = "net")]
958936
(libc::IPPROTO_IP, libc::IP_RECVIF) => {
959937
let dl = unsafe { ptr::read_unaligned(p as *const libc::sockaddr_dl) };
960938
ControlMessageOwned::Ipv4RecvIf(dl)
961939
},
962-
#[cfg(any(
963-
target_os = "freebsd",
964-
apple_targets,
965-
target_os = "netbsd",
966-
target_os = "openbsd",
967-
))]
940+
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
968941
#[cfg(feature = "net")]
969942
(libc::IPPROTO_IP, libc::IP_RECVDSTADDR) => {
970943
let dl = unsafe { ptr::read_unaligned(p as *const libc::in_addr) };
@@ -1124,10 +1097,7 @@ pub enum ControlMessage<'a> {
11241097
///
11251098
/// For further information, please refer to the
11261099
/// [`ip(7)`](https://man7.org/linux/man-pages/man7/ip.7.html) man page.
1127-
#[cfg(any(target_os = "linux",
1128-
target_os = "netbsd",
1129-
target_os = "android",
1130-
apple_targets))]
1100+
#[cfg(any(linux_android, target_os = "netbsd", apple_targets))]
11311101
#[cfg(feature = "net")]
11321102
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
11331103
Ipv4PacketInfo(&'a libc::in_pktinfo),
@@ -1145,7 +1115,7 @@ pub enum ControlMessage<'a> {
11451115
Ipv6PacketInfo(&'a libc::in6_pktinfo),
11461116

11471117
/// Configure the IPv4 source address with `IP_SENDSRCADDR`.
1148-
#[cfg(any(freebsdlike, target_os = "netbsd", target_os = "openbsd"))]
1118+
#[cfg(any(freebsdlike, netbsdlike))]
11491119
#[cfg(feature = "net")]
11501120
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
11511121
Ipv4SendSrcAddr(&'a libc::in_addr),
@@ -1268,7 +1238,7 @@ impl<'a> ControlMessage<'a> {
12681238
target_os = "freebsd", apple_targets))]
12691239
#[cfg(feature = "net")]
12701240
ControlMessage::Ipv6PacketInfo(info) => info as *const _ as *const u8,
1271-
#[cfg(any(freebsdlike, target_os = "netbsd", target_os = "openbsd"))]
1241+
#[cfg(any(freebsdlike, netbsdlike))]
12721242
#[cfg(feature = "net")]
12731243
ControlMessage::Ipv4SendSrcAddr(addr) => addr as *const _ as *const u8,
12741244
#[cfg(any(linux_android, freebsdlike, apple_targets, target_os = "haiku"))]
@@ -1330,7 +1300,7 @@ impl<'a> ControlMessage<'a> {
13301300
target_os = "freebsd", apple_targets))]
13311301
#[cfg(feature = "net")]
13321302
ControlMessage::Ipv6PacketInfo(info) => mem::size_of_val(info),
1333-
#[cfg(any(freebsdlike, target_os = "netbsd", target_os = "openbsd"))]
1303+
#[cfg(any(freebsdlike, netbsdlike))]
13341304
#[cfg(feature = "net")]
13351305
ControlMessage::Ipv4SendSrcAddr(addr) => mem::size_of_val(addr),
13361306
#[cfg(any(linux_android, freebsdlike, apple_targets, target_os = "haiku"))]
@@ -1370,7 +1340,7 @@ impl<'a> ControlMessage<'a> {
13701340
target_os = "freebsd", apple_targets))]
13711341
#[cfg(feature = "net")]
13721342
ControlMessage::Ipv6PacketInfo(_) => libc::IPPROTO_IPV6,
1373-
#[cfg(any(freebsdlike, target_os = "netbsd", target_os = "openbsd"))]
1343+
#[cfg(any(freebsdlike, netbsdlike))]
13741344
#[cfg(feature = "net")]
13751345
ControlMessage::Ipv4SendSrcAddr(_) => libc::IPPROTO_IP,
13761346
#[cfg(any(linux_android, freebsdlike, apple_targets, target_os = "haiku"))]
@@ -1415,7 +1385,7 @@ impl<'a> ControlMessage<'a> {
14151385
target_os = "freebsd", apple_targets))]
14161386
#[cfg(feature = "net")]
14171387
ControlMessage::Ipv6PacketInfo(_) => libc::IPV6_PKTINFO,
1418-
#[cfg(any(freebsdlike, target_os = "netbsd", target_os = "openbsd"))]
1388+
#[cfg(any(freebsdlike, netbsdlike))]
14191389
#[cfg(feature = "net")]
14201390
ControlMessage::Ipv4SendSrcAddr(_) => libc::IP_SENDSRCADDR,
14211391
#[cfg(any(linux_android, freebsdlike, apple_targets, target_os = "haiku"))]
@@ -2183,12 +2153,11 @@ pub fn accept(sockfd: RawFd) -> Result<RawFd> {
21832153
)
21842154
),
21852155
freebsdlike,
2156+
netbsdlike,
21862157
target_os = "emscripten",
21872158
target_os = "fuchsia",
21882159
target_os = "illumos",
21892160
target_os = "linux",
2190-
target_os = "netbsd",
2191-
target_os = "openbsd"
21922161
))]
21932162
pub fn accept4(sockfd: RawFd, flags: SockFlag) -> Result<RawFd> {
21942163
let res = unsafe {

0 commit comments

Comments
 (0)