Skip to content

Commit 7513017

Browse files
committed
replace sysinfoapi to windows-sys
1 parent adf0788 commit 7513017

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

vm/src/stdlib/sys.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -487,18 +487,15 @@ mod sys {
487487
fn getwindowsversion(vm: &VirtualMachine) -> PyResult<crate::builtins::tuple::PyTupleRef> {
488488
use std::ffi::OsString;
489489
use std::os::windows::ffi::OsStringExt;
490-
use winapi::um::{
491-
sysinfoapi::GetVersionExW,
492-
winnt::{LPOSVERSIONINFOEXW, LPOSVERSIONINFOW, OSVERSIONINFOEXW},
490+
use windows_sys::Win32::System::SystemInformation::{
491+
GetVersionExW, OSVERSIONINFOEXW, OSVERSIONINFOW,
493492
};
494493

495-
let mut version = OSVERSIONINFOEXW {
496-
dwOSVersionInfoSize: std::mem::size_of::<OSVERSIONINFOEXW>() as u32,
497-
..OSVERSIONINFOEXW::default()
498-
};
494+
let mut version: OSVERSIONINFOEXW = unsafe { std::mem::zeroed() };
495+
version.dwOSVersionInfoSize = std::mem::size_of::<OSVERSIONINFOEXW>() as u32;
499496
let result = unsafe {
500-
let osvi = &mut version as LPOSVERSIONINFOEXW as LPOSVERSIONINFOW;
501-
// SAFETY: GetVersionExW accepts a pointer of OSVERSIONINFOW, but winapi crate's type currently doesn't allow to do so.
497+
let osvi = &mut version as *mut OSVERSIONINFOEXW as *mut OSVERSIONINFOW;
498+
// SAFETY: GetVersionExW accepts a pointer of OSVERSIONINFOW, but windows-sys crate's type currently doesn't allow to do so.
502499
// https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexw#parameters
503500
GetVersionExW(osvi)
504501
};

vm/src/stdlib/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ mod platform {
633633
GetCurrentProcess, GetCurrentThread, GetProcessTimes, GetThreadTimes,
634634
};
635635
use winapi::um::profileapi::{QueryPerformanceCounter, QueryPerformanceFrequency};
636-
use winapi::um::sysinfoapi::{GetSystemTimeAdjustment, GetTickCount64};
636+
use windows_sys::Win32::System::SystemInformation::{GetSystemTimeAdjustment, GetTickCount64};
637637

638638
fn u64_from_filetime(time: FILETIME) -> u64 {
639639
unsafe {

0 commit comments

Comments
 (0)