@@ -1185,7 +1185,7 @@ impl Bitfield {
1185
1185
let bitfield_ty_layout = bitfield_ty. layout ( ctx) . expect (
1186
1186
"Bitfield without layout? Gah!" ,
1187
1187
) ;
1188
- let bitfield_int_ty = helpers:: blob ( bitfield_ty_layout) ;
1188
+ let bitfield_int_ty = helpers:: blob ( ctx , bitfield_ty_layout) ;
1189
1189
1190
1190
let offset = self . offset_into_unit ( ) ;
1191
1191
let width = self . width ( ) as u8 ;
@@ -1367,7 +1367,7 @@ impl<'a> FieldCodegen<'a> for Bitfield {
1367
1367
let bitfield_ty_layout = bitfield_ty. layout ( ctx) . expect (
1368
1368
"Bitfield without layout? Gah!" ,
1369
1369
) ;
1370
- let bitfield_int_ty = match helpers:: integer_type ( bitfield_ty_layout) {
1370
+ let bitfield_int_ty = match helpers:: integer_type ( ctx , bitfield_ty_layout) {
1371
1371
Some ( int_ty) => {
1372
1372
* bitfield_representable_as_int = true ;
1373
1373
int_ty
@@ -1547,7 +1547,7 @@ impl CodeGenerator for CompInfo {
1547
1547
}
1548
1548
1549
1549
let layout = layout. expect ( "Unable to get layout information?" ) ;
1550
- let ty = helpers:: blob ( layout) ;
1550
+ let ty = helpers:: blob ( ctx , layout) ;
1551
1551
1552
1552
fields. push ( if self . can_be_rust_union ( ctx) {
1553
1553
quote ! {
@@ -1572,7 +1572,7 @@ impl CodeGenerator for CompInfo {
1572
1572
Some ( l) => {
1573
1573
explicit_align = Some ( l. align ) ;
1574
1574
1575
- let ty = helpers:: blob ( l) ;
1575
+ let ty = helpers:: blob ( ctx , l) ;
1576
1576
fields. push ( quote ! {
1577
1577
pub _bindgen_opaque_blob: #ty ,
1578
1578
} ) ;
@@ -1595,7 +1595,7 @@ impl CodeGenerator for CompInfo {
1595
1595
} else {
1596
1596
explicit_align = Some ( layout. align ) ;
1597
1597
if !ctx. options ( ) . rust_features . repr_align {
1598
- let ty = helpers:: blob ( Layout :: new ( 0 , layout. align ) ) ;
1598
+ let ty = helpers:: blob ( ctx , Layout :: new ( 0 , layout. align ) ) ;
1599
1599
fields. push ( quote ! {
1600
1600
pub __bindgen_align: #ty ,
1601
1601
} ) ;
@@ -1629,7 +1629,7 @@ impl CodeGenerator for CompInfo {
1629
1629
} ;
1630
1630
1631
1631
if has_address {
1632
- let ty = helpers:: blob ( Layout :: new ( 1 , 1 ) ) ;
1632
+ let ty = helpers:: blob ( ctx , Layout :: new ( 1 , 1 ) ) ;
1633
1633
fields. push ( quote ! {
1634
1634
pub _address: #ty,
1635
1635
} ) ;
@@ -2800,7 +2800,7 @@ trait TryToOpaque {
2800
2800
extra : & Self :: Extra ,
2801
2801
) -> error:: Result < quote:: Tokens > {
2802
2802
self . try_get_layout ( ctx, extra) . map ( |layout| {
2803
- helpers:: blob ( layout)
2803
+ helpers:: blob ( ctx , layout)
2804
2804
} )
2805
2805
}
2806
2806
}
@@ -2827,7 +2827,7 @@ trait ToOpaque: TryToOpaque {
2827
2827
extra : & Self :: Extra ,
2828
2828
) -> quote:: Tokens {
2829
2829
let layout = self . get_layout ( ctx, extra) ;
2830
- helpers:: blob ( layout)
2830
+ helpers:: blob ( ctx , layout)
2831
2831
}
2832
2832
}
2833
2833
@@ -2885,7 +2885,7 @@ where
2885
2885
|_| if let Ok ( layout) =
2886
2886
self . try_get_layout ( ctx, extra)
2887
2887
{
2888
- Ok ( helpers:: blob ( layout) )
2888
+ Ok ( helpers:: blob ( ctx , layout) )
2889
2889
} else {
2890
2890
Err ( error:: Error :: NoLayoutForOpaqueBlob )
2891
2891
} ,
@@ -3037,7 +3037,7 @@ impl TryToRustTy for Type {
3037
3037
IntKind :: LongLong => Ok ( raw_type ( ctx, "c_longlong" ) ) ,
3038
3038
IntKind :: ULongLong => Ok ( raw_type ( ctx, "c_ulonglong" ) ) ,
3039
3039
IntKind :: WChar { size } => {
3040
- let ty = Layout :: known_type_for_size ( size)
3040
+ let ty = Layout :: known_type_for_size ( ctx , size)
3041
3041
. expect ( "Non-representable wchar_t?" ) ;
3042
3042
let ident = ctx. rust_ident_raw ( ty) ;
3043
3043
Ok ( quote ! { #ident } )
@@ -3059,17 +3059,27 @@ 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
}
3070
- TypeKind :: Float ( fk) => Ok ( float_kind_rust_type ( ctx, fk) ) ,
3080
+ TypeKind :: Float ( fk) => Ok ( float_kind_rust_type ( ctx, fk, self . layout ( ctx ) ) ) ,
3071
3081
TypeKind :: Complex ( fk) => {
3072
- let float_path = float_kind_rust_type ( ctx, fk) ;
3082
+ let float_path = float_kind_rust_type ( ctx, fk, self . layout ( ctx ) ) ;
3073
3083
3074
3084
ctx. generated_bindgen_complex ( ) ;
3075
3085
Ok ( if ctx. options ( ) . enable_cxx_namespaces {
0 commit comments