rutabaga_gfx: fix cross-compile on Windows

When cross-compiling Windows on Linux, multiple features are
reported missing.  Also, winapi::ctypes::c_void and
libc::c_void differ.

winbase isn't used yet, but there's a few futre patches that
benefit from it.

BUG=322802940
TEST=cargo build --target x86_64-pc-windows-gnu

Change-Id: I7aee961b1758050e5f93c3619db27d59bf918fe2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5245137
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
Gurchetan Singh 2024-01-25 12:32:55 -08:00 committed by crosvm LUCI
parent 481d24e461
commit f29fff8331
2 changed files with 9 additions and 9 deletions

View file

@ -29,7 +29,7 @@ log = "0.4"
nix = { version = "0.27.1", features = ["event", "feature", "fs", "mman", "socket", "uio", "ioctl"] }
[target.'cfg(windows)'.dependencies]
winapi = "0.3"
winapi = {version = "0.3", features = ["winnt", "handleapi", "processthreadsapi", "winbase"]}
# To build latest Vulkano, change version to git = "https:/github.com/vulkano-rs/vulkano.git"
# vulkano = { version = "0.31.0", optional = true }

View file

@ -34,7 +34,7 @@ pub type RawDescriptor = RawHandle;
impl Drop for SafeDescriptor {
fn drop(&mut self) {
// SAFETY: Safe because we own the descriptor.
unsafe { CloseHandle(self.descriptor) };
unsafe { CloseHandle(self.descriptor as _) };
}
}
@ -54,12 +54,12 @@ pub fn duplicate_handle_from_source_process(
// 2. new_handle_ptr points to a valid location on the stack
// 3. Caller guarantees hndl is a real valid handle.
unsafe {
let mut new_handle: RawHandle = std::ptr::null_mut();
let new_handle: RawHandle = std::ptr::null_mut();
let success_flag = DuplicateHandle(
/* hSourceProcessHandle= */ source_process_handle,
/* hSourceHandle= */ hndl,
/* hTargetProcessHandle= */ target_process_handle,
/* lpTargetHandle= */ &mut new_handle,
/* hSourceProcessHandle= */ source_process_handle as _,
/* hSourceHandle= */ hndl as _,
/* hTargetProcessHandle= */ target_process_handle as _,
/* lpTargetHandle= */ new_handle as _,
/* dwDesiredAccess= */ 0,
/* bInheritHandle= */ TRUE,
/* dwOptions= */ DUPLICATE_SAME_ACCESS,
@ -80,7 +80,7 @@ fn duplicate_handle_with_target_handle(
duplicate_handle_from_source_process(
// SAFETY:
// Safe because `GetCurrentProcess` just gets the current process handle.
unsafe { GetCurrentProcess() },
unsafe { GetCurrentProcess() as _ },
hndl,
target_process_handle,
)
@ -89,7 +89,7 @@ fn duplicate_handle_with_target_handle(
pub fn duplicate_handle(hndl: RawHandle) -> io::Result<RawHandle> {
// SAFETY:
// Safe because `GetCurrentProcess` just gets the current process handle.
duplicate_handle_with_target_handle(hndl, unsafe { GetCurrentProcess() })
duplicate_handle_with_target_handle(hndl, unsafe { GetCurrentProcess() as _ })
}
impl TryFrom<&dyn AsRawHandle> for SafeDescriptor {