• 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(Debug, Copy, Clone)]
10 pub struct foo {
11     pub member: foo__bindgen_ty_1::Type,
12 }
13 pub mod foo__bindgen_ty_1 {
14     pub type Type = ::std::os::raw::c_uint;
15     pub const FOO_A: Type = 0;
16     pub const FOO_B: Type = 1;
17 }
18 #[test]
bindgen_test_layout_foo()19 fn bindgen_test_layout_foo() {
20     const UNINIT: ::std::mem::MaybeUninit<foo> =
21         ::std::mem::MaybeUninit::uninit();
22     let ptr = UNINIT.as_ptr();
23     assert_eq!(
24         ::std::mem::size_of::<foo>(),
25         4usize,
26         concat!("Size of: ", stringify!(foo))
27     );
28     assert_eq!(
29         ::std::mem::align_of::<foo>(),
30         4usize,
31         concat!("Alignment of ", stringify!(foo))
32     );
33     assert_eq!(
34         unsafe { ::std::ptr::addr_of!((*ptr).member) as usize - ptr as usize },
35         0usize,
36         concat!(
37             "Offset of field: ",
38             stringify!(foo),
39             "::",
40             stringify!(member)
41         )
42     );
43 }
44 impl Default for foo {
default() -> Self45     fn default() -> Self {
46         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
47         unsafe {
48             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
49             s.assume_init()
50         }
51     }
52 }
53 pub mod Foo {
54     pub type Type = ::std::os::raw::c_uint;
55     pub const Bar: Type = 0;
56     pub const Qux: Type = 1;
57 }
58 pub mod Neg {
59     pub type Type = ::std::os::raw::c_int;
60     pub const MinusOne: Type = -1;
61     pub const One: Type = 1;
62 }
63 pub mod NoDebug {
64     /// <div rustbindgen nodebug></div>
65     pub type Type = ::std::os::raw::c_uint;
66     pub const NoDebug1: Type = 0;
67     pub const NoDebug2: Type = 1;
68 }
69 pub mod Debug {
70     /// <div rustbindgen derive="Debug"></div>
71     pub type Type = ::std::os::raw::c_uint;
72     pub const Debug1: Type = 0;
73     pub const Debug2: Type = 1;
74 }
75