File tree 3 files changed +69
-5
lines changed
3 files changed +69
-5
lines changed Original file line number Diff line number Diff line change @@ -3059,11 +3059,21 @@ impl TryToRustTy for Type {
3059
3059
#ident
3060
3060
} )
3061
3061
}
3062
- // FIXME: This doesn't generate the proper alignment, but we
3063
- // can't do better right now. We should be able to use
3064
- // i128/u128 when they're available.
3065
- IntKind :: U128 | IntKind :: I128 => {
3066
- Ok ( quote ! { [ u64 ; 2 ] } )
3062
+ IntKind :: U128 => {
3063
+ Ok ( if ctx. options ( ) . rust_features . i128_and_u128 {
3064
+ quote ! { u128 }
3065
+ } else {
3066
+ // Best effort thing, but wrong alignment
3067
+ // unfortunately.
3068
+ quote ! { [ u64 ; 2 ] }
3069
+ } )
3070
+ }
3071
+ IntKind :: I128 => {
3072
+ Ok ( if ctx. options ( ) . rust_features . i128_and_u128 {
3073
+ quote ! { i128 }
3074
+ } else {
3075
+ quote ! { [ u64 ; 2 ] }
3076
+ } )
3067
3077
}
3068
3078
}
3069
3079
}
Original file line number Diff line number Diff line change
1
+ /* automatically generated by rust-bindgen */
2
+
3
+ #![ allow(
4
+ dead_code,
5
+ non_snake_case,
6
+ non_camel_case_types,
7
+ non_upper_case_globals
8
+ ) ]
9
+
10
+ #[ repr( C ) ]
11
+ #[ derive( Debug , Default , Copy , Clone ) ]
12
+ pub struct foo {
13
+ pub my_signed : i128 ,
14
+ pub my_unsigned : u128 ,
15
+ }
16
+ #[ test]
17
+ fn bindgen_test_layout_foo ( ) {
18
+ assert_eq ! (
19
+ :: std:: mem:: size_of:: <foo>( ) ,
20
+ 32usize ,
21
+ concat!( "Size of: " , stringify!( foo) )
22
+ ) ;
23
+ assert_eq ! (
24
+ :: std:: mem:: align_of:: <foo>( ) ,
25
+ 16usize ,
26
+ concat!( "Alignment of " , stringify!( foo) )
27
+ ) ;
28
+ assert_eq ! (
29
+ unsafe { & ( * ( :: std:: ptr:: null:: <foo>( ) ) ) . my_signed as * const _ as usize } ,
30
+ 0usize ,
31
+ concat!(
32
+ "Offset of field: " ,
33
+ stringify!( foo) ,
34
+ "::" ,
35
+ stringify!( my_signed)
36
+ )
37
+ ) ;
38
+ assert_eq ! (
39
+ unsafe { & ( * ( :: std:: ptr:: null:: <foo>( ) ) ) . my_unsigned as * const _ as usize } ,
40
+ 16usize ,
41
+ concat!(
42
+ "Offset of field: " ,
43
+ stringify!( foo) ,
44
+ "::" ,
45
+ stringify!( my_unsigned)
46
+ )
47
+ ) ;
48
+ }
Original file line number Diff line number Diff line change
1
+ // bindgen-flags: --rust-target 1.26
2
+
3
+ struct foo {
4
+ __int128 my_signed ;
5
+ unsigned __int128 my_unsigned ;
6
+ };
You can’t perform that action at this time.
0 commit comments