@@ -217,9 +217,6 @@ struct CodegenResult<'a> {
217217 /// Whether a bitfield allocation unit has been seen at least once.
218218 saw_bitfield_unit : bool ,
219219
220- /// Whether a long double has been seen at least once.
221- saw_long_double : bool ,
222-
223220 items_seen : HashSet < ItemId > ,
224221 /// The set of generated function/var names, needed because in C/C++ is
225222 /// legal to do something like:
@@ -256,7 +253,6 @@ impl<'a> CodegenResult<'a> {
256253 saw_objc : false ,
257254 saw_block : false ,
258255 saw_bitfield_unit : false ,
259- saw_long_double : false ,
260256 codegen_id,
261257 items_seen : Default :: default ( ) ,
262258 functions_seen : Default :: default ( ) ,
@@ -289,10 +285,6 @@ impl<'a> CodegenResult<'a> {
289285 self . saw_bitfield_unit = true ;
290286 }
291287
292- fn saw_long_double ( & mut self ) {
293- self . saw_long_double = true ;
294- }
295-
296288 fn seen < Id : Into < ItemId > > ( & self , item : Id ) -> bool {
297289 self . items_seen . contains ( & item. into ( ) )
298290 }
@@ -548,6 +540,9 @@ impl CodeGenerator for Module {
548540 if ctx. need_bindgen_complex_type ( ) {
549541 utils:: prepend_complex_type ( & mut * result) ;
550542 }
543+ if let Some ( layout) = ctx. need_bindgen_long_double ( ) {
544+ utils:: prepend_long_double ( layout, & mut * result) ;
545+ }
551546 if result. saw_objc {
552547 utils:: prepend_objc_header ( ctx, & mut * result) ;
553548 }
@@ -2459,7 +2454,7 @@ impl Method {
24592454
24602455 let signature = match * signature_item. expect_type ( ) . kind ( ) {
24612456 TypeKind :: Function ( ref sig) => sig,
2462- _ => panic ! ( "How in the world?" ) ,
2457+ _ => unreachable ! ( ) ,
24632458 } ;
24642459
24652460 if utils:: sig_unsupported_types ( ctx, signature) {
@@ -4513,6 +4508,7 @@ pub mod utils {
45134508 use crate :: ir:: context:: BindgenContext ;
45144509 use crate :: ir:: function:: { Abi , ClangAbi , FunctionSig } ;
45154510 use crate :: ir:: item:: { Item , ItemCanonicalPath } ;
4511+ use crate :: ir:: layout:: Layout ;
45164512 use crate :: ir:: ty:: TypeKind ;
45174513 use proc_macro2;
45184514 use std:: borrow:: Cow ;
@@ -4785,6 +4781,21 @@ pub mod utils {
47854781 result. extend ( old_items. into_iter ( ) ) ;
47864782 }
47874783
4784+ pub fn prepend_long_double (
4785+ layout : Layout ,
4786+ result : & mut Vec < proc_macro2:: TokenStream > ,
4787+ ) {
4788+ let Layout { align, size, .. } = layout;
4789+ result. insert (
4790+ 0 ,
4791+ quote ! {
4792+ #[ derive( PartialEq , Copy , Clone , Hash , Debug , Default ) ]
4793+ #[ repr( C , align( #align) ) ]
4794+ pub struct __BindgenLongDouble( [ u8 ; #size] ) ;
4795+ } ,
4796+ ) ;
4797+ }
4798+
47884799 pub fn build_path (
47894800 item : & Item ,
47904801 ctx : & BindgenContext ,
@@ -5078,12 +5089,12 @@ pub mod utils {
50785089
50795090 pub fn sig_unsupported_types (
50805091 ctx : & BindgenContext ,
5081- sig : & FunctionSig
5092+ sig : & FunctionSig ,
50825093 ) -> bool {
5083- sig. argument_types ( ) . iter ( )
5094+ sig. argument_types ( )
5095+ . iter ( )
50845096 . map ( |( _, ty_id) | ty_id)
50855097 . chain ( std:: iter:: once ( & sig. return_type ( ) ) )
5086- . find ( |ty_id| ctx. lookup_never_by_value ( * ty_id) )
5087- . is_some ( )
5098+ . any ( |ty_id| ctx. lookup_never_by_value ( * ty_id) )
50885099 }
50895100}
0 commit comments