diff --git a/CHANGELOG.md b/CHANGELOG.md index 74cc48f6..637df135 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Unreleased + +## Fixed +- [[#130]](https://github.com/rust-vmm/linux-loader/issues/130) Generate bindings + to fix unaligned references in unit tests. + # [v0.9.0] ## Fixed diff --git a/rust-vmm-ci b/rust-vmm-ci index 8627b376..285971e8 160000 --- a/rust-vmm-ci +++ b/rust-vmm-ci @@ -1 +1 @@ -Subproject commit 8627b3766b2bedde4657c7e9ddfc6f95a20e6942 +Subproject commit 285971e8c716512d6e35ac47a009a49fc3c75660 diff --git a/src/loader_gen/mod.rs b/src/loader_gen/mod.rs index 9c25130f..31010c71 100644 --- a/src/loader_gen/mod.rs +++ b/src/loader_gen/mod.rs @@ -10,8 +10,6 @@ //! Bindgen autogenerated structs for boot parameters. #![cfg(any(target_arch = "x86", target_arch = "x86_64"))] -// Keep this until https://github.com/rust-lang/rust-bindgen/issues/1651 is fixed. -#![cfg_attr(test, allow(deref_nullptr, unaligned_references))] mod x86_64; pub use x86_64::*; diff --git a/src/loader_gen/x86_64/bootparam.rs b/src/loader_gen/x86_64/bootparam.rs index 7808192f..12921cdc 100644 --- a/src/loader_gen/x86_64/bootparam.rs +++ b/src/loader_gen/x86_64/bootparam.rs @@ -8,9 +8,9 @@ // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause /* - * automatically generated by rust-bindgen - * From upstream linux bootparam.h at commit: - * 0ecfebd2b52404ae0c54a878c872bb93363ada36 + * automatically generated by rust-bindgen 0.65.1 * + * From upstream linux arch/x86/include/uapi/asm/bootparam.h at commit: + * 48b1320a674e1ff5de2fad8606bee38f724594dc */ #[repr(C)] @@ -22,12 +22,12 @@ impl __IncompleteArrayField { __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] { @@ -43,12 +43,6 @@ 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 SETUP_NONE: u32 = 0; pub const SETUP_E820_EXT: u32 = 1; pub const SETUP_DTB: u32 = 2; @@ -56,6 +50,12 @@ pub const SETUP_PCI: u32 = 3; pub const SETUP_EFI: u32 = 4; pub const SETUP_APPLE_PROPERTIES: u32 = 5; pub const SETUP_JAILHOUSE: u32 = 6; +pub const SETUP_CC_BLOB: u32 = 7; +pub const SETUP_IMA: u32 = 8; +pub const SETUP_RNG_SEED: u32 = 9; +pub const SETUP_ENUM_MAX: u32 = 9; +pub const SETUP_INDIRECT: u32 = 2147483648; +pub const SETUP_TYPE_MAX: u32 = 2147483657; pub const RAMDISK_IMAGE_START_MASK: u32 = 2047; pub const RAMDISK_PROMPT_FLAG: u32 = 32768; pub const RAMDISK_LOAD_FLAG: u32 = 16384; @@ -69,6 +69,8 @@ pub const XLF_CAN_BE_LOADED_ABOVE_4G: u32 = 2; pub const XLF_EFI_HANDOVER_32: u32 = 4; pub const XLF_EFI_HANDOVER_64: u32 = 8; pub const XLF_EFI_KEXEC: u32 = 16; +pub const XLF_5LEVEL: u32 = 32; +pub const XLF_5LEVEL_ENABLED: u32 = 64; pub const __BITS_PER_LONG: u32 = 64; pub const __FD_SETSIZE: u32 = 1024; pub const VIDEO_TYPE_MDA: u32 = 16; @@ -217,6 +219,8 @@ pub struct __kernel_fd_set { } #[test] fn bindgen_test_layout___kernel_fd_set() { + const UNINIT: ::std::mem::MaybeUninit<__kernel_fd_set> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<__kernel_fd_set>(), 128usize, @@ -228,7 +232,7 @@ fn bindgen_test_layout___kernel_fd_set() { concat!("Alignment of ", stringify!(__kernel_fd_set)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::<__kernel_fd_set>())).fds_bits as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fds_bits) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -267,6 +271,8 @@ pub struct __kernel_fsid_t { } #[test] fn bindgen_test_layout___kernel_fsid_t() { + const UNINIT: ::std::mem::MaybeUninit<__kernel_fsid_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<__kernel_fsid_t>(), 8usize, @@ -278,7 +284,7 @@ fn bindgen_test_layout___kernel_fsid_t() { concat!("Alignment of ", stringify!(__kernel_fsid_t)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::<__kernel_fsid_t>())).val as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).val) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -290,6 +296,7 @@ fn bindgen_test_layout___kernel_fsid_t() { } pub type __kernel_off_t = __kernel_long_t; pub type __kernel_loff_t = ::std::os::raw::c_longlong; +pub type __kernel_old_time_t = __kernel_long_t; pub type __kernel_time_t = __kernel_long_t; pub type __kernel_time64_t = ::std::os::raw::c_longlong; pub type __kernel_clock_t = __kernel_long_t; @@ -349,6 +356,8 @@ pub struct screen_info { } #[test] fn bindgen_test_layout_screen_info() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 64usize, @@ -360,7 +369,7 @@ fn bindgen_test_layout_screen_info() { concat!("Alignment of ", stringify!(screen_info)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).orig_x as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).orig_x) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -370,7 +379,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).orig_y as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).orig_y) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -380,7 +389,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_mem_k as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_mem_k) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -390,7 +399,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).orig_video_page as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).orig_video_page) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -400,7 +409,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).orig_video_mode as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).orig_video_mode) as usize - ptr as usize }, 6usize, concat!( "Offset of field: ", @@ -410,7 +419,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).orig_video_cols as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).orig_video_cols) as usize - ptr as usize }, 7usize, concat!( "Offset of field: ", @@ -420,7 +429,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -430,7 +439,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).unused2 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).unused2) as usize - ptr as usize }, 9usize, concat!( "Offset of field: ", @@ -440,7 +449,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).orig_video_ega_bx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).orig_video_ega_bx) as usize - ptr as usize }, 10usize, concat!( "Offset of field: ", @@ -450,7 +459,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).unused3 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).unused3) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -460,7 +469,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).orig_video_lines as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).orig_video_lines) as usize - ptr as usize }, 14usize, concat!( "Offset of field: ", @@ -470,7 +479,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).orig_video_isVGA as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).orig_video_isVGA) as usize - ptr as usize }, 15usize, concat!( "Offset of field: ", @@ -480,7 +489,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).orig_video_points as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).orig_video_points) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -490,7 +499,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).lfb_width as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).lfb_width) as usize - ptr as usize }, 18usize, concat!( "Offset of field: ", @@ -500,7 +509,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).lfb_height as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).lfb_height) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -510,7 +519,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).lfb_depth as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).lfb_depth) as usize - ptr as usize }, 22usize, concat!( "Offset of field: ", @@ -520,7 +529,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).lfb_base as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).lfb_base) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -530,7 +539,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).lfb_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).lfb_size) as usize - ptr as usize }, 28usize, concat!( "Offset of field: ", @@ -540,7 +549,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cl_magic as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cl_magic) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -550,7 +559,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cl_offset as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cl_offset) as usize - ptr as usize }, 34usize, concat!( "Offset of field: ", @@ -560,7 +569,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).lfb_linelength as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).lfb_linelength) as usize - ptr as usize }, 36usize, concat!( "Offset of field: ", @@ -570,7 +579,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).red_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).red_size) as usize - ptr as usize }, 38usize, concat!( "Offset of field: ", @@ -580,7 +589,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).red_pos as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).red_pos) as usize - ptr as usize }, 39usize, concat!( "Offset of field: ", @@ -590,7 +599,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).green_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).green_size) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -600,7 +609,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).green_pos as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).green_pos) as usize - ptr as usize }, 41usize, concat!( "Offset of field: ", @@ -610,7 +619,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).blue_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).blue_size) as usize - ptr as usize }, 42usize, concat!( "Offset of field: ", @@ -620,7 +629,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).blue_pos as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).blue_pos) as usize - ptr as usize }, 43usize, concat!( "Offset of field: ", @@ -630,7 +639,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsvd_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rsvd_size) as usize - ptr as usize }, 44usize, concat!( "Offset of field: ", @@ -640,7 +649,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsvd_pos as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rsvd_pos) as usize - ptr as usize }, 45usize, concat!( "Offset of field: ", @@ -650,7 +659,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vesapm_seg as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).vesapm_seg) as usize - ptr as usize }, 46usize, concat!( "Offset of field: ", @@ -660,7 +669,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vesapm_off as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).vesapm_off) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -670,7 +679,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pages as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pages) as usize - ptr as usize }, 50usize, concat!( "Offset of field: ", @@ -680,7 +689,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vesa_attributes as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).vesa_attributes) as usize - ptr as usize }, 52usize, concat!( "Offset of field: ", @@ -690,7 +699,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).capabilities as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).capabilities) as usize - ptr as usize }, 54usize, concat!( "Offset of field: ", @@ -700,7 +709,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_lfb_base as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_lfb_base) as usize - ptr as usize }, 58usize, concat!( "Offset of field: ", @@ -710,7 +719,7 @@ fn bindgen_test_layout_screen_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._reserved) as usize - ptr as usize }, 62usize, concat!( "Offset of field: ", @@ -737,6 +746,8 @@ pub struct apm_bios_info { } #[test] fn bindgen_test_layout_apm_bios_info() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 20usize, @@ -748,7 +759,7 @@ fn bindgen_test_layout_apm_bios_info() { concat!("Alignment of ", stringify!(apm_bios_info)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).version as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -758,7 +769,7 @@ fn bindgen_test_layout_apm_bios_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cseg as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cseg) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -768,7 +779,7 @@ fn bindgen_test_layout_apm_bios_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -778,7 +789,7 @@ fn bindgen_test_layout_apm_bios_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cseg_16 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cseg_16) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -788,7 +799,7 @@ fn bindgen_test_layout_apm_bios_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dseg as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dseg) as usize - ptr as usize }, 10usize, concat!( "Offset of field: ", @@ -798,7 +809,7 @@ fn bindgen_test_layout_apm_bios_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -808,7 +819,7 @@ fn bindgen_test_layout_apm_bios_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cseg_len as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cseg_len) as usize - ptr as usize }, 14usize, concat!( "Offset of field: ", @@ -818,7 +829,7 @@ fn bindgen_test_layout_apm_bios_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cseg_16_len as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cseg_16_len) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -828,7 +839,7 @@ fn bindgen_test_layout_apm_bios_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dseg_len as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dseg_len) as usize - ptr as usize }, 18usize, concat!( "Offset of field: ", @@ -869,7 +880,6 @@ pub union edd_device_params__bindgen_ty_1 { pub xprs: edd_device_params__bindgen_ty_1__bindgen_ty_4, pub htpt: edd_device_params__bindgen_ty_1__bindgen_ty_5, pub unknown: edd_device_params__bindgen_ty_1__bindgen_ty_6, - _bindgen_union_align: [u8; 8usize], } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -880,6 +890,9 @@ pub struct edd_device_params__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -897,10 +910,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).base_address - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).base_address) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -910,10 +920,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved1 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -923,10 +930,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved2 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -947,6 +951,9 @@ pub struct edd_device_params__bindgen_ty_1__bindgen_ty_2 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -964,10 +971,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).bus - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).bus) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -977,10 +981,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).slot - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -990,10 +991,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).function - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).function) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -1003,10 +1001,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).channel - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).channel) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -1016,10 +1011,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1036,6 +1028,9 @@ pub struct edd_device_params__bindgen_ty_1__bindgen_ty_3 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1053,10 +1048,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1073,6 +1065,9 @@ pub struct edd_device_params__bindgen_ty_1__bindgen_ty_4 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_4() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1090,10 +1085,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1110,6 +1102,9 @@ pub struct edd_device_params__bindgen_ty_1__bindgen_ty_5 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_5() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1127,10 +1122,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_5() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1147,6 +1139,9 @@ pub struct edd_device_params__bindgen_ty_1__bindgen_ty_6 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_6() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1164,10 +1159,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_6() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1179,6 +1171,9 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_6() { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1190,9 +1185,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1() { concat!("Alignment of ", stringify!(edd_device_params__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).isa as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).isa) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1202,9 +1195,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pci as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pci) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1214,9 +1205,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ibnd as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ibnd) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1226,9 +1215,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).xprs as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).xprs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1238,9 +1225,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).htpt as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).htpt) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1250,9 +1235,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).unknown as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).unknown) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1264,7 +1247,11 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_1() { } impl Default for edd_device_params__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1280,7 +1267,6 @@ pub union edd_device_params__bindgen_ty_2 { pub raid: edd_device_params__bindgen_ty_2__bindgen_ty_8, pub sata: edd_device_params__bindgen_ty_2__bindgen_ty_9, pub unknown: edd_device_params__bindgen_ty_2__bindgen_ty_10, - _bindgen_union_align: [u8; 16usize], } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -1293,6 +1279,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_1 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1310,10 +1299,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).device - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1323,10 +1309,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved1 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -1336,10 +1319,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved2 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -1349,10 +1329,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved3 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved3) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1362,10 +1339,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved4 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved4) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1387,6 +1361,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_2 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1404,10 +1381,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).device - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1417,10 +1391,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).lun - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -1430,10 +1401,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved1 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -1443,10 +1411,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved2 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -1456,10 +1421,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved3 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved3) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1469,10 +1431,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved4 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved4) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1492,6 +1451,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_3 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1509,10 +1471,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).id as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1522,10 +1481,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).lun - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -1535,10 +1491,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved1 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, 10usize, concat!( "Offset of field: ", @@ -1548,10 +1501,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved2 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -1569,6 +1519,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_4 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_4() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1586,10 +1539,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).serial_number - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).serial_number) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1599,10 +1549,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1620,6 +1567,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_5 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_5() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1637,10 +1587,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_5() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).eui - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).eui) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1650,10 +1597,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_5() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1671,6 +1615,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_6 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_6() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1688,10 +1635,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_6() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).wwid - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).wwid) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1701,10 +1645,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_6() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).lun - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1722,6 +1663,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_7 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_7() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1739,10 +1683,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_7() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).identity_tag - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).identity_tag) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1752,10 +1693,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_7() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1774,6 +1712,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_8 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_8() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1791,10 +1732,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_8() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).array_number - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).array_number) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1804,10 +1742,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_8() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved1 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1817,10 +1752,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_8() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved2 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1841,6 +1773,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_9 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_9() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1858,10 +1793,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_9() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).device - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1871,10 +1803,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_9() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved1 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -1884,10 +1813,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_9() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved2 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -1897,10 +1823,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_9() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved3 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved3) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1910,10 +1833,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_9() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved4 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved4) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1931,6 +1851,9 @@ pub struct edd_device_params__bindgen_ty_2__bindgen_ty_10 { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_10() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1948,10 +1871,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_10() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved1 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1961,10 +1881,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_10() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved2 - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1976,6 +1893,9 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_10() { } #[test] fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1987,9 +1907,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { concat!("Alignment of ", stringify!(edd_device_params__bindgen_ty_2)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ata as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ata) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1999,9 +1917,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).atapi as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).atapi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2011,9 +1927,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).scsi as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).scsi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2023,9 +1937,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).usb as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).usb) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2035,9 +1947,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).i1394 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).i1394) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2047,9 +1957,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fibre as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).fibre) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2059,9 +1967,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).i2o as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).i2o) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2071,9 +1977,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).raid as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).raid) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2083,9 +1987,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sata as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).sata) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2095,9 +1997,7 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).unknown as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).unknown) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2109,11 +2009,17 @@ fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { } impl Default for edd_device_params__bindgen_ty_2 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] fn bindgen_test_layout_edd_device_params() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 74usize, @@ -2125,7 +2031,7 @@ fn bindgen_test_layout_edd_device_params() { concat!("Alignment of ", stringify!(edd_device_params)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2135,7 +2041,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).info_flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).info_flags) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -2145,9 +2051,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).num_default_cylinders as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).num_default_cylinders) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2157,9 +2061,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).num_default_heads as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).num_default_heads) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2169,9 +2071,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sectors_per_track as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).sectors_per_track) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -2181,9 +2081,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).number_of_sectors as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).number_of_sectors) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2193,9 +2091,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).bytes_per_sector as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).bytes_per_sector) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -2205,7 +2101,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dpte_ptr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dpte_ptr) as usize - ptr as usize }, 26usize, concat!( "Offset of field: ", @@ -2215,7 +2111,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).key as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).key) as usize - ptr as usize }, 30usize, concat!( "Offset of field: ", @@ -2225,10 +2121,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).device_path_info_length as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).device_path_info_length) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -2238,7 +2131,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved2 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, 33usize, concat!( "Offset of field: ", @@ -2248,7 +2141,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved3 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved3) as usize - ptr as usize }, 34usize, concat!( "Offset of field: ", @@ -2258,7 +2151,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).host_bus_type as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).host_bus_type) as usize - ptr as usize }, 36usize, concat!( "Offset of field: ", @@ -2268,9 +2161,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).interface_type as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).interface_type) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -2280,9 +2171,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).interface_path as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).interface_path) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -2292,7 +2181,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).device_path as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).device_path) as usize - ptr as usize }, 56usize, concat!( "Offset of field: ", @@ -2302,7 +2191,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved4 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved4) as usize - ptr as usize }, 72usize, concat!( "Offset of field: ", @@ -2312,7 +2201,7 @@ fn bindgen_test_layout_edd_device_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).checksum as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).checksum) as usize - ptr as usize }, 73usize, concat!( "Offset of field: ", @@ -2324,7 +2213,11 @@ fn bindgen_test_layout_edd_device_params() { } impl Default for edd_device_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C, packed)] @@ -2340,6 +2233,8 @@ pub struct edd_info { } #[test] fn bindgen_test_layout_edd_info() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 82usize, @@ -2351,7 +2246,7 @@ fn bindgen_test_layout_edd_info() { concat!("Alignment of ", stringify!(edd_info)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).device as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2361,7 +2256,7 @@ fn bindgen_test_layout_edd_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).version as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -2371,7 +2266,7 @@ fn bindgen_test_layout_edd_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).interface_support as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).interface_support) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -2381,7 +2276,7 @@ fn bindgen_test_layout_edd_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).legacy_max_cylinder as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).legacy_max_cylinder) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2391,7 +2286,7 @@ fn bindgen_test_layout_edd_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).legacy_max_head as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).legacy_max_head) as usize - ptr as usize }, 6usize, concat!( "Offset of field: ", @@ -2401,9 +2296,7 @@ fn bindgen_test_layout_edd_info() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).legacy_sectors_per_track as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).legacy_sectors_per_track) as usize - ptr as usize }, 7usize, concat!( "Offset of field: ", @@ -2413,7 +2306,7 @@ fn bindgen_test_layout_edd_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).params as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2425,7 +2318,11 @@ fn bindgen_test_layout_edd_info() { } impl Default for edd_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -2438,6 +2335,8 @@ pub struct edd { } #[test] fn bindgen_test_layout_edd() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 560usize, @@ -2449,7 +2348,7 @@ fn bindgen_test_layout_edd() { concat!("Alignment of ", stringify!(edd)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mbr_signature as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).mbr_signature) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2459,7 +2358,7 @@ fn bindgen_test_layout_edd() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).edd_info as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).edd_info) as usize - ptr as usize }, 64usize, concat!( "Offset of field: ", @@ -2469,7 +2368,7 @@ fn bindgen_test_layout_edd() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mbr_signature_nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).mbr_signature_nr) as usize - ptr as usize }, 556usize, concat!( "Offset of field: ", @@ -2479,7 +2378,7 @@ fn bindgen_test_layout_edd() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).edd_info_nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).edd_info_nr) as usize - ptr as usize }, 557usize, concat!( "Offset of field: ", @@ -2491,7 +2390,11 @@ fn bindgen_test_layout_edd() { } impl Default for edd { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -2504,6 +2407,8 @@ pub struct ist_info { } #[test] fn bindgen_test_layout_ist_info() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -2515,7 +2420,7 @@ fn bindgen_test_layout_ist_info() { concat!("Alignment of ", stringify!(ist_info)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).signature as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).signature) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2525,7 +2430,7 @@ fn bindgen_test_layout_ist_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).command as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).command) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2535,7 +2440,7 @@ fn bindgen_test_layout_ist_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).event as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).event) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2545,7 +2450,7 @@ fn bindgen_test_layout_ist_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).perf_level as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).perf_level) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -2556,12 +2461,14 @@ fn bindgen_test_layout_ist_info() { ); } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct edid_info { pub dummy: [::std::os::raw::c_uchar; 128usize], } #[test] fn bindgen_test_layout_edid_info() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 128usize, @@ -2573,7 +2480,7 @@ fn bindgen_test_layout_edid_info() { concat!("Alignment of ", stringify!(edid_info)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dummy as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dummy) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2585,7 +2492,11 @@ fn bindgen_test_layout_edid_info() { } impl Default for edid_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -2598,6 +2509,8 @@ pub struct setup_data { } #[test] fn bindgen_test_layout_setup_data() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -2609,7 +2522,7 @@ fn bindgen_test_layout_setup_data() { concat!("Alignment of ", stringify!(setup_data)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2619,7 +2532,7 @@ fn bindgen_test_layout_setup_data() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2629,7 +2542,7 @@ fn bindgen_test_layout_setup_data() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -2639,7 +2552,7 @@ fn bindgen_test_layout_setup_data() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2649,6 +2562,69 @@ fn bindgen_test_layout_setup_data() { ) ); } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct setup_indirect { + pub type_: __u32, + pub reserved: __u32, + pub len: __u64, + pub addr: __u64, +} +#[test] +fn bindgen_test_layout_setup_indirect() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(setup_indirect)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(setup_indirect)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(setup_indirect), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(setup_indirect), + "::", + stringify!(reserved) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(setup_indirect), + "::", + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(setup_indirect), + "::", + stringify!(addr) + ) + ); +} #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct setup_header { @@ -2690,12 +2666,15 @@ pub struct setup_header { pub pref_address: __u64, pub init_size: __u32, pub handover_offset: __u32, + pub kernel_info_offset: __u32, } #[test] fn bindgen_test_layout_setup_header() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 119usize, + 123usize, concat!("Size of: ", stringify!(setup_header)) ); assert_eq!( @@ -2704,7 +2683,7 @@ fn bindgen_test_layout_setup_header() { concat!("Alignment of ", stringify!(setup_header)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).setup_sects as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).setup_sects) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2714,7 +2693,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).root_flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).root_flags) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -2724,7 +2703,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).syssize as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).syssize) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -2734,7 +2713,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ram_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ram_size) as usize - ptr as usize }, 7usize, concat!( "Offset of field: ", @@ -2744,7 +2723,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vid_mode as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).vid_mode) as usize - ptr as usize }, 9usize, concat!( "Offset of field: ", @@ -2754,7 +2733,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).root_dev as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).root_dev) as usize - ptr as usize }, 11usize, concat!( "Offset of field: ", @@ -2764,7 +2743,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).boot_flag as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).boot_flag) as usize - ptr as usize }, 13usize, concat!( "Offset of field: ", @@ -2774,7 +2753,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).jump as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).jump) as usize - ptr as usize }, 15usize, concat!( "Offset of field: ", @@ -2784,7 +2763,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).header as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).header) as usize - ptr as usize }, 17usize, concat!( "Offset of field: ", @@ -2794,7 +2773,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).version as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, 21usize, concat!( "Offset of field: ", @@ -2804,7 +2783,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).realmode_swtch as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).realmode_swtch) as usize - ptr as usize }, 23usize, concat!( "Offset of field: ", @@ -2814,7 +2793,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).start_sys_seg as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).start_sys_seg) as usize - ptr as usize }, 27usize, concat!( "Offset of field: ", @@ -2824,7 +2803,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).kernel_version as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).kernel_version) as usize - ptr as usize }, 29usize, concat!( "Offset of field: ", @@ -2834,7 +2813,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_of_loader as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_of_loader) as usize - ptr as usize }, 31usize, concat!( "Offset of field: ", @@ -2844,7 +2823,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).loadflags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).loadflags) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -2854,7 +2833,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).setup_move_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).setup_move_size) as usize - ptr as usize }, 33usize, concat!( "Offset of field: ", @@ -2864,7 +2843,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).code32_start as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).code32_start) as usize - ptr as usize }, 35usize, concat!( "Offset of field: ", @@ -2874,7 +2853,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ramdisk_image as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ramdisk_image) as usize - ptr as usize }, 39usize, concat!( "Offset of field: ", @@ -2884,7 +2863,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ramdisk_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ramdisk_size) as usize - ptr as usize }, 43usize, concat!( "Offset of field: ", @@ -2894,7 +2873,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).bootsect_kludge as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).bootsect_kludge) as usize - ptr as usize }, 47usize, concat!( "Offset of field: ", @@ -2904,7 +2883,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).heap_end_ptr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).heap_end_ptr) as usize - ptr as usize }, 51usize, concat!( "Offset of field: ", @@ -2914,7 +2893,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_loader_ver as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_loader_ver) as usize - ptr as usize }, 53usize, concat!( "Offset of field: ", @@ -2924,7 +2903,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_loader_type as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_loader_type) as usize - ptr as usize }, 54usize, concat!( "Offset of field: ", @@ -2934,7 +2913,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cmd_line_ptr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cmd_line_ptr) as usize - ptr as usize }, 55usize, concat!( "Offset of field: ", @@ -2944,7 +2923,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).initrd_addr_max as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).initrd_addr_max) as usize - ptr as usize }, 59usize, concat!( "Offset of field: ", @@ -2954,7 +2933,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).kernel_alignment as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).kernel_alignment) as usize - ptr as usize }, 63usize, concat!( "Offset of field: ", @@ -2964,7 +2943,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).relocatable_kernel as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).relocatable_kernel) as usize - ptr as usize }, 67usize, concat!( "Offset of field: ", @@ -2974,7 +2953,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).min_alignment as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).min_alignment) as usize - ptr as usize }, 68usize, concat!( "Offset of field: ", @@ -2984,7 +2963,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).xloadflags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).xloadflags) as usize - ptr as usize }, 69usize, concat!( "Offset of field: ", @@ -2994,7 +2973,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cmdline_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cmdline_size) as usize - ptr as usize }, 71usize, concat!( "Offset of field: ", @@ -3004,7 +2983,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hardware_subarch as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).hardware_subarch) as usize - ptr as usize }, 75usize, concat!( "Offset of field: ", @@ -3014,9 +2993,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hardware_subarch_data as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hardware_subarch_data) as usize - ptr as usize }, 79usize, concat!( "Offset of field: ", @@ -3026,7 +3003,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).payload_offset as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).payload_offset) as usize - ptr as usize }, 87usize, concat!( "Offset of field: ", @@ -3036,7 +3013,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).payload_length as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).payload_length) as usize - ptr as usize }, 91usize, concat!( "Offset of field: ", @@ -3046,7 +3023,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).setup_data as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).setup_data) as usize - ptr as usize }, 95usize, concat!( "Offset of field: ", @@ -3056,7 +3033,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pref_address as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pref_address) as usize - ptr as usize }, 103usize, concat!( "Offset of field: ", @@ -3066,7 +3043,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).init_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).init_size) as usize - ptr as usize }, 111usize, concat!( "Offset of field: ", @@ -3076,7 +3053,7 @@ fn bindgen_test_layout_setup_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).handover_offset as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).handover_offset) as usize - ptr as usize }, 115usize, concat!( "Offset of field: ", @@ -3085,6 +3062,16 @@ fn bindgen_test_layout_setup_header() { stringify!(handover_offset) ) ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kernel_info_offset) as usize - ptr as usize }, + 119usize, + concat!( + "Offset of field: ", + stringify!(setup_header), + "::", + stringify!(kernel_info_offset) + ) + ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -3094,6 +3081,8 @@ pub struct sys_desc_table { } #[test] fn bindgen_test_layout_sys_desc_table() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -3105,7 +3094,7 @@ fn bindgen_test_layout_sys_desc_table() { concat!("Alignment of ", stringify!(sys_desc_table)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3115,7 +3104,7 @@ fn bindgen_test_layout_sys_desc_table() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).table as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).table) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -3135,6 +3124,8 @@ pub struct olpc_ofw_header { } #[test] fn bindgen_test_layout_olpc_ofw_header() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -3146,7 +3137,7 @@ fn bindgen_test_layout_olpc_ofw_header() { concat!("Alignment of ", stringify!(olpc_ofw_header)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ofw_magic as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ofw_magic) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3156,7 +3147,7 @@ fn bindgen_test_layout_olpc_ofw_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ofw_version as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ofw_version) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -3166,7 +3157,7 @@ fn bindgen_test_layout_olpc_ofw_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cif_handler as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cif_handler) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3176,7 +3167,7 @@ fn bindgen_test_layout_olpc_ofw_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).irq_desc_table as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).irq_desc_table) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -3200,6 +3191,8 @@ pub struct efi_info { } #[test] fn bindgen_test_layout_efi_info() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -3211,7 +3204,7 @@ fn bindgen_test_layout_efi_info() { concat!("Alignment of ", stringify!(efi_info)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efi_loader_signature as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efi_loader_signature) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3221,7 +3214,7 @@ fn bindgen_test_layout_efi_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efi_systab as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efi_systab) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -3231,7 +3224,7 @@ fn bindgen_test_layout_efi_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efi_memdesc_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efi_memdesc_size) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3241,7 +3234,7 @@ fn bindgen_test_layout_efi_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efi_memdesc_version as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efi_memdesc_version) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -3251,7 +3244,7 @@ fn bindgen_test_layout_efi_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efi_memmap as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efi_memmap) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3261,7 +3254,7 @@ fn bindgen_test_layout_efi_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efi_memmap_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efi_memmap_size) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -3271,7 +3264,7 @@ fn bindgen_test_layout_efi_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efi_systab_hi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efi_systab_hi) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -3281,7 +3274,7 @@ fn bindgen_test_layout_efi_info() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efi_memmap_hi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efi_memmap_hi) as usize - ptr as usize }, 28usize, concat!( "Offset of field: ", @@ -3300,6 +3293,8 @@ pub struct boot_e820_entry { } #[test] fn bindgen_test_layout_boot_e820_entry() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 20usize, @@ -3311,7 +3306,7 @@ fn bindgen_test_layout_boot_e820_entry() { concat!("Alignment of ", stringify!(boot_e820_entry)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3321,7 +3316,7 @@ fn bindgen_test_layout_boot_e820_entry() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3331,7 +3326,7 @@ fn bindgen_test_layout_boot_e820_entry() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3342,10 +3337,60 @@ fn bindgen_test_layout_boot_e820_entry() { ); } #[repr(C, packed)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct jailhouse_setup_data { + pub hdr: jailhouse_setup_data__bindgen_ty_1, + pub v1: jailhouse_setup_data__bindgen_ty_2, + pub v2: jailhouse_setup_data__bindgen_ty_3, +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct jailhouse_setup_data__bindgen_ty_1 { pub version: __u16, pub compatible_version: __u16, +} +#[test] +fn bindgen_test_layout_jailhouse_setup_data__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(jailhouse_setup_data__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(jailhouse_setup_data__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(jailhouse_setup_data__bindgen_ty_1), + "::", + stringify!(version) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).compatible_version) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(jailhouse_setup_data__bindgen_ty_1), + "::", + stringify!(compatible_version) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct jailhouse_setup_data__bindgen_ty_2 { pub pm_timer_address: __u16, pub num_cpus: __u16, pub pci_mmconfig_base: __u64, @@ -3355,122 +3400,233 @@ pub struct jailhouse_setup_data { pub cpu_ids: [__u8; 255usize], } #[test] -fn bindgen_test_layout_jailhouse_setup_data() { +fn bindgen_test_layout_jailhouse_setup_data__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 280usize, - concat!("Size of: ", stringify!(jailhouse_setup_data)) + ::std::mem::size_of::(), + 276usize, + concat!("Size of: ", stringify!(jailhouse_setup_data__bindgen_ty_2)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(jailhouse_setup_data)) + concat!( + "Alignment of ", + stringify!(jailhouse_setup_data__bindgen_ty_2) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).version as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pm_timer_address) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(jailhouse_setup_data), + stringify!(jailhouse_setup_data__bindgen_ty_2), "::", - stringify!(version) + stringify!(pm_timer_address) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).compatible_version as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).num_cpus) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", - stringify!(jailhouse_setup_data), + stringify!(jailhouse_setup_data__bindgen_ty_2), "::", - stringify!(compatible_version) + stringify!(num_cpus) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pm_timer_address as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pci_mmconfig_base) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(jailhouse_setup_data), + stringify!(jailhouse_setup_data__bindgen_ty_2), "::", - stringify!(pm_timer_address) + stringify!(pci_mmconfig_base) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).num_cpus as *const _ as usize }, - 6usize, + unsafe { ::std::ptr::addr_of!((*ptr).tsc_khz) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(jailhouse_setup_data), + stringify!(jailhouse_setup_data__bindgen_ty_2), "::", - stringify!(num_cpus) + stringify!(tsc_khz) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pci_mmconfig_base as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).apic_khz) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(jailhouse_setup_data), + stringify!(jailhouse_setup_data__bindgen_ty_2), "::", - stringify!(pci_mmconfig_base) + stringify!(apic_khz) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tsc_khz as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).standard_ioapic) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(jailhouse_setup_data), + stringify!(jailhouse_setup_data__bindgen_ty_2), "::", - stringify!(tsc_khz) + stringify!(standard_ioapic) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apic_khz as *const _ as usize }, - 20usize, + unsafe { ::std::ptr::addr_of!((*ptr).cpu_ids) as usize - ptr as usize }, + 21usize, + concat!( + "Offset of field: ", + stringify!(jailhouse_setup_data__bindgen_ty_2), + "::", + stringify!(cpu_ids) + ) + ); +} +impl Default for jailhouse_setup_data__bindgen_ty_2 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct jailhouse_setup_data__bindgen_ty_3 { + pub flags: __u32, +} +#[test] +fn bindgen_test_layout_jailhouse_setup_data__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(jailhouse_setup_data__bindgen_ty_3)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(jailhouse_setup_data__bindgen_ty_3) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(jailhouse_setup_data__bindgen_ty_3), + "::", + stringify!(flags) + ) + ); +} +#[test] +fn bindgen_test_layout_jailhouse_setup_data() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 284usize, + concat!("Size of: ", stringify!(jailhouse_setup_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(jailhouse_setup_data)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", stringify!(jailhouse_setup_data), "::", - stringify!(apic_khz) + stringify!(hdr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).standard_ioapic as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).v1) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", stringify!(jailhouse_setup_data), "::", - stringify!(standard_ioapic) + stringify!(v1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cpu_ids as *const _ as usize }, - 25usize, + unsafe { ::std::ptr::addr_of!((*ptr).v2) as usize - ptr as usize }, + 280usize, concat!( "Offset of field: ", stringify!(jailhouse_setup_data), "::", - stringify!(cpu_ids) + stringify!(v2) ) ); } impl Default for jailhouse_setup_data { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C, packed)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct ima_setup_data { + pub addr: __u64, + pub size: __u64, +} +#[test] +fn bindgen_test_layout_ima_setup_data() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(ima_setup_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(ima_setup_data)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ima_setup_data), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ima_setup_data), + "::", + stringify!(size) + ) + ); +} +#[repr(C, packed)] #[derive(Copy, Clone)] pub struct boot_params { pub screen_info: screen_info, @@ -3487,7 +3643,8 @@ pub struct boot_params { pub ext_ramdisk_image: __u32, pub ext_ramdisk_size: __u32, pub ext_cmd_line_ptr: __u32, - pub _pad4: [__u8; 116usize], + pub _pad4: [__u8; 112usize], + pub cc_blob_address: __u32, pub edid_info: edid_info, pub efi_info: efi_info, pub alt_mem_k: __u32, @@ -3501,7 +3658,7 @@ pub struct boot_params { pub sentinel: __u8, pub _pad6: [__u8; 1usize], pub hdr: setup_header, - pub _pad7: [__u8; 40usize], + pub _pad7: [__u8; 36usize], pub edd_mbr_sig_buffer: [__u32; 16usize], pub e820_table: [boot_e820_entry; 128usize], pub _pad8: [__u8; 48usize], @@ -3510,6 +3667,8 @@ pub struct boot_params { } #[test] fn bindgen_test_layout_boot_params() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 4096usize, @@ -3521,7 +3680,7 @@ fn bindgen_test_layout_boot_params() { concat!("Alignment of ", stringify!(boot_params)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).screen_info as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).screen_info) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3531,7 +3690,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apm_bios_info as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).apm_bios_info) as usize - ptr as usize }, 64usize, concat!( "Offset of field: ", @@ -3541,7 +3700,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad2 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad2) as usize - ptr as usize }, 84usize, concat!( "Offset of field: ", @@ -3551,7 +3710,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tboot_addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tboot_addr) as usize - ptr as usize }, 88usize, concat!( "Offset of field: ", @@ -3561,7 +3720,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ist_info as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ist_info) as usize - ptr as usize }, 96usize, concat!( "Offset of field: ", @@ -3571,7 +3730,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).acpi_rsdp_addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).acpi_rsdp_addr) as usize - ptr as usize }, 112usize, concat!( "Offset of field: ", @@ -3581,7 +3740,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad3 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad3) as usize - ptr as usize }, 120usize, concat!( "Offset of field: ", @@ -3591,7 +3750,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hd0_info as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).hd0_info) as usize - ptr as usize }, 128usize, concat!( "Offset of field: ", @@ -3601,7 +3760,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hd1_info as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).hd1_info) as usize - ptr as usize }, 144usize, concat!( "Offset of field: ", @@ -3611,7 +3770,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sys_desc_table as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sys_desc_table) as usize - ptr as usize }, 160usize, concat!( "Offset of field: ", @@ -3621,7 +3780,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).olpc_ofw_header as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).olpc_ofw_header) as usize - ptr as usize }, 176usize, concat!( "Offset of field: ", @@ -3631,7 +3790,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_ramdisk_image as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_ramdisk_image) as usize - ptr as usize }, 192usize, concat!( "Offset of field: ", @@ -3641,7 +3800,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_ramdisk_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_ramdisk_size) as usize - ptr as usize }, 196usize, concat!( "Offset of field: ", @@ -3651,7 +3810,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_cmd_line_ptr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_cmd_line_ptr) as usize - ptr as usize }, 200usize, concat!( "Offset of field: ", @@ -3661,7 +3820,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad4 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad4) as usize - ptr as usize }, 204usize, concat!( "Offset of field: ", @@ -3671,7 +3830,17 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).edid_info as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cc_blob_address) as usize - ptr as usize }, + 316usize, + concat!( + "Offset of field: ", + stringify!(boot_params), + "::", + stringify!(cc_blob_address) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).edid_info) as usize - ptr as usize }, 320usize, concat!( "Offset of field: ", @@ -3681,7 +3850,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efi_info as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efi_info) as usize - ptr as usize }, 448usize, concat!( "Offset of field: ", @@ -3691,7 +3860,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).alt_mem_k as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).alt_mem_k) as usize - ptr as usize }, 480usize, concat!( "Offset of field: ", @@ -3701,7 +3870,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).scratch as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).scratch) as usize - ptr as usize }, 484usize, concat!( "Offset of field: ", @@ -3711,7 +3880,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e820_entries as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e820_entries) as usize - ptr as usize }, 488usize, concat!( "Offset of field: ", @@ -3721,7 +3890,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).eddbuf_entries as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).eddbuf_entries) as usize - ptr as usize }, 489usize, concat!( "Offset of field: ", @@ -3731,9 +3900,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).edd_mbr_sig_buf_entries as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).edd_mbr_sig_buf_entries) as usize - ptr as usize }, 490usize, concat!( "Offset of field: ", @@ -3743,7 +3910,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).kbd_status as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).kbd_status) as usize - ptr as usize }, 491usize, concat!( "Offset of field: ", @@ -3753,7 +3920,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).secure_boot as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).secure_boot) as usize - ptr as usize }, 492usize, concat!( "Offset of field: ", @@ -3763,7 +3930,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad5 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad5) as usize - ptr as usize }, 493usize, concat!( "Offset of field: ", @@ -3773,7 +3940,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sentinel as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sentinel) as usize - ptr as usize }, 495usize, concat!( "Offset of field: ", @@ -3783,7 +3950,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad6 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad6) as usize - ptr as usize }, 496usize, concat!( "Offset of field: ", @@ -3793,7 +3960,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, 497usize, concat!( "Offset of field: ", @@ -3803,8 +3970,8 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad7 as *const _ as usize }, - 616usize, + unsafe { ::std::ptr::addr_of!((*ptr)._pad7) as usize - ptr as usize }, + 620usize, concat!( "Offset of field: ", stringify!(boot_params), @@ -3813,7 +3980,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).edd_mbr_sig_buffer as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).edd_mbr_sig_buffer) as usize - ptr as usize }, 656usize, concat!( "Offset of field: ", @@ -3823,7 +3990,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e820_table as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e820_table) as usize - ptr as usize }, 720usize, concat!( "Offset of field: ", @@ -3833,7 +4000,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad8 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad8) as usize - ptr as usize }, 3280usize, concat!( "Offset of field: ", @@ -3843,7 +4010,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).eddbuf as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).eddbuf) as usize - ptr as usize }, 3328usize, concat!( "Offset of field: ", @@ -3853,7 +4020,7 @@ fn bindgen_test_layout_boot_params() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad9 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad9) as usize - ptr as usize }, 3820usize, concat!( "Offset of field: ", @@ -3865,7 +4032,11 @@ fn bindgen_test_layout_boot_params() { } impl Default for boot_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub const x86_hardware_subarch_X86_SUBARCH_PC: x86_hardware_subarch = 0; @@ -3874,4 +4045,5 @@ pub const x86_hardware_subarch_X86_SUBARCH_XEN: x86_hardware_subarch = 2; pub const x86_hardware_subarch_X86_SUBARCH_INTEL_MID: x86_hardware_subarch = 3; pub const x86_hardware_subarch_X86_SUBARCH_CE4100: x86_hardware_subarch = 4; pub const x86_hardware_subarch_X86_NR_SUBARCHS: x86_hardware_subarch = 5; -pub type x86_hardware_subarch = u32; +#[doc = " enum x86_hardware_subarch - x86 hardware subarchitecture\n\n The x86 hardware_subarch and hardware_subarch_data were added as of the x86\n boot protocol 2.07 to help distinguish and support custom x86 boot\n sequences. This enum represents accepted values for the x86\n hardware_subarch. Custom x86 boot sequences (not X86_SUBARCH_PC) do not\n have or simply *cannot* make use of natural stubs like BIOS or EFI, the\n hardware_subarch can be used on the Linux entry path to revector to a\n subarchitecture stub when needed. This subarchitecture stub can be used to\n set up Linux boot parameters or for special care to account for nonstandard\n handling of page tables.\n\n These enums should only ever be used by x86 code, and the code that uses\n it should be well contained and compartmentalized.\n\n KVM and Xen HVM do not have a subarch as these are expected to follow\n standard x86 boot entries. If there is a genuine need for \"hypervisor\" type\n that should be considered separately in the future. Future guest types\n should seriously consider working with standard x86 boot stubs such as\n the BIOS or EFI boot stubs.\n\n WARNING: this enum is only used for legacy hacks, for platform features that\n\t are not easily enumerated or discoverable. You should not ever use\n\t this for new features.\n\n @X86_SUBARCH_PC: Should be used if the hardware is enumerable using standard\n\tPC mechanisms (PCI, ACPI) and doesn't need a special boot flow.\n @X86_SUBARCH_LGUEST: Used for x86 hypervisor demo, lguest, deprecated\n @X86_SUBARCH_XEN: Used for Xen guest types which follow the PV boot path,\n \twhich start at asm startup_xen() entry point and later jump to the C\n \txen_start_kernel() entry point. Both domU and dom0 type of guests are\n \tcurrently supported through this PV boot path.\n @X86_SUBARCH_INTEL_MID: Used for Intel MID (Mobile Internet Device) platform\n\tsystems which do not have the PCI legacy interfaces.\n @X86_SUBARCH_CE4100: Used for Intel CE media processor (CE4100) SoC\n \tfor settop boxes and media devices, the use of a subarch for CE4100\n \tis more of a hack..."] +pub type x86_hardware_subarch = ::std::os::raw::c_uint; diff --git a/src/loader_gen/x86_64/elf.rs b/src/loader_gen/x86_64/elf.rs index 600d848e..3932e94f 100644 --- a/src/loader_gen/x86_64/elf.rs +++ b/src/loader_gen/x86_64/elf.rs @@ -14,7 +14,7 @@ * # bindgen --with-derive-default elf.h > elf.rs * * From upstream linux include/uapi/linux/elf.h at commit: - * 3cc6e2c599cdca573a8f347aea5da4c855ff5a78 + * 48b1320a674e1ff5de2fad8606bee38f724594dc * and then edited to eliminate unnecessary definitions, add comments, * and relocate definitions and tests for clarity. */ @@ -103,6 +103,8 @@ mod tests { #[test] fn bindgen_test_layout_elf64_hdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 64usize, @@ -114,7 +116,7 @@ mod tests { concat!("Alignment of ", stringify!(elf64_hdr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_ident as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_ident) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -124,7 +126,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_type as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_type) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -134,7 +136,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_machine as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_machine) as usize - ptr as usize }, 18usize, concat!( "Offset of field: ", @@ -144,7 +146,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_version as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_version) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -154,7 +156,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_entry as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_entry) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -164,7 +166,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_phoff as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_phoff) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -174,7 +176,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_shoff as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_shoff) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -184,7 +186,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_flags) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -194,7 +196,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_ehsize as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_ehsize) as usize - ptr as usize }, 52usize, concat!( "Offset of field: ", @@ -204,7 +206,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_phentsize as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_phentsize) as usize - ptr as usize }, 54usize, concat!( "Offset of field: ", @@ -214,7 +216,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_phnum as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_phnum) as usize - ptr as usize }, 56usize, concat!( "Offset of field: ", @@ -224,7 +226,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_shentsize as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_shentsize) as usize - ptr as usize }, 58usize, concat!( "Offset of field: ", @@ -234,7 +236,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_shnum as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_shnum) as usize - ptr as usize }, 60usize, concat!( "Offset of field: ", @@ -244,7 +246,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).e_shstrndx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).e_shstrndx) as usize - ptr as usize }, 62usize, concat!( "Offset of field: ", @@ -257,6 +259,8 @@ mod tests { #[test] fn bindgen_test_layout_elf64_phdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 56usize, @@ -268,7 +272,7 @@ mod tests { concat!("Alignment of ", stringify!(elf64_phdr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).p_type as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).p_type) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -278,7 +282,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).p_flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).p_flags) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -288,7 +292,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).p_offset as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).p_offset) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -298,7 +302,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).p_vaddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).p_vaddr) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -308,7 +312,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).p_paddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).p_paddr) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -318,7 +322,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).p_filesz as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).p_filesz) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -328,7 +332,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).p_memsz as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).p_memsz) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -338,7 +342,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).p_align as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).p_align) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -351,6 +355,8 @@ mod tests { #[test] fn bindgen_test_layout_elf64_note() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 12usize, @@ -362,7 +368,7 @@ mod tests { concat!("Alignment of ", stringify!(elf64_note)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).n_namesz as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).n_namesz) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -372,7 +378,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).n_descsz as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).n_descsz) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -382,7 +388,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).n_type as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).n_type) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", diff --git a/src/loader_gen/x86_64/start_info.rs b/src/loader_gen/x86_64/start_info.rs index 90384240..79601480 100644 --- a/src/loader_gen/x86_64/start_info.rs +++ b/src/loader_gen/x86_64/start_info.rs @@ -28,7 +28,7 @@ * From the canonical version in upstream Xen repository * xen/include/public/arch-x86/hvm/start_info.h * at commit: - * a2e84d8e42c9e878fff17b738d8e5c5d83888f31 + * b4642c32c4d079916d5607ddda0232aae5e1690e * * The generated file has been edited to eliminate unnecessary * definitions, add comments, and relocate definitions and tests for clarity. @@ -160,6 +160,8 @@ mod tests { #[test] fn bindgen_test_layout_hvm_start_info() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 56usize, @@ -171,7 +173,7 @@ mod tests { concat!("Alignment of ", stringify!(hvm_start_info)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).magic as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).magic) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -181,7 +183,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).version as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -191,7 +193,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -201,7 +203,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nr_modules as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nr_modules) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -211,9 +213,7 @@ mod tests { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).modlist_paddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).modlist_paddr) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -223,9 +223,7 @@ mod tests { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).cmdline_paddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).cmdline_paddr) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -235,7 +233,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsdp_paddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rsdp_paddr) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -245,7 +243,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).memmap_paddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).memmap_paddr) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -255,9 +253,7 @@ mod tests { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).memmap_entries as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).memmap_entries) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -267,7 +263,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 52usize, concat!( "Offset of field: ", @@ -280,6 +276,9 @@ mod tests { #[test] fn bindgen_test_layout_hvm_modlist_entry() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -291,7 +290,7 @@ mod tests { concat!("Alignment of ", stringify!(hvm_modlist_entry)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).paddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).paddr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -301,7 +300,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -311,9 +310,7 @@ mod tests { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).cmdline_paddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).cmdline_paddr) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -323,7 +320,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -336,6 +333,9 @@ mod tests { #[test] fn bindgen_test_layout_hvm_memmap_table_entry() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 24usize, @@ -347,7 +347,7 @@ mod tests { concat!("Alignment of ", stringify!(hvm_memmap_table_entry)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -357,7 +357,7 @@ mod tests { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -367,9 +367,7 @@ mod tests { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).type_ as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -379,9 +377,7 @@ mod tests { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ",