44#![ allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals) ]
55
66
7+
8+ /// Because this struct have array larger than 32 items
9+ /// and --with-derive-partialeq --impl-partialeq --impl-debug is provided,
10+ /// this struct should manually implement `Debug` and `PartialEq`.
711#[ repr( C ) ]
812#[ derive( Copy ) ]
913pub struct Foo {
10- pub big_array : [ :: std:: os:: raw:: c_char ; 33usize ] ,
11- pub _bitfield_1 : u8 ,
14+ pub large : [ :: std:: os:: raw:: c_int ; 33usize ] ,
15+ pub _bitfield_1 : [ u8 ; 2usize ] ,
16+ pub __bindgen_padding_0 : u16 ,
1217}
1318#[ test]
1419fn bindgen_test_layout_Foo ( ) {
1520 assert_eq ! (
1621 :: std:: mem:: size_of:: <Foo >( ) ,
17- 34usize ,
22+ 136usize ,
1823 concat!( "Size of: " , stringify!( Foo ) )
1924 ) ;
2025 assert_eq ! (
2126 :: std:: mem:: align_of:: <Foo >( ) ,
22- 1usize ,
27+ 4usize ,
2328 concat!( "Alignment of " , stringify!( Foo ) )
2429 ) ;
2530 assert_eq ! (
26- unsafe { & ( * ( 0 as * const Foo ) ) . big_array as * const _ as usize } ,
31+ unsafe { & ( * ( 0 as * const Foo ) ) . large as * const _ as usize } ,
2732 0usize ,
2833 concat!(
2934 "Alignment of field: " ,
3035 stringify!( Foo ) ,
3136 "::" ,
32- stringify!( big_array )
37+ stringify!( large )
3338 )
3439 ) ;
3540}
@@ -55,37 +60,51 @@ impl Default for Foo {
5560 unsafe { :: std:: mem:: zeroed ( ) }
5661 }
5762}
63+ impl :: std:: fmt:: Debug for Foo {
64+ fn fmt ( & self , f : & mut :: std:: fmt:: Formatter ) -> :: std:: fmt:: Result {
65+ write ! (
66+ f,
67+ "Foo {{ large: [{}], type_ : {:?}, }}" ,
68+ self . large
69+ . iter( )
70+ . enumerate( )
71+ . map( |( i, v) | format!( "{}{:?}" , if i > 0 { ", " } else { "" } , v) )
72+ . collect:: <String >( ) ,
73+ self . type__bindgen_bitfield( )
74+ )
75+ }
76+ }
5877impl :: std:: cmp:: PartialEq for Foo {
5978 fn eq ( & self , other : & Foo ) -> bool {
60- & self . big_array [ ..] == & other. big_array [ ..]
79+ & self . large [ ..] == & other. large [ ..]
6180 && self . type__bindgen_bitfield ( ) == other. type__bindgen_bitfield ( )
6281 }
6382}
6483impl Foo {
6584 #[ inline]
6685 pub fn type__bindgen_bitfield ( & self ) -> :: std:: os:: raw:: c_char {
67- let mut unit_field_val: u8 = unsafe { :: std:: mem:: uninitialized ( ) } ;
86+ let mut unit_field_val: u16 = unsafe { :: std:: mem:: uninitialized ( ) } ;
6887 unsafe {
6988 :: std:: ptr:: copy_nonoverlapping (
7089 & self . _bitfield_1 as * const _ as * const u8 ,
71- & mut unit_field_val as * mut u8 as * mut u8 ,
72- :: std:: mem:: size_of :: < u8 > ( ) ,
90+ & mut unit_field_val as * mut u16 as * mut u8 ,
91+ :: std:: mem:: size_of :: < u16 > ( ) ,
7392 )
7493 } ;
75- let mask = 7u64 as u8 ;
94+ let mask = 7u64 as u16 ;
7695 let val = ( unit_field_val & mask) >> 0usize ;
7796 unsafe { :: std:: mem:: transmute ( val as u8 ) }
7897 }
7998 #[ inline]
8099 pub fn set_type__bindgen_bitfield ( & mut self , val : :: std:: os:: raw:: c_char ) {
81- let mask = 7u64 as u8 ;
82- let val = val as u8 as u8 ;
83- let mut unit_field_val: u8 = unsafe { :: std:: mem:: uninitialized ( ) } ;
100+ let mask = 7u64 as u16 ;
101+ let val = val as u8 as u16 ;
102+ let mut unit_field_val: u16 = unsafe { :: std:: mem:: uninitialized ( ) } ;
84103 unsafe {
85104 :: std:: ptr:: copy_nonoverlapping (
86105 & self . _bitfield_1 as * const _ as * const u8 ,
87- & mut unit_field_val as * mut u8 as * mut u8 ,
88- :: std:: mem:: size_of :: < u8 > ( ) ,
106+ & mut unit_field_val as * mut u16 as * mut u8 ,
107+ :: std:: mem:: size_of :: < u16 > ( ) ,
89108 )
90109 } ;
91110 unit_field_val &= !mask;
@@ -94,13 +113,13 @@ impl Foo {
94113 :: std:: ptr:: copy_nonoverlapping (
95114 & unit_field_val as * const _ as * const u8 ,
96115 & mut self . _bitfield_1 as * mut _ as * mut u8 ,
97- :: std:: mem:: size_of :: < u8 > ( ) ,
116+ :: std:: mem:: size_of :: < u16 > ( ) ,
98117 ) ;
99118 }
100119 }
101120 #[ inline]
102- pub fn new_bitfield_1 ( type__bindgen_bitfield : :: std:: os:: raw:: c_char ) -> u8 {
103- ( 0 | ( ( type__bindgen_bitfield as u8 as u8 ) << 0usize ) & ( 7u64 as u8 ) )
121+ pub fn new_bitfield_1 ( type__bindgen_bitfield : :: std:: os:: raw:: c_char ) -> u16 {
122+ ( 0 | ( ( type__bindgen_bitfield as u8 as u16 ) << 0usize ) & ( 7u64 as u16 ) )
104123 }
105124 #[ inline]
106125 pub unsafe fn type_ ( & mut self ) -> :: std:: os:: raw:: c_char {
0 commit comments