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",
|
"memmap2",
|
||||||
"region",
|
"region",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
"winapi",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -21,8 +21,13 @@ target-lexicon = "0.12"
|
|||||||
memmap2 = { version = "0.2.1", optional = true }
|
memmap2 = { version = "0.2.1", optional = true }
|
||||||
log = { version = "0.4.6", default-features = false }
|
log = { version = "0.4.6", default-features = false }
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(windows)'.dependencies.windows-sys]
|
||||||
winapi = { version = "0.3", features = ["winbase", "memoryapi"] }
|
version = "0.36.0"
|
||||||
|
features = [
|
||||||
|
"Win32_Foundation",
|
||||||
|
"Win32_System_LibraryLoader",
|
||||||
|
"Win32_System_Memory",
|
||||||
|
]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
selinux-fix = ['memmap2']
|
selinux-fix = ['memmap2']
|
||||||
|
|||||||
@@ -889,6 +889,10 @@ fn lookup_with_dlsym(name: &str) -> Option<*const u8> {
|
|||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn lookup_with_dlsym(name: &str) -> Option<*const u8> {
|
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";
|
const MSVCRT_DLL: &[u8] = b"msvcrt.dll\0";
|
||||||
|
|
||||||
let c_str = CString::new(name).unwrap();
|
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
|
// try to find the searched symbol in the currently running executable
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
// try to find the searched symbol in local c runtime
|
// 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 {
|
for handle in &handles {
|
||||||
let addr = winapi::um::libloaderapi::GetProcAddress(*handle, c_str_ptr);
|
let addr = LibraryLoader::GetProcAddress(*handle as HINSTANCE, c_str_ptr.cast());
|
||||||
if addr.is_null() {
|
match addr {
|
||||||
continue;
|
None => continue,
|
||||||
|
Some(addr) => return Some(addr as *const u8),
|
||||||
}
|
}
|
||||||
return Some(addr as *const u8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -62,8 +62,9 @@ impl PtrLen {
|
|||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn with_size(size: usize) -> io::Result<Self> {
|
fn with_size(size: usize) -> io::Result<Self> {
|
||||||
use winapi::um::memoryapi::VirtualAlloc;
|
use windows_sys::Win32::System::Memory::{
|
||||||
use winapi::um::winnt::{MEM_COMMIT, MEM_RESERVE, PAGE_READWRITE};
|
VirtualAlloc, MEM_COMMIT, MEM_RESERVE, PAGE_READWRITE,
|
||||||
|
};
|
||||||
|
|
||||||
// VirtualAlloc always rounds up to the next multiple of the page size
|
// VirtualAlloc always rounds up to the next multiple of the page size
|
||||||
let ptr = unsafe {
|
let ptr = unsafe {
|
||||||
|
|||||||
Reference in New Issue
Block a user