From ce0d8c51e9db52631e629b1376add5c5eccf5960 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 7 Dec 2021 17:05:39 -0800 Subject: [PATCH] libvda: regenerate bindings BUG=b:218388029 TEST=tools/presubmit --quick Change-Id: I37112713dca5e8fef1299fcff72933cfcf06eafd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339810 Reviewed-by: Alexandre Courbot Tested-by: kokoro Commit-Queue: Daniel Verkamp --- libvda/bindgen.sh | 46 +++ libvda/src/bindings.rs | 64 +--- libvda/src/decode/bindings.rs | 512 +++------------------------ libvda/src/encode/bindings.rs | 641 ++++------------------------------ tools/bindgen-all-the-things | 1 + 5 files changed, 167 insertions(+), 1097 deletions(-) create mode 100755 libvda/bindgen.sh diff --git a/libvda/bindgen.sh b/libvda/bindgen.sh new file mode 100755 index 0000000000..099dd226cc --- /dev/null +++ b/libvda/bindgen.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# Copyright 2022 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Regenerate libvda bindgen bindings. + +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +source tools/impl/bindgen-common.sh + +bindgen_generate \ + --allowlist-type='video_.*' \ + "${BINDGEN_PLATFORM2}/arc/vm/libvda/libvda_common.h" \ + > libvda/src/bindings.rs + +bindgen_generate \ + --raw-line 'pub use crate::bindings::*;' \ + --allowlist-function 'initialize' \ + --allowlist-function 'deinitialize' \ + --allowlist-function 'get_vda_capabilities' \ + --allowlist-function 'init_decode_session' \ + --allowlist-function 'close_decode_session' \ + --allowlist-function 'vda_.*' \ + --allowlist-type 'vda_.*' \ + --blocklist-type 'video_.*' \ + "${BINDGEN_PLATFORM2}/arc/vm/libvda/libvda_decode.h" \ + -- \ + -I "${BINDGEN_PLATFORM2}" \ + > libvda/src/decode/bindings.rs + +bindgen_generate \ + --raw-line 'pub use crate::bindings::*;' \ + --allowlist-function 'initialize_encode' \ + --allowlist-function 'deinitialize_encode' \ + --allowlist-function 'get_vea_capabilities' \ + --allowlist-function 'init_encode_session' \ + --allowlist-function 'close_encode_session' \ + --allowlist-function 'vea_.*' \ + --allowlist-type 'vea_.*' \ + --blocklist-type 'video_.*' \ + "${BINDGEN_PLATFORM2}/arc/vm/libvda/libvda_encode.h" \ + -- \ + -I "${BINDGEN_PLATFORM2}" \ + > libvda/src/encode/bindings.rs diff --git a/libvda/src/bindings.rs b/libvda/src/bindings.rs index d2eaf87cf1..80c25d6fec 100644 --- a/libvda/src/bindings.rs +++ b/libvda/src/bindings.rs @@ -1,65 +1,17 @@ -// Copyright 2020 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +/* automatically generated by tools/bindgen-all-the-things */ -#![allow( - dead_code, - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - warnings -)] - -/* -automatically generated by rust-bindgen - -generated with the command: -cd ${CHROMEOS_DIR}/src/platform2 && \ -bindgen arc/vm/libvda/libvda_common.h \ - -o ../platform/crosvm/libvda/src/common/bindings.rs \ - --allowlist-type "video_.*" -*/ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] pub type __int32_t = ::std::os::raw::c_int; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone)] pub struct video_frame_plane { pub offset: i32, pub stride: i32, } -#[test] -fn bindgen_test_layout_video_frame_plane() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(video_frame_plane)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(video_frame_plane)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(video_frame_plane), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).stride as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(video_frame_plane), - "::", - stringify!(stride) - ) - ); -} pub type video_frame_plane_t = video_frame_plane; pub const video_codec_profile_VIDEO_CODEC_PROFILE_UNKNOWN: video_codec_profile = -1; pub const video_codec_profile_VIDEO_CODEC_PROFILE_MIN: video_codec_profile = -1; @@ -105,10 +57,10 @@ pub const video_codec_profile_AV1PROFILE_PROFILE_HIGH: video_codec_profile = 25; pub const video_codec_profile_AV1PROFILE_PROFILE_PRO: video_codec_profile = 26; pub const video_codec_profile_AV1PROFILE_MAX: video_codec_profile = 26; pub const video_codec_profile_VIDEO_CODEC_PROFILE_MAX: video_codec_profile = 26; -pub type video_codec_profile = i32; +pub type video_codec_profile = ::std::os::raw::c_int; pub use self::video_codec_profile as video_codec_profile_t; pub const video_pixel_format_YV12: video_pixel_format = 0; pub const video_pixel_format_NV12: video_pixel_format = 1; pub const video_pixel_format_PIXEL_FORMAT_MAX: video_pixel_format = 1; -pub type video_pixel_format = u32; +pub type video_pixel_format = ::std::os::raw::c_uint; pub use self::video_pixel_format as video_pixel_format_t; diff --git a/libvda/src/decode/bindings.rs b/libvda/src/decode/bindings.rs index ba6d8d68c2..b790094214 100644 --- a/libvda/src/decode/bindings.rs +++ b/libvda/src/decode/bindings.rs @@ -1,43 +1,19 @@ -// Copyright 2020 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +/* automatically generated by tools/bindgen-all-the-things */ -#![allow( - dead_code, - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - warnings -)] - -/* -automatically generated by rust-bindgen - -generated with the command: -cd ${CHROMEOS_DIR}/src/platform2/ && \ -bindgen arc/vm/libvda/libvda_decode.h \ - -o ../platform/crosvm/libvda/src/decode/bindings.rs \ - --raw-line 'pub use crate::bindings::*;' \ - --allowlist-function "initialize" \ - --allowlist-function "deinitialize" \ - --allowlist-function "get_vda_capabilities" \ - --allowlist-function "init_decode_session" \ - --allowlist-function "close_decode_session" \ - --allowlist-function "vda_.*" \ - --allowlist-type "vda_.*" \ - --blocklist-type "video_.*" \ - -- \ - -I . -*/ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] pub use crate::bindings::*; pub type __int32_t = ::std::os::raw::c_int; pub type __uint32_t = ::std::os::raw::c_uint; +pub type __uint64_t = ::std::os::raw::c_ulong; pub const vda_impl_type_FAKE: vda_impl_type = 0; pub const vda_impl_type_GAVDA: vda_impl_type = 1; pub const vda_impl_type_GAVD: vda_impl_type = 2; -pub type vda_impl_type = u32; +pub type vda_impl_type = ::std::os::raw::c_uint; pub use self::vda_impl_type as vda_impl_type_t; pub const vda_result_SUCCESS: vda_result = 0; pub const vda_result_ILLEGAL_STATE: vda_result = 1; @@ -46,7 +22,7 @@ pub const vda_result_UNREADABLE_INPUT: vda_result = 3; pub const vda_result_PLATFORM_FAILURE: vda_result = 4; pub const vda_result_INSUFFICIENT_RESOURCES: vda_result = 5; pub const vda_result_CANCELLED: vda_result = 6; -pub type vda_result = u32; +pub type vda_result = ::std::os::raw::c_uint; pub use self::vda_result as vda_result_t; pub use self::video_codec_profile_t as vda_profile_t; pub use self::video_pixel_format_t as vda_pixel_format_t; @@ -57,10 +33,10 @@ pub const vda_event_type_NOTIFY_END_OF_BITSTREAM_BUFFER: vda_event_type = 3; pub const vda_event_type_NOTIFY_ERROR: vda_event_type = 4; pub const vda_event_type_RESET_RESPONSE: vda_event_type = 5; pub const vda_event_type_FLUSH_RESPONSE: vda_event_type = 6; -pub type vda_event_type = u32; +pub type vda_event_type = ::std::os::raw::c_uint; pub use self::vda_event_type as vda_event_type_t; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone)] pub struct provide_picture_buffers_event_data { pub min_num_buffers: u32, pub width: i32, @@ -70,116 +46,9 @@ pub struct provide_picture_buffers_event_data { pub visible_rect_right: i32, pub visible_rect_bottom: i32, } -#[test] -fn bindgen_test_layout_provide_picture_buffers_event_data() { - assert_eq!( - ::std::mem::size_of::(), - 28usize, - concat!("Size of: ", stringify!(provide_picture_buffers_event_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!( - "Alignment of ", - stringify!(provide_picture_buffers_event_data) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).min_num_buffers - as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(provide_picture_buffers_event_data), - "::", - stringify!(min_num_buffers) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).width as *const _ - as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(provide_picture_buffers_event_data), - "::", - stringify!(width) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).height as *const _ - as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(provide_picture_buffers_event_data), - "::", - stringify!(height) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).visible_rect_left - as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(provide_picture_buffers_event_data), - "::", - stringify!(visible_rect_left) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).visible_rect_top - as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(provide_picture_buffers_event_data), - "::", - stringify!(visible_rect_top) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).visible_rect_right - as *const _ as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(provide_picture_buffers_event_data), - "::", - stringify!(visible_rect_right) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).visible_rect_bottom - as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(provide_picture_buffers_event_data), - "::", - stringify!(visible_rect_bottom) - ) - ); -} pub type provide_picture_buffers_event_data_t = provide_picture_buffers_event_data; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone)] pub struct picture_ready_event_data { pub picture_buffer_id: i32, pub bitstream_id: i32, @@ -188,92 +57,6 @@ pub struct picture_ready_event_data { pub crop_right: i32, pub crop_bottom: i32, } -#[test] -fn bindgen_test_layout_picture_ready_event_data() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(picture_ready_event_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(picture_ready_event_data)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).picture_buffer_id as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(picture_ready_event_data), - "::", - stringify!(picture_buffer_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).bitstream_id as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(picture_ready_event_data), - "::", - stringify!(bitstream_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).crop_left as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(picture_ready_event_data), - "::", - stringify!(crop_left) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).crop_top as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(picture_ready_event_data), - "::", - stringify!(crop_top) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).crop_right as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(picture_ready_event_data), - "::", - stringify!(crop_right) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).crop_bottom as *const _ as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(picture_ready_event_data), - "::", - stringify!(crop_bottom) - ) - ); -} pub type picture_ready_event_data_t = picture_ready_event_data; #[repr(C)] #[derive(Copy, Clone)] @@ -282,62 +65,15 @@ pub union vda_event_data { pub picture_ready: picture_ready_event_data_t, pub bitstream_id: i32, pub result: vda_result_t, - _bindgen_union_align: [u32; 7usize], } -#[test] -fn bindgen_test_layout_vda_event_data() { - assert_eq!( - ::std::mem::size_of::(), - 28usize, - concat!("Size of: ", stringify!(vda_event_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(vda_event_data)) - ); - assert_eq!( +impl Default for vda_event_data { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).provide_picture_buffers as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vda_event_data), - "::", - stringify!(provide_picture_buffers) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).picture_ready as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vda_event_data), - "::", - stringify!(picture_ready) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bitstream_id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vda_event_data), - "::", - stringify!(bitstream_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).result as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vda_event_data), - "::", - stringify!(result) - ) - ); + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vda_event_data_t = vda_event_data; #[repr(C)] @@ -348,68 +84,14 @@ pub struct vda_input_format { pub max_width: u32, pub max_height: u32, } -#[test] -fn bindgen_test_layout_vda_input_format() { - assert_eq!( - ::std::mem::size_of::(), - 20usize, - concat!("Size of: ", stringify!(vda_input_format)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(vda_input_format)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).profile as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vda_input_format), - "::", - stringify!(profile) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).min_width as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(vda_input_format), - "::", - stringify!(min_width) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).min_height as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vda_input_format), - "::", - stringify!(min_height) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_width as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(vda_input_format), - "::", - stringify!(max_width) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_height as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(vda_input_format), - "::", - stringify!(max_height) - ) - ); +impl Default for vda_input_format { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vda_input_format_t = vda_input_format; #[repr(C)] @@ -418,38 +100,14 @@ pub struct vda_event { pub event_type: vda_event_type_t, pub event_data: vda_event_data_t, } -#[test] -fn bindgen_test_layout_vda_event() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(vda_event)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(vda_event)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).event_type as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vda_event), - "::", - stringify!(event_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).event_data as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(vda_event), - "::", - stringify!(event_data) - ) - ); +impl Default for vda_event { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vda_event_t = vda_event; #[repr(C)] @@ -460,62 +118,14 @@ pub struct vda_capabilities { pub num_output_formats: usize, pub output_formats: *const vda_pixel_format_t, } -#[test] -fn bindgen_test_layout_vda_capabilities() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(vda_capabilities)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(vda_capabilities)) - ); - assert_eq!( +impl Default for vda_capabilities { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).num_input_formats as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vda_capabilities), - "::", - stringify!(num_input_formats) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).input_formats as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vda_capabilities), - "::", - stringify!(input_formats) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).num_output_formats as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(vda_capabilities), - "::", - stringify!(num_output_formats) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).output_formats as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(vda_capabilities), - "::", - stringify!(output_formats) - ) - ); + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vda_capabilities_t = vda_capabilities; #[repr(C)] @@ -524,38 +134,14 @@ pub struct vda_session_info { pub ctx: *mut ::std::os::raw::c_void, pub event_pipe_fd: ::std::os::raw::c_int, } -#[test] -fn bindgen_test_layout_vda_session_info() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(vda_session_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(vda_session_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ctx as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vda_session_info), - "::", - stringify!(ctx) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).event_pipe_fd as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vda_session_info), - "::", - stringify!(event_pipe_fd) - ) - ); +impl Default for vda_session_info { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vda_session_info_t = vda_session_info; extern "C" { diff --git a/libvda/src/encode/bindings.rs b/libvda/src/encode/bindings.rs index 5cb00b538c..951c2bb328 100644 --- a/libvda/src/encode/bindings.rs +++ b/libvda/src/encode/bindings.rs @@ -1,34 +1,9 @@ -// Copyright 2020 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +/* automatically generated by tools/bindgen-all-the-things */ -/* -automatically generated by rust-bindgen - -generated with the command: -cd ${CHROMEOS_DIR}/src/platform2/ && \ -bindgen arc/vm/libvda/libvda_encode.h \ - -o ../platform/crosvm/libvda/src/encode/bindings.rs \ - --raw-line 'pub use crate::bindings::*;' \ - --allowlist-function "initialize_encode" \ - --allowlist-function "deinitialize_encode" \ - --allowlist-function "get_vea_capabilities" \ - --allowlist-function "init_encode_session" \ - --allowlist-function "close_encode_session" \ - --allowlist-function "vea_.*" \ - --allowlist-type "vea_.*" \ - --blocklist-type "video_.*" \ - -- \ - -I . - */ - -#![allow( - dead_code, - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - warnings -)] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] pub use crate::bindings::*; @@ -38,7 +13,7 @@ pub type __uint32_t = ::std::os::raw::c_uint; pub type __int64_t = ::std::os::raw::c_long; pub const vea_impl_type_VEA_FAKE: vea_impl_type = 0; pub const vea_impl_type_GAVEA: vea_impl_type = 1; -pub type vea_impl_type = u32; +pub type vea_impl_type = ::std::os::raw::c_uint; pub use self::vea_impl_type as vea_impl_type_t; #[repr(C)] pub struct vea_profile { @@ -48,72 +23,14 @@ pub struct vea_profile { pub max_framerate_numerator: u32, pub max_framerate_denominator: u32, } -#[test] -fn bindgen_test_layout_vea_profile() { - assert_eq!( - ::std::mem::size_of::(), - 20usize, - concat!("Size of: ", stringify!(vea_profile)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(vea_profile)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).profile as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_profile), - "::", - stringify!(profile) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_width as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(vea_profile), - "::", - stringify!(max_width) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_height as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vea_profile), - "::", - stringify!(max_height) - ) - ); - assert_eq!( +impl Default for vea_profile { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).max_framerate_numerator as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(vea_profile), - "::", - stringify!(max_framerate_numerator) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).max_framerate_denominator as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(vea_profile), - "::", - stringify!(max_framerate_denominator) - ) - ); + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vea_profile_t = vea_profile; #[repr(C)] @@ -124,67 +41,19 @@ pub struct vea_capabilities { pub num_output_formats: usize, pub output_formats: *const vea_profile_t, } -#[test] -fn bindgen_test_layout_vea_capabilities() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(vea_capabilities)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(vea_capabilities)) - ); - assert_eq!( +impl Default for vea_capabilities { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).num_input_formats as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_capabilities), - "::", - stringify!(num_input_formats) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).input_formats as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vea_capabilities), - "::", - stringify!(input_formats) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).num_output_formats as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(vea_capabilities), - "::", - stringify!(num_output_formats) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).output_formats as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(vea_capabilities), - "::", - stringify!(output_formats) - ) - ); + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vea_capabilities_t = vea_capabilities; pub const vea_bitrate_mode_VBR: vea_bitrate_mode = 0; pub const vea_bitrate_mode_CBR: vea_bitrate_mode = 1; -pub type vea_bitrate_mode = u32; +pub type vea_bitrate_mode = ::std::os::raw::c_uint; pub use self::vea_bitrate_mode as vea_bitrate_mode_t; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -193,48 +62,14 @@ pub struct vea_bitrate { pub target: u32, pub peak: u32, } -#[test] -fn bindgen_test_layout_vea_bitrate() { - assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(vea_bitrate)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(vea_bitrate)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mode as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_bitrate), - "::", - stringify!(mode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).target as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(vea_bitrate), - "::", - stringify!(target) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).peak as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vea_bitrate), - "::", - stringify!(peak) - ) - ); +impl Default for vea_bitrate { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vea_bitrate_t = vea_bitrate; #[repr(C)] @@ -249,118 +84,20 @@ pub struct vea_config { pub h264_output_level: u8, pub has_h264_output_level: u8, } -#[test] -fn bindgen_test_layout_vea_config() { - assert_eq!( - ::std::mem::size_of::(), - 36usize, - concat!("Size of: ", stringify!(vea_config)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(vea_config)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).input_format as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_config), - "::", - stringify!(input_format) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).input_visible_width as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(vea_config), - "::", - stringify!(input_visible_width) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).input_visible_height as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vea_config), - "::", - stringify!(input_visible_height) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).output_profile as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(vea_config), - "::", - stringify!(output_profile) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bitrate as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(vea_config), - "::", - stringify!(bitrate) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).initial_framerate as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(vea_config), - "::", - stringify!(initial_framerate) - ) - ); - assert_eq!( +impl Default for vea_config { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).has_initial_framerate as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(vea_config), - "::", - stringify!(has_initial_framerate) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).h264_output_level as *const _ as usize }, - 33usize, - concat!( - "Offset of field: ", - stringify!(vea_config), - "::", - stringify!(h264_output_level) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).has_h264_output_level as *const _ as usize - }, - 34usize, - concat!( - "Offset of field: ", - stringify!(vea_config), - "::", - stringify!(has_h264_output_level) - ) - ); + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vea_config_t = vea_config; pub const vea_error_ILLEGAL_STATE_ERROR: vea_error = 0; pub const vea_error_INVALID_ARGUMENT_ERROR: vea_error = 1; pub const vea_error_PLATFORM_FAILURE_ERROR: vea_error = 2; -pub type vea_error = u32; +pub type vea_error = ::std::os::raw::c_uint; pub use self::vea_error as vea_error_t; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -368,38 +105,14 @@ pub struct vea_session_info { pub ctx: *mut ::std::os::raw::c_void, pub event_pipe_fd: ::std::os::raw::c_int, } -#[test] -fn bindgen_test_layout_vea_session_info() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(vea_session_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(vea_session_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ctx as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_session_info), - "::", - stringify!(ctx) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).event_pipe_fd as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vea_session_info), - "::", - stringify!(event_pipe_fd) - ) - ); +impl Default for vea_session_info { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vea_session_info_t = vea_session_info; pub type vea_input_buffer_id_t = i32; @@ -409,167 +122,25 @@ pub const vea_event_type_PROCESSED_INPUT_BUFFER: vea_event_type = 1; pub const vea_event_type_PROCESSED_OUTPUT_BUFFER: vea_event_type = 2; pub const vea_event_type_VEA_FLUSH_RESPONSE: vea_event_type = 3; pub const vea_event_type_VEA_NOTIFY_ERROR: vea_event_type = 4; -pub type vea_event_type = u32; +pub type vea_event_type = ::std::os::raw::c_uint; pub use self::vea_event_type as vea_event_type_t; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone)] pub struct vea_require_input_buffers_event_data { pub input_count: u32, pub input_frame_width: u32, pub input_frame_height: u32, pub output_buffer_size: u32, } -#[test] -fn bindgen_test_layout_vea_require_input_buffers_event_data() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(vea_require_input_buffers_event_data) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!( - "Alignment of ", - stringify!(vea_require_input_buffers_event_data) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input_count as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_require_input_buffers_event_data), - "::", - stringify!(input_count) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input_frame_width - as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(vea_require_input_buffers_event_data), - "::", - stringify!(input_frame_width) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input_frame_height - as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vea_require_input_buffers_event_data), - "::", - stringify!(input_frame_height) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).output_buffer_size - as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(vea_require_input_buffers_event_data), - "::", - stringify!(output_buffer_size) - ) - ); -} pub type vea_require_input_buffers_event_data_t = vea_require_input_buffers_event_data; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone)] pub struct vea_processed_output_buffer_event_data { pub output_buffer_id: vea_output_buffer_id_t, pub payload_size: u32, pub key_frame: u8, pub timestamp: i64, } -#[test] -fn bindgen_test_layout_vea_processed_output_buffer_event_data() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!( - "Size of: ", - stringify!(vea_processed_output_buffer_event_data) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(vea_processed_output_buffer_event_data) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).output_buffer_id - as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_processed_output_buffer_event_data), - "::", - stringify!(output_buffer_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).payload_size - as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(vea_processed_output_buffer_event_data), - "::", - stringify!(payload_size) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).key_frame as *const _ - as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vea_processed_output_buffer_event_data), - "::", - stringify!(key_frame) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).timestamp as *const _ - as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(vea_processed_output_buffer_event_data), - "::", - stringify!(timestamp) - ) - ); -} pub type vea_processed_output_buffer_event_data_t = vea_processed_output_buffer_event_data; #[repr(C)] #[derive(Copy, Clone)] @@ -579,77 +150,15 @@ pub union vea_event_data { pub processed_output_buffer: vea_processed_output_buffer_event_data_t, pub flush_done: u8, pub error: vea_error_t, - _bindgen_union_align: [u64; 3usize], } -#[test] -fn bindgen_test_layout_vea_event_data() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(vea_event_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(vea_event_data)) - ); - assert_eq!( +impl Default for vea_event_data { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).require_input_buffers as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_event_data), - "::", - stringify!(require_input_buffers) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).processed_input_buffer_id as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_event_data), - "::", - stringify!(processed_input_buffer_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).processed_output_buffer as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_event_data), - "::", - stringify!(processed_output_buffer) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flush_done as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_event_data), - "::", - stringify!(flush_done) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).error as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_event_data), - "::", - stringify!(error) - ) - ); + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vea_event_data_t = vea_event_data; #[repr(C)] @@ -658,38 +167,14 @@ pub struct vea_event { pub event_type: vea_event_type_t, pub event_data: vea_event_data_t, } -#[test] -fn bindgen_test_layout_vea_event() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(vea_event)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(vea_event)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).event_type as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(vea_event), - "::", - stringify!(event_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).event_data as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(vea_event), - "::", - stringify!(event_data) - ) - ); +impl Default for vea_event { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } pub type vea_event_t = vea_event; extern "C" { diff --git a/tools/bindgen-all-the-things b/tools/bindgen-all-the-things index fefd1abfa7..7eb9d52a9c 100755 --- a/tools/bindgen-all-the-things +++ b/tools/bindgen-all-the-things @@ -23,6 +23,7 @@ dirs=( devices/src/virtio/gpu kernel_loader kvm_sys + libvda ) for d in "${dirs[@]}"; do