Skip to content

Commit 99317a4

Browse files
b92paulChromeos LUCI
authored and
Chromeos LUCI
committed
sof_sys: Regenerate bindings with correct packed address lookup
bindgen is using addr_of! instead of "reference first and convert to pointer later" since rust-lang/rust-bindgen#2203. Regenerate bindings.rs with bindgen 0.63.0. BUG=b:239850356 TEST=cargo clippy Change-Id: Id4f6f4c0ccbf222de27cd35d42dbdda7958dac2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/4570362 Commit-Queue: Chih-Yang Hsia <[email protected]> Tested-by: [email protected] <[email protected]> Tested-by: ChromeOS Audio Quick Verifier <[email protected]> Tested-by: Chih-Yang Hsia <[email protected]> Reviewed-by: Li-Yu Yu <[email protected]>
1 parent 09547c1 commit 99317a4

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

sof_sys/generator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ name = "generator"
33
version = "0.1.0"
44
authors = ["The ChromiumOS Authors"]
55
[dependencies]
6-
bindgen = "0.59.2"
6+
bindgen = "0.63.0"

sof_sys/src/bindings.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* ipc/control.h
88
*/
99

10-
/* automatically generated by rust-bindgen 0.59.2 */
10+
/* automatically generated by rust-bindgen 0.63.0 */
1111

1212
#[repr(C)]
1313
#[derive(Default)]
@@ -39,14 +39,7 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3939
fmt.write_str("__IncompleteArrayField")
4040
}
4141
}
42-
pub type __uint32_t = ::std::os::raw::c_uint;
43-
#[doc = " \\brief Header for all non IPC ABI data."]
44-
#[doc = ""]
45-
#[doc = " Identifies data type, size and ABI."]
46-
#[doc = " Data header used for all component data structures and binary blobs sent to"]
47-
#[doc = " firmware as runtime data. This data is typically sent by userspace"]
48-
#[doc = " applications and tunnelled through any OS kernel (via binary kcontrol on"]
49-
#[doc = " Linux) to the firmware."]
42+
#[doc = " \\brief Header for all non IPC ABI data.\n\n Identifies data type, size and ABI.\n Data header used for all component data structures and binary blobs sent to\n firmware as runtime data. This data is typically sent by userspace\n applications and tunnelled through any OS kernel (via binary kcontrol on\n Linux) to the firmware."]
5043
#[repr(C, packed)]
5144
pub struct sof_abi_hdr {
5245
#[doc = "< 'S', 'O', 'F', '\\0'"]
@@ -64,6 +57,8 @@ pub struct sof_abi_hdr {
6457
}
6558
#[test]
6659
fn bindgen_test_layout_sof_abi_hdr() {
60+
const UNINIT: ::std::mem::MaybeUninit<sof_abi_hdr> = ::std::mem::MaybeUninit::uninit();
61+
let ptr = UNINIT.as_ptr();
6762
assert_eq!(
6863
::std::mem::size_of::<sof_abi_hdr>(),
6964
32usize,
@@ -75,7 +70,7 @@ fn bindgen_test_layout_sof_abi_hdr() {
7570
concat!("Alignment of ", stringify!(sof_abi_hdr))
7671
);
7772
assert_eq!(
78-
unsafe { &(*(::std::ptr::null::<sof_abi_hdr>())).magic as *const _ as usize },
73+
unsafe { ::std::ptr::addr_of!((*ptr).magic) as usize - ptr as usize },
7974
0usize,
8075
concat!(
8176
"Offset of field: ",
@@ -85,7 +80,7 @@ fn bindgen_test_layout_sof_abi_hdr() {
8580
)
8681
);
8782
assert_eq!(
88-
unsafe { &(*(::std::ptr::null::<sof_abi_hdr>())).type_ as *const _ as usize },
83+
unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize },
8984
4usize,
9085
concat!(
9186
"Offset of field: ",
@@ -95,7 +90,7 @@ fn bindgen_test_layout_sof_abi_hdr() {
9590
)
9691
);
9792
assert_eq!(
98-
unsafe { &(*(::std::ptr::null::<sof_abi_hdr>())).size as *const _ as usize },
93+
unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize },
9994
8usize,
10095
concat!(
10196
"Offset of field: ",
@@ -105,7 +100,7 @@ fn bindgen_test_layout_sof_abi_hdr() {
105100
)
106101
);
107102
assert_eq!(
108-
unsafe { &(*(::std::ptr::null::<sof_abi_hdr>())).abi as *const _ as usize },
103+
unsafe { ::std::ptr::addr_of!((*ptr).abi) as usize - ptr as usize },
109104
12usize,
110105
concat!(
111106
"Offset of field: ",
@@ -115,7 +110,7 @@ fn bindgen_test_layout_sof_abi_hdr() {
115110
)
116111
);
117112
assert_eq!(
118-
unsafe { &(*(::std::ptr::null::<sof_abi_hdr>())).reserved as *const _ as usize },
113+
unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize },
119114
16usize,
120115
concat!(
121116
"Offset of field: ",
@@ -125,7 +120,7 @@ fn bindgen_test_layout_sof_abi_hdr() {
125120
)
126121
);
127122
assert_eq!(
128-
unsafe { &(*(::std::ptr::null::<sof_abi_hdr>())).data as *const _ as usize },
123+
unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize },
129124
32usize,
130125
concat!(
131126
"Offset of field: ",

sof_sys/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#![allow(non_upper_case_globals)]
77
#![allow(non_camel_case_types)]
88
#![allow(non_snake_case)]
9-
// FIXME: See b/239850356.
10-
// This should be removed when that bug is fixed.
11-
#![warn(unaligned_references)]
129

1310
pub mod bindings;
1411
#[allow(unused_imports)]

0 commit comments

Comments
 (0)