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*-*-* } } */
12 cls_double_va_fn(ffi_cif
* cif __UNUSED__
, void* resp
,
13 void** args
, void* userdata __UNUSED__
)
15 char* format
= *(char**)args
[0];
16 double doubleValue
= *(double*)args
[1];
18 *(ffi_arg
*)resp
= printf(format
, doubleValue
);
25 ffi_closure
*pcl
= ffi_closure_alloc(sizeof(ffi_closure
), &code
);
27 ffi_type
* arg_types
[3];
29 char* format
= "%.1f\n";
33 arg_types
[0] = &ffi_type_pointer
;
34 arg_types
[1] = &ffi_type_double
;
37 CHECK(ffi_prep_cif(&cif
, FFI_DEFAULT_ABI
, 2, &ffi_type_sint
,
38 arg_types
) == FFI_OK
);
44 ffi_call(&cif
, FFI_FN(printf
), &res
, args
);
45 // { dg-output "7.0" }
46 printf("res: %d\n", (int) res
);
47 // { dg-output "\nres: 4" }
49 CHECK(ffi_prep_closure_loc(pcl
, &cif
, cls_double_va_fn
, NULL
, code
) == FFI_OK
);
51 res
= ((int(*)(char*, double))(code
))(format
, doubleArg
);
52 // { dg-output "\n7.0" }
53 printf("res: %d\n", (int) res
);
54 // { dg-output "\nres: 4" }