forked from Rust-related/RustPython
upgrade to windows-sys 0.59.0
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -2023,7 +2023,7 @@ dependencies = [
|
||||
"siphasher 0.3.11",
|
||||
"volatile",
|
||||
"widestring",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2252,7 +2252,7 @@ dependencies = [
|
||||
"unicode_names2",
|
||||
"uuid",
|
||||
"widestring",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
@@ -2332,7 +2332,7 @@ dependencies = [
|
||||
"which",
|
||||
"widestring",
|
||||
"windows",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
"winreg",
|
||||
]
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ thiserror = "2.0"
|
||||
thread_local = "1.1.8"
|
||||
unicode_names2 = "1.3.0"
|
||||
widestring = "1.1.0"
|
||||
windows-sys = "0.52.0"
|
||||
windows-sys = "0.59.0"
|
||||
wasm-bindgen = "0.2.100"
|
||||
|
||||
# Lints
|
||||
|
||||
@@ -116,7 +116,7 @@ pub mod windows {
|
||||
let h = h?;
|
||||
// reset stat?
|
||||
|
||||
let file_type = unsafe { GetFileType(h) };
|
||||
let file_type = unsafe { GetFileType(h as _) };
|
||||
if file_type == FILE_TYPE_UNKNOWN {
|
||||
return Err(std::io::Error::last_os_error());
|
||||
}
|
||||
@@ -138,10 +138,10 @@ pub mod windows {
|
||||
let mut basic_info: FILE_BASIC_INFO = unsafe { std::mem::zeroed() };
|
||||
let mut id_info: FILE_ID_INFO = unsafe { std::mem::zeroed() };
|
||||
|
||||
if unsafe { GetFileInformationByHandle(h, &mut info) } == 0
|
||||
if unsafe { GetFileInformationByHandle(h as _, &mut info) } == 0
|
||||
|| unsafe {
|
||||
GetFileInformationByHandleEx(
|
||||
h,
|
||||
h as _,
|
||||
FileBasicInfo,
|
||||
&mut basic_info as *mut _ as *mut _,
|
||||
std::mem::size_of_val(&basic_info) as u32,
|
||||
@@ -153,7 +153,7 @@ pub mod windows {
|
||||
|
||||
let p_id_info = if unsafe {
|
||||
GetFileInformationByHandleEx(
|
||||
h,
|
||||
h as _,
|
||||
FileIdInfo,
|
||||
&mut id_info as *mut _ as *mut _,
|
||||
std::mem::size_of_val(&id_info) as u32,
|
||||
@@ -320,7 +320,7 @@ pub mod windows {
|
||||
.get_or_init(|| {
|
||||
let library_name = OsString::from("api-ms-win-core-file-l2-1-4").to_wide_with_nul();
|
||||
let module = unsafe { LoadLibraryW(library_name.as_ptr()) };
|
||||
if module == 0 {
|
||||
if module == std::ptr::null_mut() {
|
||||
return None;
|
||||
}
|
||||
let name = CString::new("GetFileInformationByName").unwrap();
|
||||
|
||||
@@ -125,6 +125,7 @@ features = [
|
||||
"Win32_NetworkManagement_Ndis",
|
||||
"Win32_Security_Cryptography",
|
||||
"Win32_System_Environment",
|
||||
"Win32_System_IO"
|
||||
]
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -144,6 +144,7 @@ features = [
|
||||
"Win32_System_SystemInformation",
|
||||
"Win32_System_SystemServices",
|
||||
"Win32_System_Threading",
|
||||
"Win32_System_WindowsProgramming",
|
||||
"Win32_UI_Shell",
|
||||
"Win32_UI_WindowsAndMessaging",
|
||||
]
|
||||
|
||||
@@ -150,7 +150,7 @@ pub(crate) mod module {
|
||||
}
|
||||
|
||||
let h = unsafe { Threading::OpenProcess(Threading::PROCESS_ALL_ACCESS, 0, pid) };
|
||||
if h == 0 {
|
||||
if h == std::ptr::null_mut() {
|
||||
return Err(errno_err(vm));
|
||||
}
|
||||
let ret = unsafe { Threading::TerminateProcess(h, sig) };
|
||||
@@ -172,7 +172,7 @@ pub(crate) mod module {
|
||||
_ => return Err(vm.new_value_error("bad file descriptor".to_owned())),
|
||||
};
|
||||
let h = unsafe { Console::GetStdHandle(stdhandle) };
|
||||
if h == 0 {
|
||||
if h == std::ptr::null_mut() {
|
||||
return Err(vm.new_os_error("handle cannot be retrieved".to_owned()));
|
||||
}
|
||||
if h == INVALID_HANDLE_VALUE {
|
||||
|
||||
@@ -79,7 +79,7 @@ mod _winapi {
|
||||
|
||||
#[pyfunction]
|
||||
fn CloseHandle(handle: HANDLE) -> WindowsSysResult<BOOL> {
|
||||
WindowsSysResult(unsafe { windows_sys::Win32::Foundation::CloseHandle(handle.0) })
|
||||
WindowsSysResult(unsafe { windows_sys::Win32::Foundation::CloseHandle(handle.0 as _) })
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
@@ -99,8 +99,8 @@ mod _winapi {
|
||||
let mut read = std::mem::MaybeUninit::<isize>::uninit();
|
||||
let mut write = std::mem::MaybeUninit::<isize>::uninit();
|
||||
WindowsSysResult(windows_sys::Win32::System::Pipes::CreatePipe(
|
||||
read.as_mut_ptr(),
|
||||
write.as_mut_ptr(),
|
||||
read.as_mut_ptr() as _,
|
||||
write.as_mut_ptr() as _,
|
||||
std::ptr::null(),
|
||||
size,
|
||||
))
|
||||
@@ -122,10 +122,10 @@ mod _winapi {
|
||||
let target = unsafe {
|
||||
let mut target = std::mem::MaybeUninit::<isize>::uninit();
|
||||
WindowsSysResult(windows_sys::Win32::Foundation::DuplicateHandle(
|
||||
src_process.0,
|
||||
src.0,
|
||||
target_process.0,
|
||||
target.as_mut_ptr(),
|
||||
src_process.0 as _,
|
||||
src.0 as _,
|
||||
target_process.0 as _,
|
||||
target.as_mut_ptr() as _,
|
||||
access,
|
||||
inherit,
|
||||
options.unwrap_or(0),
|
||||
@@ -151,7 +151,7 @@ mod _winapi {
|
||||
h: HANDLE,
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult<windows_sys::Win32::Storage::FileSystem::FILE_TYPE> {
|
||||
let file_type = unsafe { windows_sys::Win32::Storage::FileSystem::GetFileType(h.0) };
|
||||
let file_type = unsafe { windows_sys::Win32::Storage::FileSystem::GetFileType(h.0 as _) };
|
||||
if file_type == 0 && unsafe { windows_sys::Win32::Foundation::GetLastError() } != 0 {
|
||||
Err(errno_err(vm))
|
||||
} else {
|
||||
@@ -274,8 +274,8 @@ mod _winapi {
|
||||
};
|
||||
|
||||
Ok((
|
||||
HANDLE(procinfo.hProcess),
|
||||
HANDLE(procinfo.hThread),
|
||||
HANDLE(procinfo.hProcess as _),
|
||||
HANDLE(procinfo.hThread as _),
|
||||
procinfo.dwProcessId,
|
||||
procinfo.dwThreadId,
|
||||
))
|
||||
@@ -286,13 +286,13 @@ mod _winapi {
|
||||
desired_access: u32,
|
||||
inherit_handle: bool,
|
||||
process_id: u32,
|
||||
) -> windows_sys::Win32::Foundation::HANDLE {
|
||||
) -> isize {
|
||||
unsafe {
|
||||
windows_sys::Win32::System::Threading::OpenProcess(
|
||||
desired_access,
|
||||
BOOL::from(inherit_handle),
|
||||
process_id,
|
||||
)
|
||||
) as _
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ mod _winapi {
|
||||
|
||||
#[pyfunction]
|
||||
fn WaitForSingleObject(h: HANDLE, ms: u32, vm: &VirtualMachine) -> PyResult<u32> {
|
||||
let ret = unsafe { windows_sys::Win32::System::Threading::WaitForSingleObject(h.0, ms) };
|
||||
let ret = unsafe { windows_sys::Win32::System::Threading::WaitForSingleObject(h.0 as _, ms) };
|
||||
if ret == windows_sys::Win32::Foundation::WAIT_FAILED {
|
||||
Err(errno_err(vm))
|
||||
} else {
|
||||
@@ -451,7 +451,7 @@ mod _winapi {
|
||||
unsafe {
|
||||
let mut ec = std::mem::MaybeUninit::uninit();
|
||||
WindowsSysResult(windows_sys::Win32::System::Threading::GetExitCodeProcess(
|
||||
h.0,
|
||||
h.0 as _,
|
||||
ec.as_mut_ptr(),
|
||||
))
|
||||
.to_pyresult(vm)?;
|
||||
@@ -462,7 +462,7 @@ mod _winapi {
|
||||
#[pyfunction]
|
||||
fn TerminateProcess(h: HANDLE, exit_code: u32) -> WindowsSysResult<BOOL> {
|
||||
WindowsSysResult(unsafe {
|
||||
windows_sys::Win32::System::Threading::TerminateProcess(h.0, exit_code)
|
||||
windows_sys::Win32::System::Threading::TerminateProcess(h.0 as _, exit_code)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -507,11 +507,11 @@ mod _winapi {
|
||||
// if handle.is_invalid() {
|
||||
// return Err(errno_err(vm));
|
||||
// }
|
||||
Ok(handle)
|
||||
Ok(handle as _)
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
fn ReleaseMutex(handle: isize) -> WindowsSysResult<BOOL> {
|
||||
WindowsSysResult(unsafe { windows_sys::Win32::System::Threading::ReleaseMutex(handle) })
|
||||
WindowsSysResult(unsafe { windows_sys::Win32::System::Threading::ReleaseMutex(handle as _) })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ impl WindowsSysResultValue for RAW_HANDLE {
|
||||
*self == INVALID_HANDLE_VALUE
|
||||
}
|
||||
fn into_ok(self) -> Self::Ok {
|
||||
HANDLE(self)
|
||||
HANDLE(self as _)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user