2003-11-08 Andreas Tobler <a.tobler@schweiz.ch>
[official-gcc.git] / libffi / testsuite / libffi.call / float1.c
blob94636a230ed89b40643cdc73d9d098a8b3fb0618
1 /* Area: ffi_call
2 Purpose: Check return value double.
3 Limitations: none.
4 PR: none.
5 Originator: From the original ffitest.c */
7 /* { dg-do run } */
8 #include "ffitest.h"
9 #include "float.h"
11 static double dblit(float f)
13 return f/3.0;
16 int main (void)
18 ffi_cif cif;
19 ffi_type *args[MAX_ARGS];
20 void *values[MAX_ARGS];
21 float f;
22 double d;
25 args[0] = &ffi_type_float;
26 values[0] = &f;
28 /* Initialize the cif */
29 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
30 &ffi_type_double, args) == FFI_OK);
32 f = 3.14159;
34 ffi_call(&cif, FFI_FN(dblit), &d, values);
36 /* These are not always the same!! Check for a reasonable delta */
38 CHECK(d - dblit(f) < DBL_EPSILON);
40 exit(0);