• 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 #[repr(C)]
9 #[derive(Copy, Clone)]
10 pub struct foo {
11     pub bar: foo__bindgen_ty_1,
12 }
13 #[repr(C)]
14 #[derive(Copy, Clone)]
15 pub union foo__bindgen_ty_1 {
16     pub a: ::std::os::raw::c_uint,
17     pub b: ::std::os::raw::c_ushort,
18 }
19 #[test]
bindgen_test_layout_foo__bindgen_ty_1()20 fn bindgen_test_layout_foo__bindgen_ty_1() {
21     const UNINIT: ::std::mem::MaybeUninit<foo__bindgen_ty_1> =
22         ::std::mem::MaybeUninit::uninit();
23     let ptr = UNINIT.as_ptr();
24     assert_eq!(
25         ::std::mem::size_of::<foo__bindgen_ty_1>(),
26         4usize,
27         concat!("Size of: ", stringify!(foo__bindgen_ty_1))
28     );
29     assert_eq!(
30         ::std::mem::align_of::<foo__bindgen_ty_1>(),
31         4usize,
32         concat!("Alignment of ", stringify!(foo__bindgen_ty_1))
33     );
34     assert_eq!(
35         unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize },
36         0usize,
37         concat!(
38             "Offset of field: ",
39             stringify!(foo__bindgen_ty_1),
40             "::",
41             stringify!(a)
42         )
43     );
44     assert_eq!(
45         unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize },
46         0usize,
47         concat!(
48             "Offset of field: ",
49             stringify!(foo__bindgen_ty_1),
50             "::",
51             stringify!(b)
52         )
53     );
54 }
55 impl Default for foo__bindgen_ty_1 {
default() -> Self56     fn default() -> Self {
57         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
58         unsafe {
59             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
60             s.assume_init()
61         }
62     }
63 }
64 #[test]
bindgen_test_layout_foo()65 fn bindgen_test_layout_foo() {
66     const UNINIT: ::std::mem::MaybeUninit<foo> =
67         ::std::mem::MaybeUninit::uninit();
68     let ptr = UNINIT.as_ptr();
69     assert_eq!(
70         ::std::mem::size_of::<foo>(),
71         4usize,
72         concat!("Size of: ", stringify!(foo))
73     );
74     assert_eq!(
75         ::std::mem::align_of::<foo>(),
76         4usize,
77         concat!("Alignment of ", stringify!(foo))
78     );
79     assert_eq!(
80         unsafe { ::std::ptr::addr_of!((*ptr).bar) as usize - ptr as usize },
81         0usize,
82         concat!("Offset of field: ", stringify!(foo), "::", stringify!(bar))
83     );
84 }
85 impl Default for foo {
default() -> Self86     fn default() -> Self {
87         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
88         unsafe {
89             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
90             s.assume_init()
91         }
92     }
93 }
94