blob: e3db2318168dd3e91d71de4890ed5238c6d52b76 [file] [log] [blame]
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct A {
pub foo: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_A() {
assert_eq!(
::std::mem::size_of::<A>(),
4usize,
concat!("Size of: ", stringify!(A))
);
assert_eq!(
::std::mem::align_of::<A>(),
4usize,
concat!("Alignment of ", stringify!(A))
);
assert_eq!(
{
let struct_instance = unsafe { std::mem::zeroed::<A>() };
let struct_ptr = &struct_instance as *const A;
let field_ptr = std::ptr::addr_of!(struct_instance.foo);
let struct_address = struct_ptr as usize;
let field_address = field_ptr as usize;
std::mem::forget(struct_instance);
field_address.checked_sub(struct_address).unwrap()
},
0usize,
concat!("Offset of field: ", stringify!(A), "::", stringify!(foo))
);
}
#[repr(C)]
pub struct B__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct B {
pub vtable_: *const B__bindgen_vtable,
pub bar: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_B() {
assert_eq!(
::std::mem::size_of::<B>(),
16usize,
concat!("Size of: ", stringify!(B))
);
assert_eq!(
::std::mem::align_of::<B>(),
8usize,
concat!("Alignment of ", stringify!(B))
);
assert_eq!(
{
let struct_instance = unsafe { std::mem::zeroed::<B>() };
let struct_ptr = &struct_instance as *const B;
let field_ptr = std::ptr::addr_of!(struct_instance.bar);
let struct_address = struct_ptr as usize;
let field_address = field_ptr as usize;
std::mem::forget(struct_instance);
field_address.checked_sub(struct_address).unwrap()
},
8usize,
concat!("Offset of field: ", stringify!(B), "::", stringify!(bar))
);
}
impl Default for B {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
pub struct C__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct C {
pub vtable_: *const C__bindgen_vtable,
pub baz: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_C() {
assert_eq!(
::std::mem::size_of::<C>(),
16usize,
concat!("Size of: ", stringify!(C))
);
assert_eq!(
::std::mem::align_of::<C>(),
8usize,
concat!("Alignment of ", stringify!(C))
);
assert_eq!(
{
let struct_instance = unsafe { std::mem::zeroed::<C>() };
let struct_ptr = &struct_instance as *const C;
let field_ptr = std::ptr::addr_of!(struct_instance.baz);
let struct_address = struct_ptr as usize;
let field_address = field_ptr as usize;
std::mem::forget(struct_instance);
field_address.checked_sub(struct_address).unwrap()
},
8usize,
concat!("Offset of field: ", stringify!(C), "::", stringify!(baz))
);
}
impl Default for C {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct D {
pub _base: C,
pub _base_1: B,
pub bazz: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_D() {
assert_eq!(
::std::mem::size_of::<D>(),
40usize,
concat!("Size of: ", stringify!(D))
);
assert_eq!(
::std::mem::align_of::<D>(),
8usize,
concat!("Alignment of ", stringify!(D))
);
}
impl Default for D {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}