upgrade to windows-sys 0.59.0

This commit is contained in:
Ashwin Naren
2025-03-05 10:36:04 -08:00
committed by Noa
parent 05cb8c0b73
commit 33940726a8
10 changed files with 56 additions and 54 deletions

View File

@@ -125,6 +125,7 @@ features = [
"Win32_NetworkManagement_Ndis",
"Win32_Security_Cryptography",
"Win32_System_Environment",
"Win32_System_IO"
]
[target.'cfg(target_os = "macos")'.dependencies]

View File

@@ -24,13 +24,17 @@ mod _overlapped {
use windows_sys::Win32::{
Foundation::{
ERROR_IO_PENDING, ERROR_NETNAME_DELETED, ERROR_OPERATION_ABORTED, ERROR_PIPE_BUSY,
ERROR_PORT_UNREACHABLE, ERROR_SEM_TIMEOUT, INVALID_HANDLE_VALUE,
ERROR_PORT_UNREACHABLE, ERROR_SEM_TIMEOUT,
},
Networking::WinSock::{
SO_UPDATE_ACCEPT_CONTEXT, SO_UPDATE_CONNECT_CONTEXT, TF_REUSE_SOCKET,
},
System::Threading::INFINITE,
};
#[pyattr(once)]
fn INVALID_HANDLE_VALUE(_vm: &VirtualMachine) -> isize {
windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE as isize
}
#[pyattr]
const NULL: isize = 0;
@@ -126,7 +130,7 @@ mod _overlapped {
fn mark_as_completed(ov: &mut OVERLAPPED) {
ov.Internal = 0;
if ov.hEvent != 0 {
if ov.hEvent != std::ptr::null_mut() {
unsafe { windows_sys::Win32::System::Threading::SetEvent(ov.hEvent) };
}
}
@@ -164,7 +168,7 @@ mod _overlapped {
fn WSARecv_inner(
inner: &mut OverlappedInner,
handle: HANDLE,
handle: isize,
buf: &[u8],
mut flags: u32,
vm: &VirtualMachine,
@@ -209,7 +213,7 @@ mod _overlapped {
#[pymethod]
fn WSARecv(
zelf: &Py<Self>,
handle: HANDLE,
handle: isize,
size: u32,
flags: u32,
vm: &VirtualMachine,
@@ -224,9 +228,9 @@ mod _overlapped {
let buf = vec![0u8; std::cmp::max(size, 1) as usize];
let buf = vm.ctx.new_bytes(buf);
inner.handle = handle;
inner.handle = handle as _;
let r = Self::WSARecv_inner(&mut inner, handle, buf.as_bytes(), flags, vm);
let r = Self::WSARecv_inner(&mut inner, handle as _, buf.as_bytes(), flags, vm);
inner.data = OverlappedData::Read(buf);
r
}
@@ -256,30 +260,30 @@ mod _overlapped {
}
impl Constructor for Overlapped {
type Args = (HANDLE,);
type Args = (isize,);
fn py_new(cls: PyTypeRef, (mut event,): Self::Args, vm: &VirtualMachine) -> PyResult {
if event == INVALID_HANDLE_VALUE {
if event as isize == INVALID_HANDLE_VALUE as isize {
event = unsafe {
windows_sys::Win32::System::Threading::CreateEventA(
std::ptr::null(),
Foundation::TRUE,
Foundation::FALSE,
std::ptr::null(),
)
) as isize
};
if event == NULL {
if event as isize == NULL {
return Err(errno_err(vm));
}
}
let mut overlapped: OVERLAPPED = unsafe { std::mem::zeroed() };
if event != NULL {
overlapped.hEvent = event;
overlapped.hEvent = event as _;
}
let inner = OverlappedInner {
overlapped,
handle: NULL,
handle: NULL as _,
error: 0,
data: OverlappedData::None,
};
@@ -292,29 +296,29 @@ mod _overlapped {
#[pyfunction]
fn CreateIoCompletionPort(
handle: HANDLE,
port: HANDLE,
handle: isize,
port: isize,
key: usize,
concurrency: u32,
vm: &VirtualMachine,
) -> PyResult<HANDLE> {
) -> PyResult<isize> {
let r = unsafe {
windows_sys::Win32::System::IO::CreateIoCompletionPort(handle, port, key, concurrency)
windows_sys::Win32::System::IO::CreateIoCompletionPort(handle as _, port as _, key, concurrency) as isize
};
if r == 0 {
if r as usize == 0 {
return Err(errno_err(vm));
}
Ok(r)
}
#[pyfunction]
fn GetQueuedCompletionStatus(port: HANDLE, msecs: u32, vm: &VirtualMachine) -> PyResult {
fn GetQueuedCompletionStatus(port: isize, msecs: u32, vm: &VirtualMachine) -> PyResult {
let mut bytes_transferred = 0;
let mut completion_key = 0;
let mut overlapped: *mut OVERLAPPED = std::ptr::null_mut();
let ret = unsafe {
windows_sys::Win32::System::IO::GetQueuedCompletionStatus(
port,
port as _,
&mut bytes_transferred,
&mut completion_key,
&mut overlapped,

View File

@@ -36,11 +36,7 @@ mod _socket {
#[cfg(windows)]
mod c {
pub use windows_sys::Win32::NetworkManagement::IpHelper::{if_indextoname, if_nametoindex};
pub const INADDR_ANY: u32 = 0x00000000;
pub const INADDR_LOOPBACK: u32 = 0x7f000001;
pub const INADDR_BROADCAST: u32 = 0xffffffff;
pub const INADDR_NONE: u32 = 0xffffffff;
pub use windows_sys::Win32::Networking::WinSock::{INADDR_ANY, INADDR_LOOPBACK, INADDR_BROADCAST, INADDR_NONE};
pub use windows_sys::Win32::Networking::WinSock::{
AF_APPLETALK, AF_DECnet, AF_IPX, AF_LINK, AI_ADDRCONFIG, AI_ALL, AI_CANONNAME,
@@ -2135,7 +2131,7 @@ mod _socket {
#[cfg(all(unix, not(target_os = "redox")))]
type IfIndex = c::c_uint;
#[cfg(windows)]
type IfIndex = u32; // NET_IFINDEX but windows-sys 0.59 doesn't have it
type IfIndex = u32; // NET_IFINDEX but windows-sys 0.59 doesn't have it
#[cfg(not(target_os = "redox"))]
#[pyfunction]