1 /* Area: ffi_call, closure_call
2 Purpose: Test doubles passed in variable argument lists.
5 Originator: Blake Chaffin 6/6/2007 */
7 /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
8 /* { dg-output "" { xfail avr32*-*-* } } */
9 /* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */
14 cls_double_va_fn(ffi_cif
* cif __UNUSED__
, void* resp
,
15 void** args
, void* userdata __UNUSED__
)
17 char* format
= *(char**)args
[0];
18 double doubleValue
= *(double*)args
[1];
20 *(ffi_arg
*)resp
= printf(format
, doubleValue
);
27 ffi_closure
*pcl
= ffi_closure_alloc(sizeof(ffi_closure
), &code
);
29 ffi_type
* arg_types
[3];
31 char* format
= "%.1f\n";
35 arg_types
[0] = &ffi_type_pointer
;
36 arg_types
[1] = &ffi_type_double
;
39 /* This printf call is variadic */
40 CHECK(ffi_prep_cif_var(&cif
, FFI_DEFAULT_ABI
, 1, 2, &ffi_type_sint
,
41 arg_types
) == FFI_OK
);
47 ffi_call(&cif
, FFI_FN(printf
), &res
, args
);
48 /* { dg-output "7.0" } */
49 printf("res: %d\n", (int) res
);
50 /* { dg-output "\nres: 4" } */
52 CHECK(ffi_prep_closure_loc(pcl
, &cif
, cls_double_va_fn
, NULL
,
55 res
= ((int(*)(char*, ...))(code
))(format
, doubleArg
);
56 /* { dg-output "\n7.0" } */
57 printf("res: %d\n", (int) res
);
58 /* { dg-output "\nres: 4" } */