diff --git a/devices/src/virtio/gpu/bindgen.sh b/devices/src/virtio/gpu/bindgen.sh new file mode 100755 index 0000000000..7c1dbad7ce --- /dev/null +++ b/devices/src/virtio/gpu/bindgen.sh @@ -0,0 +1,18 @@ +#!/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 virtio-gpu udmabuf bindgen bindings. + +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." + +source tools/impl/bindgen-common.sh + +bindgen_generate \ + --allowlist-type='udmabuf_.*' \ + --allowlist-var="UDMABUF_.*" \ + "${BINDGEN_LINUX}/include/uapi/linux/udmabuf.h" \ + | replace_linux_int_types | rustfmt \ + > devices/src/virtio/gpu/udmabuf_bindings.rs diff --git a/devices/src/virtio/gpu/udmabuf_bindings.rs b/devices/src/virtio/gpu/udmabuf_bindings.rs index dcd89a6f5e..5e172ea432 100644 --- a/devices/src/virtio/gpu/udmabuf_bindings.rs +++ b/devices/src/virtio/gpu/udmabuf_bindings.rs @@ -1,29 +1,25 @@ -// Copyright 2021 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, though the exact command remains - * lost to history. Should be easy to duplicate, if needed. - */ - -#![allow(dead_code)] +#![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] #[repr(C)] #[derive(Default)] pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); impl __IncompleteArrayField { #[inline] - pub fn new() -> Self { + pub const fn new() -> Self { __IncompleteArrayField(::std::marker::PhantomData, []) } #[inline] - pub unsafe fn as_ptr(&self) -> *const T { - ::std::mem::transmute(self) + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T } #[inline] - pub unsafe fn as_mut_ptr(&mut self) -> *mut T { - ::std::mem::transmute(self) + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { @@ -39,36 +35,27 @@ impl ::std::fmt::Debug for __IncompleteArrayField { fmt.write_str("__IncompleteArrayField") } } -impl ::std::clone::Clone for __IncompleteArrayField { - #[inline] - fn clone(&self) -> Self { - Self::new() - } -} pub const UDMABUF_FLAGS_CLOEXEC: u32 = 1; -pub type __u32 = ::std::os::raw::c_uint; -pub type __u64 = ::std::os::raw::c_ulonglong; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct udmabuf_create { - pub memfd: __u32, - pub flags: __u32, - pub offset: __u64, - pub size: __u64, + pub memfd: u32, + pub flags: u32, + pub offset: u64, + pub size: u64, } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct udmabuf_create_item { - pub memfd: __u32, - pub __pad: __u32, - pub offset: __u64, - pub size: __u64, + pub memfd: u32, + pub __pad: u32, + pub offset: u64, + pub size: u64, } #[repr(C)] -#[repr(align(8))] #[derive(Debug, Default)] pub struct udmabuf_create_list { - pub flags: __u32, - pub count: __u32, + pub flags: u32, + pub count: u32, pub list: __IncompleteArrayField, } diff --git a/tools/bindgen-all-the-things b/tools/bindgen-all-the-things index 71e54a0ec4..f933cd07bf 100755 --- a/tools/bindgen-all-the-things +++ b/tools/bindgen-all-the-things @@ -20,6 +20,7 @@ die() { dirs=( common/io_uring + devices/src/virtio/gpu ) for d in "${dirs[@]}"; do