Skip to content

Commit 97341da

Browse files
committed
Enable more flags for FreeBSD
1 parent adc34ee commit 97341da

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,11 @@ fd_operation!(
470470
pub struct Allocate(sys::fs::AllocateOp) -> io::Result<()>;
471471
);
472472

473+
#[cfg(any(target_os = "android", target_os = "linux"))]
473474
impl<'fd> Stat<'fd> {
474475
/// Set which field(s) of the metadata the kernel should fill.
475476
///
476477
/// Defaults to filling some basic fields.
477-
#[cfg(any(target_os = "android", target_os = "linux"))]
478478
pub fn only(mut self, mask: MetadataInterest) -> Self {
479479
if let Some(args) = self.state.args_mut() {
480480
*args = mask;

src/net.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ new_flag!(
9292
/// User Datagram Protocol.
9393
UDP = libc::IPPROTO_UDP,
9494
/// Datagram Congestion Control Protocol.
95-
#[cfg(any(target_os = "android", target_os = "linux"))]
95+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
9696
DCCP = libc::IPPROTO_DCCP,
9797
/// Stream Control Transport Protocol.
9898
SCTP = libc::IPPROTO_SCTP,
9999
/// UDP-Lite.
100-
#[cfg(any(target_os = "android", target_os = "linux"))]
100+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
101101
UDPLITE = libc::IPPROTO_UDPLITE,
102102
/// Raw IP packets.
103103
RAW = libc::IPPROTO_RAW,
@@ -411,7 +411,7 @@ new_flag!(
411411
pub struct RecvFlag(u32) impl BitOr {
412412
/// Set the close-on-exec flag for the file descriptor received via a
413413
/// UNIX domain file descriptor using the `SCM_RIGHTS` operation.
414-
#[cfg(any(target_os = "android", target_os = "linux"))]
414+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
415415
CMSG_CLOEXEC = libc::MSG_CMSG_CLOEXEC,
416416
/// This flag specifies that queued errors should be received from the
417417
/// socket error queue.
@@ -539,7 +539,7 @@ new_flag!(
539539
#[cfg(any(target_os = "android", target_os = "linux"))]
540540
DETACH_BPF = libc::SO_DETACH_BPF,
541541
/// Domain.
542-
#[cfg(any(target_os = "android", target_os = "linux"))]
542+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
543543
DOMAIN = libc::SO_DOMAIN,
544544
/// Get and clear the pending socket error.
545545
ERROR = libc::SO_ERROR,
@@ -578,7 +578,7 @@ new_flag!(
578578
#[cfg(any(target_os = "android", target_os = "linux"))]
579579
PRIORITY = libc::SO_PRIORITY,
580580
/// Retrieves the socket protocol.
581-
#[cfg(any(target_os = "android", target_os = "linux"))]
581+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
582582
PROTOCOL = libc::SO_PROTOCOL,
583583
/// Maximum receive buffer in bytes.
584584
RECV_BUF = libc::SO_RCVBUF,
@@ -689,7 +689,7 @@ new_flag!(
689689
#[cfg(any(target_os = "android", target_os = "linux"))]
690690
RECV_OPTS = libc::IP_RECVOPTS,
691691
/// Enables the `IP_ORIGDSTADDR` ancillary message in `recvmsg(2)`.
692-
#[cfg(any(target_os = "android", target_os = "linux"))]
692+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
693693
RECV_ORIG_DST_ADDR = libc::IP_RECVORIGDSTADDR,
694694
/// Enable passing of `IP_TOS` in ancillary message with incoming
695695
/// packets.
@@ -785,7 +785,7 @@ new_flag!(
785785
#[doc = man_link!(tcp(7))]
786786
pub struct TcpOpt(u32) {
787787
/// Set the TCP congestion control algorithm to be used.
788-
#[cfg(any(target_os = "android", target_os = "linux"))]
788+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
789789
CONGESTION = libc::TCP_CONGESTION,
790790
/// Don't send out partial frames.
791791
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -795,14 +795,14 @@ new_flag!(
795795
#[cfg(any(target_os = "android", target_os = "linux"))]
796796
DEFER_ACCEPT = libc::TCP_DEFER_ACCEPT,
797797
/// Collect information about this socket.
798-
#[cfg(any(target_os = "android", target_os = "linux"))]
798+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
799799
INFO = libc::TCP_INFO,
800800
/// The maximum number of keepalive probes TCP should send before
801801
/// dropping the connection.
802802
KEEP_CNT = libc::TCP_KEEPCNT,
803803
/// The time (in seconds) the connection needs to remain idle before TCP
804804
/// starts sending keepalive probes.
805-
#[cfg(any(target_os = "android", target_os = "linux"))]
805+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
806806
KEEP_IDLE = libc::TCP_KEEPIDLE,
807807
/// The time (in seconds) between individual keepalive probes.
808808
KEEP_INTVL = libc::TCP_KEEPINTVL,
@@ -1599,7 +1599,7 @@ impl private::SocketAddress for unix::net::SocketAddr {
15991599
fn into_storage(self) -> Self::Storage {
16001600
let mut storage = libc::sockaddr_un {
16011601
// A number of OS have `sin6_len`, but we don't use it.
1602-
#[cfg(not(any(target_os = "android", target_os = "linux")))]
1602+
#[cfg(not(any(target_os = "android", target_os = "freebsd", target_os = "linux")))]
16031603
sun_len: 0,
16041604
sun_family: libc::AF_UNIX as libc::sa_family_t,
16051605
// SAFETY: all zero is valid for `sockaddr_un`.

src/net/option.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,32 @@ new_option! {
189189
target_os = "netbsd"
190190
))]
191191
new_option! {
192+
/// Domain.
193+
#[doc(alias = "SO_DOMAIN")]
194+
pub Domain {
195+
type Storage = libc::c_int;
196+
const LEVEL = Level::SOCKET;
197+
const OPT = SocketOpt::DOMAIN;
198+
199+
unsafe fn init(storage: MaybeUninit<Self::Storage>, length: u32) -> net::Domain {
200+
assert!(length == size_of::<Self::Storage>() as u32);
201+
unsafe { net::Domain(storage.assume_init()) }
202+
}
203+
}
204+
205+
/// Retrieves the socket protocol.
206+
#[doc(alias = "SO_PROTOCOL")]
207+
pub Protocol {
208+
type Storage = u32;
209+
const LEVEL = Level::SOCKET;
210+
const OPT = SocketOpt::PROTOCOL;
211+
212+
unsafe fn init(storage: MaybeUninit<Self::Storage>, length: u32) -> net::Protocol {
213+
assert!(length == size_of::<Self::Storage>() as u32);
214+
unsafe { net::Protocol(storage.assume_init()) }
215+
}
216+
}
217+
192218
/// Returns a value indicating whether or not this socket has been
193219
/// marked to accept connections with `listen(2)`.
194220
#[doc(alias = "SO_ACCEPTCONN")]
@@ -206,19 +232,6 @@ new_option! {
206232

207233
#[cfg(any(target_os = "android", target_os = "linux"))]
208234
new_option! {
209-
/// Domain.
210-
#[doc(alias = "SO_DOMAIN")]
211-
pub Domain {
212-
type Storage = libc::c_int;
213-
const LEVEL = Level::SOCKET;
214-
const OPT = SocketOpt::DOMAIN;
215-
216-
unsafe fn init(storage: MaybeUninit<Self::Storage>, length: u32) -> net::Domain {
217-
assert!(length == size_of::<Self::Storage>() as u32);
218-
unsafe { net::Domain(storage.assume_init()) }
219-
}
220-
}
221-
222235
/// CPU affinity.
223236
#[doc(alias = "SO_INCOMING_CPU")]
224237
pub IncomingCpu {
@@ -236,19 +249,6 @@ new_option! {
236249
value.cast_signed()
237250
}
238251
}
239-
240-
/// Retrieves the socket protocol.
241-
#[doc(alias = "SO_PROTOCOL")]
242-
pub Protocol {
243-
type Storage = u32;
244-
const LEVEL = Level::SOCKET;
245-
const OPT = SocketOpt::PROTOCOL;
246-
247-
unsafe fn init(storage: MaybeUninit<Self::Storage>, length: u32) -> net::Protocol {
248-
assert!(length == size_of::<Self::Storage>() as u32);
249-
unsafe { net::Protocol(storage.assume_init()) }
250-
}
251-
}
252252
}
253253

254254
macro_rules! new_option {

0 commit comments

Comments
 (0)