Fix a bug in cfg fixup
[official-gcc.git] / libffi / testsuite / libffi.call / float.c
blobfbc272d84f1fa894f0c26e8765ed9c109f7dacff
1 /* Area: ffi_call
2 Purpose: Check return value float.
3 Limitations: none.
4 PR: none.
5 Originator: From the original ffitest.c */
7 /* { dg-do run } */
9 #include "ffitest.h"
11 static int floating(int a, float b, double c, long double d)
13 int i;
15 i = (int) ((float)a/b + ((float)c/(float)d));
17 return i;
20 int main (void)
22 ffi_cif cif;
23 ffi_type *args[MAX_ARGS];
24 void *values[MAX_ARGS];
25 ffi_arg rint;
27 float f;
28 signed int si1;
29 double d;
30 long double ld;
32 args[0] = &ffi_type_sint;
33 values[0] = &si1;
34 args[1] = &ffi_type_float;
35 values[1] = &f;
36 args[2] = &ffi_type_double;
37 values[2] = &d;
38 args[3] = &ffi_type_longdouble;
39 values[3] = &ld;
41 /* Initialize the cif */
42 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
43 &ffi_type_sint, args) == FFI_OK);
45 si1 = 6;
46 f = 3.14159;
47 d = (double)1.0/(double)3.0;
48 ld = 2.71828182846L;
50 floating (si1, f, d, ld);
52 ffi_call(&cif, FFI_FN(floating), &rint, values);
54 printf ("%d vs %d\n", (int)rint, floating (si1, f, d, ld));
56 CHECK((int)rint == floating(si1, f, d, ld));
58 exit (0);