Skip to content

Commit

Permalink
try pass compile in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
loongs-zhang committed Feb 8, 2024
1 parent 294f87d commit a30e577
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions monoio/src/driver/op/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ impl OpAble for Open {
fn legacy_call(&mut self) -> io::Result<u32> {
syscall!(
CreateFileW(
self.path.as_c_str().as_ptr(),
self.path.as_c_str().as_ptr().cast(),
self.opts.access_mode()?,
self.opts.share_mode,
self.opts.security_attributes,
self.opts.creation_mode()?,
self.opts.get_flags_and_attributes(),
std::ptr::null_mut(),
0,
),
PartialEq::eq,
INVALID_HANDLE_VALUE
Expand Down
19 changes: 10 additions & 9 deletions monoio/src/driver/op/recv.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
use std::{
io,
mem::{transmute, MaybeUninit},
net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6},
};
use std::{io, net::SocketAddr};

#[cfg(all(target_os = "linux", feature = "iouring"))]
use io_uring::{opcode, types};
#[cfg(unix)]
use libc::{socklen_t, AF_INET, AF_INET6};
#[cfg(all(windows, any(feature = "legacy", feature = "poll-io")))]
use {
crate::syscall,
Expand All @@ -16,11 +10,18 @@ use {
};
#[cfg(all(unix, any(feature = "legacy", feature = "poll-io")))]
use {crate::syscall_u32, std::os::unix::prelude::AsRawFd};
#[cfg(unix)]
use {
libc::{socklen_t, AF_INET, AF_INET6},
net::unix::SocketAddr as UnixSocketAddr,
std::mem::{transmute, MaybeUninit},
std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6},
};

use super::{super::shared_fd::SharedFd, Op, OpAble};
#[cfg(any(feature = "legacy", feature = "poll-io"))]
use crate::driver::ready::Direction;
use crate::{buf::IoBufMut, net::unix::SocketAddr as UnixSocketAddr, BufResult};
use crate::{buf::IoBufMut, BufResult};

pub(crate) struct Recv<T> {
/// Holds a strong ref to the FD, preventing the file from being closed
Expand Down Expand Up @@ -293,7 +294,7 @@ impl<T: IoBufMut> Op<RecvMsgUnix<T>> {
unimplemented!()
}

pub(crate) async fn wait(self) -> BufResult<(usize, UnixSocketAddr), T> {
pub(crate) async fn wait(self) -> BufResult<(usize, SocketAddr), T> {
unimplemented!()
}
}
Expand Down
7 changes: 4 additions & 3 deletions monoio/src/driver/op/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::{io, net::SocketAddr};

#[cfg(all(target_os = "linux", feature = "iouring"))]
use io_uring::{opcode, types};
use socket2::SockAddr;
#[cfg(unix)]
use {crate::net::unix::SocketAddr as UnixSocketAddr, socket2::SockAddr};
#[cfg(all(windows, any(feature = "legacy", feature = "poll-io")))]
use {
crate::syscall, std::os::windows::io::AsRawSocket,
Expand All @@ -14,7 +15,7 @@ use {crate::syscall_u32, std::os::unix::prelude::AsRawFd};
use super::{super::shared_fd::SharedFd, Op, OpAble};
#[cfg(any(feature = "legacy", feature = "poll-io"))]
use crate::driver::ready::Direction;
use crate::{buf::IoBuf, net::unix::SocketAddr as UnixSocketAddr, BufResult};
use crate::{buf::IoBuf, BufResult};

pub(crate) struct Send<T> {
/// Holds a strong ref to the FD, preventing the file from being closed
Expand Down Expand Up @@ -276,7 +277,7 @@ impl<T: IoBuf> Op<SendMsgUnix<T>> {
pub(crate) fn send_msg_unix(
fd: SharedFd,
buf: T,
socket_addr: Option<UnixSocketAddr>,
socket_addr: Option<SocketAddr>,
) -> io::Result<Self> {
unimplemented!()
}
Expand Down
2 changes: 1 addition & 1 deletion monoio/src/driver/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ macro_rules! syscall {
if $err_test(&res, &$err_value) {
Err(io::Error::last_os_error())
} else {
Ok(res)
Ok(res.try_into().unwrap())
}
}};
}
Expand Down
7 changes: 3 additions & 4 deletions monoio/src/io/util/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

use std::io;

use crate::{
io::{AsyncReadRent, AsyncWriteRent, AsyncWriteRentExt},
net::unix::new_pipe,
};
use crate::io::{AsyncReadRent, AsyncWriteRent, AsyncWriteRentExt};
#[cfg(unix)]
use crate::net::unix::new_pipe;

const BUF_SIZE: usize = 4 * 1024;

Expand Down
2 changes: 1 addition & 1 deletion monoio/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub(crate) fn new_socket(
socket.set_nonblocking(true).map_err(|e| {
// If either of the `ioctlsocket` calls failed, ensure the socket is
// closed and return the error.
windows_sys::Win32::Networking::WinSock::closesocket(raw_socket as _);
unsafe { windows_sys::Win32::Networking::WinSock::closesocket(raw_socket as _) };
e
})?;
Ok(raw_socket)
Expand Down

0 comments on commit a30e577

Please sign in to comment.