mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
remove processthreadsapi
This commit is contained in:
1 parent
7513017e21
commit
8a84a479f1
4 files changed
+31
-20
No files matched your search
+2
-2
@@ -142,8 +142,8 @@ features = [
|
||||
version = "0.3.9"
|
||||
features = [
|
||||
"winsock2", "handleapi", "std", "winbase", "processenv",
|
||||
"winnt", "processthreadsapi", "errhandlingapi", "wincon",
|
||||
"impl-default", "vcruntime", "sysinfoapi",
|
||||
"winnt", "errhandlingapi", "wincon",
|
||||
"impl-default", "vcruntime",
|
||||
]
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
|
||||
+6
-5
@@ -136,7 +136,8 @@ pub(crate) mod module {
|
||||
#[pyfunction]
|
||||
fn kill(pid: i32, sig: isize, vm: &VirtualMachine) -> PyResult<()> {
|
||||
{
|
||||
use um::{handleapi, processthreadsapi, wincon, winnt};
|
||||
use um::{wincon, winnt};
|
||||
use windows_sys::Win32::{Foundation::CloseHandle, System::Threading};
|
||||
let sig = sig as u32;
|
||||
let pid = pid as u32;
|
||||
|
||||
@@ -146,13 +147,13 @@ pub(crate) mod module {
|
||||
return res;
|
||||
}
|
||||
|
||||
let h = unsafe { processthreadsapi::OpenProcess(winnt::PROCESS_ALL_ACCESS, 0, pid) };
|
||||
if h.is_null() {
|
||||
let h = unsafe { Threading::OpenProcess(winnt::PROCESS_ALL_ACCESS, 0, pid) };
|
||||
if h == 0 {
|
||||
return Err(errno_err(vm));
|
||||
}
|
||||
let ret = unsafe { processthreadsapi::TerminateProcess(h, sig) };
|
||||
let ret = unsafe { Threading::TerminateProcess(h, sig) };
|
||||
let res = if ret == 0 { Err(errno_err(vm)) } else { Ok(()) };
|
||||
unsafe { handleapi::CloseHandle(h) };
|
||||
unsafe { CloseHandle(h) };
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
+17
-8
@@ -1414,19 +1414,28 @@ pub(super) mod _os {
|
||||
fn times(vm: &VirtualMachine) -> PyResult {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use winapi::shared::minwindef::FILETIME;
|
||||
use winapi::um::processthreadsapi::{GetCurrentProcess, GetProcessTimes};
|
||||
use std::mem::MaybeUninit;
|
||||
use windows_sys::Win32::{Foundation::FILETIME, System::Threading};
|
||||
|
||||
let mut _create = FILETIME::default();
|
||||
let mut _exit = FILETIME::default();
|
||||
let mut kernel = FILETIME::default();
|
||||
let mut user = FILETIME::default();
|
||||
let mut _create = MaybeUninit::<FILETIME>::uninit();
|
||||
let mut _exit = MaybeUninit::<FILETIME>::uninit();
|
||||
let mut kernel = MaybeUninit::<FILETIME>::uninit();
|
||||
let mut user = MaybeUninit::<FILETIME>::uninit();
|
||||
|
||||
unsafe {
|
||||
let h_proc = GetCurrentProcess();
|
||||
GetProcessTimes(h_proc, &mut _create, &mut _exit, &mut kernel, &mut user);
|
||||
let h_proc = Threading::GetCurrentProcess();
|
||||
Threading::GetProcessTimes(
|
||||
h_proc,
|
||||
_create.as_mut_ptr(),
|
||||
_exit.as_mut_ptr(),
|
||||
kernel.as_mut_ptr(),
|
||||
user.as_mut_ptr(),
|
||||
);
|
||||
}
|
||||
|
||||
let kernel = unsafe { kernel.assume_init() };
|
||||
let user = unsafe { user.assume_init() };
|
||||
|
||||
let times_result = TimesResult {
|
||||
user: user.dwHighDateTime as f64 * 429.4967296 + user.dwLowDateTime as f64 * 1e-7,
|
||||
system: kernel.dwHighDateTime as f64 * 429.4967296
|
||||
|
||||
@@ -628,12 +628,13 @@ mod platform {
|
||||
PyRef, PyResult, VirtualMachine,
|
||||
};
|
||||
use std::time::Duration;
|
||||
use winapi::shared::{minwindef::FILETIME, ntdef::ULARGE_INTEGER};
|
||||
use winapi::um::processthreadsapi::{
|
||||
GetCurrentProcess, GetCurrentThread, GetProcessTimes, GetThreadTimes,
|
||||
};
|
||||
use winapi::shared::ntdef::ULARGE_INTEGER;
|
||||
use winapi::um::profileapi::{QueryPerformanceCounter, QueryPerformanceFrequency};
|
||||
use windows_sys::Win32::System::SystemInformation::{GetSystemTimeAdjustment, GetTickCount64};
|
||||
use windows_sys::Win32::{
|
||||
Foundation::FILETIME,
|
||||
System::SystemInformation::{GetSystemTimeAdjustment, GetTickCount64},
|
||||
System::Threading::{GetCurrentProcess, GetCurrentThread, GetProcessTimes, GetThreadTimes},
|
||||
};
|
||||
|
||||
fn u64_from_filetime(time: FILETIME) -> u64 {
|
||||
unsafe {
|
||||
|
||||
Reference in new issue
Block a user