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:
Dan Gohman
2022-07-01 08:41:02 -07:00
committed by GitHub
parent ec83144c88
commit 64759f04a4
4 changed files with 20 additions and 10 deletions

View File

@@ -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