1 /* Area: ffi_call, closure_call
2 Purpose: Test long doubles passed in variable argument lists.
5 Originator: Blake Chaffin 6/6/2007 */
7 /* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* x86_64-*-mingw* x86_64-*-cygwin* } } */
11 cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp,
12 void** args, void* userdata __UNUSED__)
14 char* format = *(char**)args[0];
15 long double ldValue = *(long double*)args[1];
17 *(ffi_arg*)resp = printf(format, ldValue);
24 static ffi_closure cl;
28 ffi_type* arg_types[3];
31 pcl = allocate_mmap (sizeof(ffi_closure));
36 char* format = "%L.1f\n";
37 long double ldArg = 7;
40 arg_types[0] = &ffi_type_pointer;
41 arg_types[1] = &ffi_type_longdouble;
44 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint,
45 arg_types) == FFI_OK);
51 ffi_call(&cif, FFI_FN(printf), &res, args);
52 // { dg-output "7.0" { xfail i*86-*-linux-* x86_64-*-linux-* sh*-*-linux-* } }
53 printf("res: %d\n", (int) res);
54 // { dg-output "\nres: 4" { xfail i*86-*-linux-* x86_64-*-linux-* sh*-*-linux-* } }
56 CHECK(ffi_prep_closure(pcl, &cif, cls_longdouble_va_fn, NULL) == FFI_OK);
58 res = ((int(*)(char*, long double))(pcl))(format, ldArg);
59 // { dg-output "\n7.0" }
60 printf("res: %d\n", (int) res);
61 // { dg-output "\nres: 4" }