blob: bcaa490ba12f6edd20226bbcbd0bf2677b0b4cb3 [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 bar {
pub u: foo,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct foo {
pub foo: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_foo() {
assert_eq!(
::std::mem::size_of::<foo>(),
4usize,
concat!("Size of: ", stringify!(foo))
);
assert_eq!(
::std::mem::align_of::<foo>(),
4usize,
concat!("Alignment of ", stringify!(foo))
);
assert_eq!(
{
let struct_instance = unsafe { std::mem::zeroed::<foo>() };
let struct_ptr = &struct_instance as *const foo;
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!(foo), "::", stringify!(foo))
);
}
#[test]
fn bindgen_test_layout_bar() {
assert_eq!(
::std::mem::size_of::<bar>(),
4usize,
concat!("Size of: ", stringify!(bar))
);
assert_eq!(
::std::mem::align_of::<bar>(),
4usize,
concat!("Alignment of ", stringify!(bar))
);
assert_eq!(
{
let struct_instance = unsafe { std::mem::zeroed::<bar>() };
let struct_ptr = &struct_instance as *const bar;
let field_ptr = std::ptr::addr_of!(struct_instance.u);
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!(bar), "::", stringify!(u))
);
}
pub type bar_t = bar;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct baz {
pub f: foo,
}
#[test]
fn bindgen_test_layout_baz() {
assert_eq!(
::std::mem::size_of::<baz>(),
4usize,
concat!("Size of: ", stringify!(baz))
);
assert_eq!(
::std::mem::align_of::<baz>(),
4usize,
concat!("Alignment of ", stringify!(baz))
);
assert_eq!(
{
let struct_instance = unsafe { std::mem::zeroed::<baz>() };
let struct_ptr = &struct_instance as *const baz;
let field_ptr = std::ptr::addr_of!(struct_instance.f);
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!(baz), "::", stringify!(f))
);
}