• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![allow(
2     dead_code,
3     non_snake_case,
4     non_camel_case_types,
5     non_upper_case_globals
6 )]
7 
8 #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
9 #[repr(C)]
10 pub struct __BindgenComplex<T> {
11     pub re: T,
12     pub im: T,
13 }
14 #[repr(C)]
15 #[derive(Debug, Copy, Clone)]
16 pub struct foo {
17     pub bar: ::std::os::raw::c_float,
18     pub baz: ::std::os::raw::c_float,
19     pub bazz: ::std::os::raw::c_double,
20     pub bazzz: *mut u128,
21     pub complexFloat: __BindgenComplex<::std::os::raw::c_float>,
22     pub complexDouble: __BindgenComplex<::std::os::raw::c_double>,
23 }
24 #[test]
bindgen_test_layout_foo()25 fn bindgen_test_layout_foo() {
26     const UNINIT: ::std::mem::MaybeUninit<foo> =
27         ::std::mem::MaybeUninit::uninit();
28     let ptr = UNINIT.as_ptr();
29     assert_eq!(
30         ::std::mem::size_of::<foo>(),
31         48usize,
32         concat!("Size of: ", stringify!(foo))
33     );
34     assert_eq!(
35         ::std::mem::align_of::<foo>(),
36         8usize,
37         concat!("Alignment of ", stringify!(foo))
38     );
39     assert_eq!(
40         unsafe { ::std::ptr::addr_of!((*ptr).bar) as usize - ptr as usize },
41         0usize,
42         concat!("Offset of field: ", stringify!(foo), "::", stringify!(bar))
43     );
44     assert_eq!(
45         unsafe { ::std::ptr::addr_of!((*ptr).baz) as usize - ptr as usize },
46         4usize,
47         concat!("Offset of field: ", stringify!(foo), "::", stringify!(baz))
48     );
49     assert_eq!(
50         unsafe { ::std::ptr::addr_of!((*ptr).bazz) as usize - ptr as usize },
51         8usize,
52         concat!("Offset of field: ", stringify!(foo), "::", stringify!(bazz))
53     );
54     assert_eq!(
55         unsafe { ::std::ptr::addr_of!((*ptr).bazzz) as usize - ptr as usize },
56         16usize,
57         concat!(
58             "Offset of field: ",
59             stringify!(foo),
60             "::",
61             stringify!(bazzz)
62         )
63     );
64     assert_eq!(
65         unsafe {
66             ::std::ptr::addr_of!((*ptr).complexFloat) as usize - ptr as usize
67         },
68         24usize,
69         concat!(
70             "Offset of field: ",
71             stringify!(foo),
72             "::",
73             stringify!(complexFloat)
74         )
75     );
76     assert_eq!(
77         unsafe {
78             ::std::ptr::addr_of!((*ptr).complexDouble) as usize - ptr as usize
79         },
80         32usize,
81         concat!(
82             "Offset of field: ",
83             stringify!(foo),
84             "::",
85             stringify!(complexDouble)
86         )
87     );
88 }
89 impl Default for foo {
default() -> Self90     fn default() -> Self {
91         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
92         unsafe {
93             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
94             s.assume_init()
95         }
96     }
97 }
98