Skip to content

Commit

Permalink
Add freebsd/netbsd back, having added libc support
Browse files Browse the repository at this point in the history
This reverts commit ca4611d.
  • Loading branch information
dholroyd committed Apr 1, 2019
1 parent ca4611d commit c709020
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/sys/socket/mod.rs
Expand Up @@ -11,10 +11,14 @@ use sys::time::TimeVal;
use sys::uio::IoVec;
#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
))]
use sys::time::TimeSpec;
#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
))]
use std::marker::PhantomData;

Expand Down Expand Up @@ -1345,13 +1349,17 @@ pub fn shutdown(df: RawFd, how: Shutdown) -> Result<()> {

#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
))]
#[repr(C)]
#[allow(missing_debug_implementations)]
pub struct SendMMsgHdr<'a>(libc::mmsghdr, PhantomData<&'a ()>);

#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
))]
impl<'a> SendMMsgHdr<'a> {
pub fn new(iov: &mut[IoVec<&'a mut [u8]>],
Expand Down Expand Up @@ -1436,13 +1444,17 @@ impl<'a> SendMMsgHdr<'a> {

#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
))]
#[repr(C)]
#[allow(missing_debug_implementations)]
pub struct RecvMMsgHdr<'a>(libc::mmsghdr, PhantomData<&'a ()>);

#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
))]
impl<'a> RecvMMsgHdr<'a> {
pub fn new<T>(iov: &mut[IoVec<&'a mut [u8]>],
Expand Down Expand Up @@ -1505,6 +1517,8 @@ impl<'a> RecvMMsgHdr<'a> {
/// Receive multiple messages from a socket using a single system call.
#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
))]
pub fn recvmmsg(fd: RawFd, msgvec: &mut[RecvMMsgHdr],
flags: MsgFlags,
Expand All @@ -1528,6 +1542,8 @@ pub fn recvmmsg(fd: RawFd, msgvec: &mut[RecvMMsgHdr],
/// Transmit multiple messages on a socket using a single system call.
#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
))]
pub fn sendmmsg(fd: RawFd, msgvec: &mut[SendMMsgHdr]) -> Result<usize> {
let ret = unsafe {
Expand Down
2 changes: 2 additions & 0 deletions test/sys/test_socket.rs
Expand Up @@ -962,6 +962,8 @@ pub fn test_recv_ipv6pktinfo() {

#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "netbsd",
))]
#[test]
pub fn test_mmsg() {
Expand Down

0 comments on commit c709020

Please sign in to comment.