@@ -106,8 +106,10 @@ STATIC ffi_type *char2ffi_type(char c)
106106 case 'I' : return & ffi_type_uint ;
107107 case 'l' : return & ffi_type_slong ;
108108 case 'L' : return & ffi_type_ulong ;
109+ #if MICROPY_PY_BUILTINS_FLOAT
109110 case 'f' : return & ffi_type_float ;
110111 case 'd' : return & ffi_type_double ;
112+ #endif
111113 case 'C' : // (*)()
112114 case 'P' : // const void*
113115 case 'p' : // void*
@@ -141,6 +143,7 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
141143 }
142144 case 'v' :
143145 return mp_const_none ;
146+ #if MICROPY_PY_BUILTINS_FLOAT
144147 case 'f' : {
145148 union { ffi_arg ffi ; float flt ; } val_union = { .ffi = val };
146149 return mp_obj_new_float (val_union .flt );
@@ -149,6 +152,7 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
149152 double * p = (double * )& val ;
150153 return mp_obj_new_float (* p );
151154 }
155+ #endif
152156 default :
153157 return mp_obj_new_int (val );
154158 }
@@ -336,11 +340,14 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw,
336340 // pointer to a memory location of the correct size.
337341 // TODO check if this needs to be done for other types which don't fit into
338342 // ffi_arg.
343+ #if MICROPY_PY_BUILTINS_FLOAT
339344 if (sizeof (ffi_arg ) == 4 && self -> rettype == 'd' ) {
340345 double retval ;
341346 ffi_call (& self -> cif , self -> func , & retval , valueptrs );
342347 return mp_obj_new_float (retval );
343- } else {
348+ } else
349+ #endif
350+ {
344351 ffi_arg retval ;
345352 ffi_call (& self -> cif , self -> func , & retval , valueptrs );
346353 return return_ffi_value (retval , self -> rettype );
0 commit comments