10000 Remove winapi dependency and upgrade windows-sys to 0.59 by arihant2math · Pull Request #5581 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Remove winapi dependency and upgrade windows-sys to 0.59 #5581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
formatting
  • Loading branch information
arihant2math committed Mar 5, 2025
commit d2efda53d119f0073f47f0ffebc3fcf352d0bf78
2 changes: 1 addition & 1 deletion common/src/fileutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub mod windows {

let p_id_info = if unsafe {
GetFileInformationByHandleEx(
h as _,
h as _,
FileIdInfo,
&mut id_info as *mut _ as *mut _,
std::mem::size_of_val(&id_info) as u32,
Expand Down
7 changes: 6 additions & 1 deletion stdlib/src/overlapped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,12 @@ mod _overlapped {
vm: &VirtualMachine,
) -> PyResult<isize> {
let r = unsafe {
windows_sys::Win32::System::IO::CreateIoCompletionPort(handle as _, port as _, key, concurrency) as isize
windows_sys::Win32::System::IO::CreateIoCompletionPort(
handle as _,
port as _,
key,
concurrency,
) as isize
};
if r as usize == 0 {
return Err(errno_err(vm));
Expand Down
11 changes: 4 additions & 7 deletions stdlib/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ mod _socket {
#[cfg(windows)]
mod c {
pub use windows_sys::Win32::NetworkManagement::IpHelper::{if_indextoname, if_nametoindex};
pub use windows_sys::Win32::Networking::WinSock::{INADDR_ANY, INADDR_LOOPBACK, INADDR_BROADCAST, INADDR_NONE};
pub use windows_sys::Win32::Networking::WinSock::{
INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_NONE,
};

pub use windows_sys::Win32::Networking::WinSock::{
AF_APPLETALK, AF_DECnet, AF_IPX, AF_LINK, AI_ADDRCONFIG, AI_ALL, AI_CANONNAME,
Expand Down Expand Up @@ -1757,12 +1759,7 @@ mod _socket {
.map(|s| s.to_cstring(vm))
.transpose()?;
let cstr_proto = cstr_opt_as_ptr(&cstr_proto);
let serv = unsafe {
c::getservbyname(
cstr_name.as_ptr() as _,
cstr_proto as _,
)
};
let serv = unsafe { c::getservbyname(cstr_name.as_ptr() as _, cstr_proto as _) };
if serv.is_null() {
return Err(vm.new_os_error("service/proto not found".to_owned()));
}
Expand Down
15 changes: 7 additions & 8 deletions vm/src/stdlib/winapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,14 @@ mod _winapi {

Ok((
HANDLE(procinfo.hProcess as _),
HANDLE(procinfo.hThread as _),
HANDLE(procinfo.hThread as _),
procinfo.dwProcessId,
procinfo.dwThreadId,
))
}

#[pyfunction]
fn OpenProcess(
desired_access: u32,
inherit_handle: bool,
process_id: u32,
) -> isize {
fn OpenProcess(desired_access: u32, inherit_handle: bool, process_id: u32) -> isize {
unsafe {
windows_sys::Win32::System::Threading::OpenProcess(
desired_access,
Expand Down Expand Up @@ -438,7 +434,8 @@ mod _winapi {

#[pyfunction]
fn WaitForSingleObject(h: HANDLE, ms: u32, vm: &VirtualMachine) -> PyResult<u32> {
let ret = unsafe { windows_sys::Win32::System::Threading::WaitForSingleObject(h.0 as _, 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 {
Expand Down Expand Up @@ -512,6 +509,8 @@ mod _winapi {

#[pyfunction]
fn ReleaseMutex(handle: isize) -> WindowsSysResult<BOOL> {
WindowsSysResult(unsafe { windows_sys::Win32::System::Threading::ReleaseMutex(handle as _) })
WindowsSysResult(unsafe {
windows_sys::Win32::System::Threading::ReleaseMutex(handle as _)
})
}
}
Loading
0