blob: d2ab5be72d3467c4139a0bc2befe77a6483101e2 [file] [log] [blame]
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Foo {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct RefPtr<T> {
pub m_inner: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl<T> Default for RefPtr<T> {
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 Bar {
pub m_member: RefPtr<Foo>,
}
#[test]
fn bindgen_test_layout_Bar() {
assert_eq!(
::std::mem::size_of::<Bar>(),
8usize,
concat!("Size of: ", stringify!(Bar))
);
assert_eq!(
::std::mem::align_of::<Bar>(),
8usize,
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.m_member);
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!(m_member)
)
);
}
impl Default for Bar {
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()
}
}
}
#[test]
fn __bindgen_test_layout_RefPtr_open0_Foo_close0_instantiation() {
assert_eq!(
::std::mem::size_of::<RefPtr<Foo>>(),
8usize,
concat!("Size of template specialization: ", stringify!(RefPtr<Foo>))
);
assert_eq!(
::std::mem::align_of::<RefPtr<Foo>>(),
8usize,
concat!(
"Alignment of template specialization: ",
stringify!(RefPtr<Foo>)
)
);
}