From df44b5dfd37362fc65191108d7c639231d535919 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 6 May 2022 22:56:59 -0600 Subject: [PATCH] Portability fixes --- src/sys/aio.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/sys/aio.rs b/src/sys/aio.rs index 6d2a26d367..3e7663d4e3 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -30,7 +30,6 @@ use pin_utils::unsafe_pinned; use std::{ convert::TryFrom, fmt::{self, Debug}, - io::{IoSlice, IoSliceMut}, marker::{PhantomData, PhantomPinned}, mem, os::unix::io::RawFd, @@ -38,6 +37,8 @@ use std::{ ptr, thread }; +#[cfg(target_os = "freebsd")] +use std::io::{IoSlice, IoSliceMut}; use crate::sys::signal::*; use crate::sys::time::TimeSpec; @@ -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,