mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
deps: Switch from winapi
to windows_sys
in Servo code (#32516)
This is part of the switch from `winapi` to `windows-sys`. `windows-sys` is maintained by Microsoft, so is more "official." More and more crates are switching to it.
This commit is contained in:
parent
8b35c4094a
commit
e902d63732
7 changed files with 20 additions and 20 deletions
|
@ -18,7 +18,7 @@ jemalloc-sys = { workspace = true }
|
|||
libc = { workspace = true, optional = true }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { workspace = true, features = ["heapapi"] }
|
||||
windows-sys = { workspace = true, features = ["Win32_System_Memory"] }
|
||||
|
||||
[target.'cfg(target_env = "ohos")'.dependencies]
|
||||
libc = { workspace = true }
|
||||
|
|
|
@ -61,7 +61,8 @@ mod platform {
|
|||
pub use std::alloc::System as Allocator;
|
||||
use std::os::raw::c_void;
|
||||
|
||||
use winapi::um::heapapi::{GetProcessHeap, HeapSize, HeapValidate};
|
||||
use windows_sys::Win32::Foundation::FALSE;
|
||||
use windows_sys::Win32::System::Memory::{GetProcessHeap, HeapSize, HeapValidate};
|
||||
|
||||
/// Get the size of a heap block.
|
||||
///
|
||||
|
@ -71,8 +72,8 @@ mod platform {
|
|||
pub unsafe extern "C" fn usable_size(mut ptr: *const c_void) -> usize {
|
||||
let heap = GetProcessHeap();
|
||||
|
||||
if HeapValidate(heap, 0, ptr) == 0 {
|
||||
ptr = *(ptr as *const *const c_void).offset(-1);
|
||||
if HeapValidate(heap, 0, ptr) == FALSE {
|
||||
ptr = *(ptr as *const *const c_void).offset(-1)
|
||||
}
|
||||
|
||||
HeapSize(heap, 0, ptr) as usize
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use crate::sampler::{NativeStack, Sampler};
|
||||
|
||||
type MonitoredThreadId = usize; // TODO: use winapi
|
||||
type MonitoredThreadId = usize; // TODO: use the `windows` crate to do this.
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct WindowsSampler {
|
||||
|
@ -14,7 +14,7 @@ pub struct WindowsSampler {
|
|||
impl WindowsSampler {
|
||||
#[allow(unsafe_code, dead_code)]
|
||||
pub fn new_boxed() -> Box<dyn Sampler> {
|
||||
let thread_id = 0; // TODO: use winapi::um::processthreadsapi::GetThreadId
|
||||
let thread_id = 0; // TODO: use windows::Win32::System::Threading::GetThreadId
|
||||
Box::new(WindowsSampler { thread_id })
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ impl Sampler for WindowsSampler {
|
|||
// or any other unshareable resource.
|
||||
|
||||
// TODO:
|
||||
// 1: use winapi::um::processthreadsapi::SuspendThread
|
||||
// 2: use winapi::um::processthreadsapi::GetThreadContext
|
||||
// 1: use windows::Win32::Threading::SuspendThread
|
||||
// 2: use windows::Win32::Threading::GetThreadContext
|
||||
// 3: populate registers using the context, see
|
||||
// https://dxr.mozilla.org/mozilla-central/source/tools/profiler/core/platform-win32.cpp#129
|
||||
// 4: use winapi::um::processthreadsapi::ResumeThread
|
||||
// 4: use windows::Win32::Threading::ResumeThread
|
||||
|
||||
// NOTE: End of "critical section".
|
||||
Err(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue