1 /* Area: ffi_call, closure_call
2 Purpose: Check long double arguments.
5 Originator: Blake Chaffin */
7 /* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
8 /* { dg-do run { xfail arm*-*-* strongarm*-*-* xscale*-*-* } } */
9 /* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
10 /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
14 long double cls_ldouble_fn(
24 long double r
= a1
+ a2
+ a3
+ a4
+ a5
+ a6
+ a7
+ a8
;
26 printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg: %Lg\n",
27 a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
, r
);
33 cls_ldouble_gn(ffi_cif
* cif __UNUSED__
, void* resp
,
34 void** args
, void* userdata __UNUSED__
)
36 long double a1
= *(long double*)args
[0];
37 long double a2
= *(long double*)args
[1];
38 long double a3
= *(long double*)args
[2];
39 long double a4
= *(long double*)args
[3];
40 long double a5
= *(long double*)args
[4];
41 long double a6
= *(long double*)args
[5];
42 long double a7
= *(long double*)args
[6];
43 long double a8
= *(long double*)args
[7];
45 *(long double*)resp
= cls_ldouble_fn(
46 a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
53 ffi_closure
* pcl
= ffi_closure_alloc(sizeof(ffi_closure
), &code
);
55 ffi_type
* arg_types
[9];
67 arg_types
[0] = &ffi_type_longdouble
;
68 arg_types
[1] = &ffi_type_longdouble
;
69 arg_types
[2] = &ffi_type_longdouble
;
70 arg_types
[3] = &ffi_type_longdouble
;
71 arg_types
[4] = &ffi_type_longdouble
;
72 arg_types
[5] = &ffi_type_longdouble
;
73 arg_types
[6] = &ffi_type_longdouble
;
74 arg_types
[7] = &ffi_type_longdouble
;
77 CHECK(ffi_prep_cif(&cif
, FFI_DEFAULT_ABI
, 8, &ffi_type_longdouble
,
78 arg_types
) == FFI_OK
);
90 ffi_call(&cif
, FFI_FN(cls_ldouble_fn
), &res
, args
);
91 /* { dg-output "1 2 3 4 5 6 7 8: 36" } */
92 printf("res: %Lg\n", res
);
93 /* { dg-output "\nres: 36" } */
95 CHECK(ffi_prep_closure_loc(pcl
, &cif
, cls_ldouble_gn
, NULL
, code
) == FFI_OK
);
97 res
= ((long double(*)(long double, long double, long double, long double,
98 long double, long double, long double, long double))(code
))(arg1
, arg2
,
99 arg3
, arg4
, arg5
, arg6
, arg7
, arg8
);
100 /* { dg-output "\n1 2 3 4 5 6 7 8: 36" } */
101 printf("res: %Lg\n", res
);
102 /* { dg-output "\nres: 36" } */