2 Purpose: Check register allocation for closure calls with many float and double arguments
5 Originator: <david.schneider@picle.org> */
14 static void cls_mixed_float_double_fn(ffi_cif
* cif
, void* ret
, void** args
,
15 void* userdata __UNUSED__
)
20 for(i
=0; i
< cif
->nargs
; i
++)
22 if(cif
->arg_types
[i
] == &ffi_type_double
) {
23 t
= *(((double**)(args
))[i
]);
25 t
= *(((float**)(args
))[i
]);
31 typedef double (*cls_mixed
)(double, float, double, double, double, double, double, float, float, double, float, float);
38 ffi_type
*argtypes
[12] = {&ffi_type_double
, &ffi_type_float
, &ffi_type_double
,
39 &ffi_type_double
, &ffi_type_double
, &ffi_type_double
,
40 &ffi_type_double
, &ffi_type_float
, &ffi_type_float
,
41 &ffi_type_double
, &ffi_type_float
, &ffi_type_float
};
44 closure
= ffi_closure_alloc(sizeof(ffi_closure
), (void**)&code
);
47 CHECK(ffi_prep_cif(&cif
, FFI_DEFAULT_ABI
, 12, &ffi_type_double
, argtypes
) == FFI_OK
);
48 CHECK(ffi_prep_closure_loc(closure
, &cif
, cls_mixed_float_double_fn
, NULL
, code
) == FFI_OK
);
49 double ret
= ((cls_mixed
)code
)(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2);
50 ffi_closure_free(closure
);
51 if(fabs(ret
- 7.8) < FLT_EPSILON
)