2015-10-27 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / libffi / testsuite / libffi.call / many_double.c
blob4ef8c8ab28b0de3e404520b9aad2d09256f3d8c3
1 /* Area: ffi_call
2 Purpose: Check return value double, with many arguments
3 Limitations: none.
4 PR: none.
5 Originator: From the original ffitest.c */
7 /* { dg-do run } */
8 #include "ffitest.h"
10 #include <stdlib.h>
11 #include <float.h>
12 #include <math.h>
14 static double many(double f1,
15 double f2,
16 double f3,
17 double f4,
18 double f5,
19 double f6,
20 double f7,
21 double f8,
22 double f9,
23 double f10,
24 double f11,
25 double f12,
26 double f13)
28 #if 0
29 printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n",
30 (double) f1, (double) f2, (double) f3, (double) f4, (double) f5,
31 (double) f6, (double) f7, (double) f8, (double) f9, (double) f10,
32 (double) f11, (double) f12, (double) f13);
33 #endif
35 return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
38 int main (void)
40 ffi_cif cif;
41 ffi_type *args[13];
42 void *values[13];
43 double fa[13];
44 double f, ff;
45 int i;
47 for (i = 0; i < 13; i++)
49 args[i] = &ffi_type_double;
50 values[i] = &fa[i];
51 fa[i] = (double) i;
54 /* Initialize the cif */
55 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13,
56 &ffi_type_double, args) == FFI_OK);
58 ffi_call(&cif, FFI_FN(many), &f, values);
60 ff = many(fa[0], fa[1],
61 fa[2], fa[3],
62 fa[4], fa[5],
63 fa[6], fa[7],
64 fa[8], fa[9],
65 fa[10],fa[11],fa[12]);
66 if (fabs(f - ff) < FLT_EPSILON)
67 exit(0);
68 else
69 abort();