Make-lang.in: Update dependencies.
[official-gcc.git] / libffi / testsuite / libffi.call / cls_longdouble_va.c
blob07780ede4cd8d0b54dd8eb8dc61cb28cb71d3d8a
1 /* Area: ffi_call, closure_call
2 Purpose: Test long doubles passed in variable argument lists.
3 Limitations: none.
4 PR: none.
5 Originator: Blake Chaffin 6/6/2007 */
7 /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
8 /* { dg-output "" { xfail avr32*-*-* x86_64-*-mingw* } } */
9 /* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */
10 /* { dg-skip-if "" arm*-*-* { "-mfloat-abi=hard" } { "" } } */
12 #include "ffitest.h"
14 static void
15 cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp,
16 void** args, void* userdata __UNUSED__)
18 char* format = *(char**)args[0];
19 long double ldValue = *(long double*)args[1];
21 *(ffi_arg*)resp = printf(format, ldValue);
24 int main (void)
26 ffi_cif cif;
27 void *code;
28 ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
29 void* args[3];
30 ffi_type* arg_types[3];
32 char* format = "%.1Lf\n";
33 long double ldArg = 7;
34 ffi_arg res = 0;
36 arg_types[0] = &ffi_type_pointer;
37 arg_types[1] = &ffi_type_longdouble;
38 arg_types[2] = NULL;
40 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint,
41 arg_types) == FFI_OK);
43 args[0] = &format;
44 args[1] = &ldArg;
45 args[2] = NULL;
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_longdouble_va_fn, NULL, code) == FFI_OK);
54 res = ((int(*)(char*, long double))(code))(format, ldArg);
55 // { dg-output "\n7.0" }
56 printf("res: %d\n", (int) res);
57 // { dg-output "\nres: 4" }
59 exit(0);