Skip to content

Commit

Permalink
Portability fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
asomers committed May 7, 2022
1 parent 6b527db commit 97b1a72
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/sys/aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ use pin_utils::unsafe_pinned;
use std::{
convert::TryFrom,
fmt::{self, Debug},
io::{IoSlice, IoSliceMut},
marker::{PhantomData, PhantomPinned},
mem,
os::unix::io::RawFd,
pin::Pin,
ptr,
thread
};
#[cfg(target_os = "freebsd")]
use std::io::{IoSlice, IoSliceMut};
use crate::sys::signal::*;
use crate::sys::time::TimeSpec;

Expand Down Expand Up @@ -1185,16 +1186,24 @@ mod t {
assert_eq!(aior.as_ref() as *const libc::aiocb,
&aior as *const AioRead as *const libc::aiocb);

let wbuf = [];
let aiow = AioWrite::new(666, 0, &wbuf, 0, sev);
assert_eq!(aiow.as_ref() as *const libc::aiocb,
&aiow as *const AioWrite as *const libc::aiocb);
}

#[cfg(target_os = "freebsd")]
#[test]
fn casting_vectored() {
let sev = SigevNotify::SigevNone;

let mut rbuf = [];
let mut rbufs = [IoSliceMut::new(&mut rbuf)];
let aiorv = AioReadv::new(666, 0, &mut rbufs[..], 0, sev);
assert_eq!(aiorv.as_ref() as *const libc::aiocb,
&aiorv as *const AioReadv as *const libc::aiocb);

let wbuf = [];
let aiow = AioWrite::new(666, 0, &wbuf, 0, sev);
assert_eq!(aiow.as_ref() as *const libc::aiocb,
&aiow as *const AioWrite as *const libc::aiocb);

let wbufs = [IoSlice::new(&wbuf)];
let aiowv = AioWritev::new(666, 0, &wbufs, 0, sev);
assert_eq!(aiowv.as_ref() as *const libc::aiocb,
Expand Down
6 changes: 5 additions & 1 deletion test/sys/test_aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use nix::errno::*;
use nix::sys::aio::*;
use nix::sys::signal::{SaFlags, SigAction, sigaction, SigevNotify, SigHandler, Signal, SigSet};
use nix::sys::time::{TimeValLike, TimeSpec};
use std::io::{IoSlice, IoSliceMut, Write, Read, Seek, SeekFrom};
use std::io::{Write, Read, Seek, SeekFrom};
use std::ops::Deref;
use std::os::unix::io::AsRawFd;
use std::pin::Pin;
Expand Down Expand Up @@ -200,8 +200,10 @@ mod aio_read {
}
}

#[cfg(target_os = "freebsd")]
mod aio_readv {
use super::*;
use std::io::IoSliceMut;

#[test]
fn test_accessors() {
Expand Down Expand Up @@ -378,8 +380,10 @@ mod aio_write {
}
}

#[cfg(target_os = "freebsd")]
mod aio_writev {
use super::*;
use std::io::IoSlice;

#[test]
fn test_accessors() {
Expand Down

0 comments on commit 97b1a72

Please sign in to comment.