rutabaga_gfx: change os_handle type

Windows HANDLE is defined as void* which is incompatible with current
os_handle type i32. Change that to i64.

TEST=launch_cvd --gpu_mode=gfxstream
BUG=b:217977329

Change-Id: I78c6c4c0d7573773ed530d8987b932438222144f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3445529
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
This commit is contained in:
Kaiyi Li 2022-02-07 15:46:40 -08:00 committed by Commit Bot
parent 7aa543ca35
commit 3ff6bbd1ac
2 changed files with 6 additions and 4 deletions

View file

@ -123,7 +123,7 @@ struct rutabaga_iovecs {
};
struct rutabaga_handle {
int32_t os_handle;
int64_t os_handle;
uint32_t handle_type;
};

View file

@ -9,6 +9,7 @@
#![cfg(feature = "gfxstream")]
use std::cell::RefCell;
use std::convert::TryInto;
use std::mem::{size_of, transmute};
use std::os::raw::{c_char, c_int, c_uint, c_void};
use std::ptr::{null, null_mut};
@ -41,7 +42,7 @@ pub struct GfxstreamRendererCallbacks {
#[repr(C)]
#[derive(Copy, Clone, Default)]
pub struct stream_renderer_handle {
pub os_handle: i32,
pub os_handle: i64,
pub handle_type: u32,
}
@ -275,7 +276,8 @@ impl Gfxstream {
// Safe because the handle was just returned by a successful gfxstream call so it must be
// valid and owned by us.
let handle = unsafe { SafeDescriptor::from_raw_descriptor(stream_handle.os_handle) };
let raw_descriptor = stream_handle.os_handle.try_into()?;
let handle = unsafe { SafeDescriptor::from_raw_descriptor(raw_descriptor) };
Ok(Arc::new(RutabagaHandle {
os_handle: handle,
@ -483,7 +485,7 @@ impl RutabagaComponent for Gfxstream {
let mut stream_handle: stream_renderer_handle = Default::default();
if let Some(handle) = handle_opt {
stream_handle.handle_type = handle.handle_type;
stream_handle.os_handle = handle.os_handle.into_raw_descriptor();
stream_handle.os_handle = handle.os_handle.into_raw_descriptor().into();
handle_ptr = &stream_handle;
}