Migrate cranelift-jit from winapi to windows-sys (#4363)
* Migrate cranelift-jit from `winapi` to `windows-sys` Following up on #4346, this migrates one more place in the tree from winapi to windows-sys.
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -624,7 +624,7 @@ dependencies = [
|
||||
"memmap2",
|
||||
"region",
|
||||
"target-lexicon",
|
||||
"winapi",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -21,8 +21,13 @@ target-lexicon = "0.12"
|
||||
memmap2 = { version = "0.2.1", optional = true }
|
||||
log = { version = "0.4.6", default-features = false }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = { version = "0.3", features = ["winbase", "memoryapi"] }
|
||||
[target.'cfg(windows)'.dependencies.windows-sys]
|
||||
version = "0.36.0"
|
||||
features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_System_LibraryLoader",
|
||||
"Win32_System_Memory",
|
||||
]
|
||||
|
||||
[features]
|
||||
selinux-fix = ['memmap2']
|
||||
|
||||
@@ -889,6 +889,10 @@ fn lookup_with_dlsym(name: &str) -> Option<*const u8> {
|
||||
|
||||
#[cfg(windows)]
|
||||
fn lookup_with_dlsym(name: &str) -> Option<*const u8> {
|
||||
use std::os::windows::io::RawHandle;
|
||||
use windows_sys::Win32::Foundation::HINSTANCE;
|
||||
use windows_sys::Win32::System::LibraryLoader;
|
||||
|
||||
const MSVCRT_DLL: &[u8] = b"msvcrt.dll\0";
|
||||
|
||||
let c_str = CString::new(name).unwrap();
|
||||
@@ -899,15 +903,15 @@ fn lookup_with_dlsym(name: &str) -> Option<*const u8> {
|
||||
// try to find the searched symbol in the currently running executable
|
||||
ptr::null_mut(),
|
||||
// try to find the searched symbol in local c runtime
|
||||
winapi::um::libloaderapi::GetModuleHandleA(MSVCRT_DLL.as_ptr().cast::<i8>()),
|
||||
LibraryLoader::GetModuleHandleA(MSVCRT_DLL.as_ptr()) as RawHandle,
|
||||
];
|
||||
|
||||
for handle in &handles {
|
||||
let addr = winapi::um::libloaderapi::GetProcAddress(*handle, c_str_ptr);
|
||||
if addr.is_null() {
|
||||
continue;
|
||||
let addr = LibraryLoader::GetProcAddress(*handle as HINSTANCE, c_str_ptr.cast());
|
||||
match addr {
|
||||
None => continue,
|
||||
Some(addr) => return Some(addr as *const u8),
|
||||
}
|
||||
return Some(addr as *const u8);
|
||||
}
|
||||
|
||||
None
|
||||
|
||||
@@ -62,8 +62,9 @@ impl PtrLen {
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn with_size(size: usize) -> io::Result<Self> {
|
||||
use winapi::um::memoryapi::VirtualAlloc;
|
||||
use winapi::um::winnt::{MEM_COMMIT, MEM_RESERVE, PAGE_READWRITE};
|
||||
use windows_sys::Win32::System::Memory::{
|
||||
VirtualAlloc, MEM_COMMIT, MEM_RESERVE, PAGE_READWRITE,
|
||||
};
|
||||
|
||||
// VirtualAlloc always rounds up to the next multiple of the page size
|
||||
let ptr = unsafe {
|
||||
|
||||
Reference in New Issue
Block a user