Skip to content

Commit 9682683

Browse files
Platform flags
1 parent 07d3266 commit 9682683

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

apps/src/recvfrom.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use dgram::RecvData;
22

3+
#[cfg(target_os = "linux")]
34
use std::io;
45

56
/// For Linux, try to detect if GRO is available. If it is, the
@@ -28,7 +29,7 @@ pub fn detect_gro(socket: &mio::net::UdpSocket) -> bool {
2829
}
2930

3031
#[cfg(not(target_os = "linux"))]
31-
pub fn detect_gro(socket: &mio::net::UdpSocket, _segment_size: usize) -> bool {
32+
pub fn detect_gro(_socket: &mio::net::UdpSocket) -> bool {
3233
false
3334
}
3435

@@ -52,7 +53,7 @@ pub fn recv_from(
5253
}
5354

5455
#[cfg(not(target_os = "linux"))]
55-
fn recv_from(
56+
pub fn recv_from(
5657
socket: &mio::net::UdpSocket, buf: &mut [u8],
5758
) -> std::io::Result<RecvData> {
5859
match socket.recv_from(buf) {

dgram/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
pub mod socket_setup;
2+
#[cfg(target_os = "linux")]
23
pub mod sync;
34
mod syscalls;
45
#[cfg(feature = "async")]
56
pub mod tokio;
67

78
use std::net::SocketAddr;
9+
#[cfg(target_os = "linux")]
810
use std::time::Instant;
911
use std::time::SystemTime;
1012

@@ -13,7 +15,6 @@ use libc::in_pktinfo;
1315
use libc::sockaddr_in;
1416
use libc::sockaddr_in6;
1517
use nix::sys::socket::ControlMessageOwned;
16-
use nix::sys::socket::MsgFlags;
1718

1819
/// Settings for handling control messages when sending data.
1920
#[cfg(target_os = "linux")]
@@ -45,6 +46,7 @@ pub struct RecvMsgSettings<'c> {
4546
pub cmsg_space: &'c mut Vec<u8>,
4647
}
4748

49+
#[cfg(target_os = "linux")]
4850
impl<'c> RecvMsgSettings<'c> {
4951
// Convenience to avoid forcing a specific version of nix
5052
pub fn new(store_cmsgs: bool, cmsg_space: &'c mut Vec<u8>) -> Self {

dgram/src/syscalls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
use std::time::SystemTime;
2-
31
#[cfg(target_os = "linux")]
42
mod linux {
53
pub(super) use super::super::linux_imports::*;
64
pub(super) use std::os::fd::AsFd;
75
pub(super) use std::time::Instant;
6+
pub(super) use std::time::SystemTime;
87

98
pub(crate) type SyscallResult<T> = std::result::Result<T, Errno>;
109

@@ -17,6 +16,7 @@ mod linux {
1716
#[cfg(target_os = "linux")]
1817
use linux::*;
1918

19+
#[cfg(target_os = "linux")]
2020
fn raw_send_to(
2121
fd: &impl AsFd, send_buf: &[u8], cmsgs: &[ControlMessage],
2222
msg_flags: MsgFlags, client_addr: Option<SockaddrStorage>,
@@ -27,7 +27,7 @@ fn raw_send_to(
2727
sendmsg(
2828
borrowed.as_raw_fd(),
2929
&iov,
30-
&cmsgs,
30+
cmsgs,
3131
msg_flags,
3232
client_addr.as_ref(),
3333
)

0 commit comments

Comments
 (0)