Skip to content

Commit 97b1a72

Browse files
committed
Portability fixes
1 parent 6b527db commit 97b1a72

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/sys/aio.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ use pin_utils::unsafe_pinned;
3030
use std::{
3131
convert::TryFrom,
3232
fmt::{self, Debug},
33-
io::{IoSlice, IoSliceMut},
3433
marker::{PhantomData, PhantomPinned},
3534
mem,
3635
os::unix::io::RawFd,
3736
pin::Pin,
3837
ptr,
3938
thread
4039
};
40+
#[cfg(target_os = "freebsd")]
41+
use std::io::{IoSlice, IoSliceMut};
4142
use crate::sys::signal::*;
4243
use crate::sys::time::TimeSpec;
4344

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

1189+
let wbuf = [];
1190+
let aiow = AioWrite::new(666, 0, &wbuf, 0, sev);
1191+
assert_eq!(aiow.as_ref() as *const libc::aiocb,
1192+
&aiow as *const AioWrite as *const libc::aiocb);
1193+
}
1194+
1195+
#[cfg(target_os = "freebsd")]
1196+
#[test]
1197+
fn casting_vectored() {
1198+
let sev = SigevNotify::SigevNone;
1199+
1200+
let mut rbuf = [];
11881201
let mut rbufs = [IoSliceMut::new(&mut rbuf)];
11891202
let aiorv = AioReadv::new(666, 0, &mut rbufs[..], 0, sev);
11901203
assert_eq!(aiorv.as_ref() as *const libc::aiocb,
11911204
&aiorv as *const AioReadv as *const libc::aiocb);
11921205

11931206
let wbuf = [];
1194-
let aiow = AioWrite::new(666, 0, &wbuf, 0, sev);
1195-
assert_eq!(aiow.as_ref() as *const libc::aiocb,
1196-
&aiow as *const AioWrite as *const libc::aiocb);
1197-
11981207
let wbufs = [IoSlice::new(&wbuf)];
11991208
let aiowv = AioWritev::new(666, 0, &wbufs, 0, sev);
12001209
assert_eq!(aiowv.as_ref() as *const libc::aiocb,

test/sys/test_aio.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use nix::errno::*;
33
use nix::sys::aio::*;
44
use nix::sys::signal::{SaFlags, SigAction, sigaction, SigevNotify, SigHandler, Signal, SigSet};
55
use nix::sys::time::{TimeValLike, TimeSpec};
6-
use std::io::{IoSlice, IoSliceMut, Write, Read, Seek, SeekFrom};
6+
use std::io::{Write, Read, Seek, SeekFrom};
77
use std::ops::Deref;
88
use std::os::unix::io::AsRawFd;
99
use std::pin::Pin;
@@ -200,8 +200,10 @@ mod aio_read {
200200
}
201201
}
202202

203+
#[cfg(target_os = "freebsd")]
203204
mod aio_readv {
204205
use super::*;
206+
use std::io::IoSliceMut;
205207

206208
#[test]
207209
fn test_accessors() {
@@ -378,8 +380,10 @@ mod aio_write {
378380
}
379381
}
380382

383+
#[cfg(target_os = "freebsd")]
381384
mod aio_writev {
382385
use super::*;
386+
use std::io::IoSlice;
383387

384388
#[test]
385389
fn test_accessors() {

0 commit comments

Comments
 (0)