OSDN Git Service

* config/m68k/m68k.c, config/m68k/m68k.md (SGS, SGS_CMP_ORDER): Remove
[pf3gnuchains/gcc-fork.git] / libffi / testsuite / libffi.call / float2.c
1 /* Area:        ffi_call
2    Purpose:     Check return value long double.
3    Limitations: none.
4    PR:          none.
5    Originator:  From the original ffitest.c  */
6
7 /* { dg-do run } */
8 #include "ffitest.h"
9 #include "float.h"
10
11 static long double ldblit(float f)
12 {
13   return (long double) (((long double) f)/ (long double) 3.0);
14 }
15
16 int main (void)
17 {
18   ffi_cif cif;
19   ffi_type *args[MAX_ARGS];
20   void *values[MAX_ARGS];
21   float f;
22   long double ld;
23
24   args[0] = &ffi_type_float;
25   values[0] = &f;
26   
27   /* Initialize the cif */
28   CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, 
29                      &ffi_type_longdouble, args) == FFI_OK);
30   
31   f = 3.14159;
32   
33 #if 1 
34   /* This is ifdef'd out for now. long double support under SunOS/gcc
35      is pretty much non-existent.  You'll get the odd bus error in library
36      routines like printf().  */
37   printf ("%Lf\n", ldblit(f));
38 #endif
39   ld = 666;
40   ffi_call(&cif, FFI_FN(ldblit), &ld, values);
41   
42 #if 1 
43   /* This is ifdef'd out for now. long double support under SunOS/gcc
44      is pretty much non-existent.  You'll get the odd bus error in library
45      routines like printf().  */
46   printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON);
47 #endif
48   
49   /* These are not always the same!! Check for a reasonable delta */
50   /*@-realcompare@*/
51   if (ld - ldblit(f) < LDBL_EPSILON)
52     /*@=realcompare@*/
53     puts("long double return value tests ok!");
54   else
55     CHECK(0);
56
57   exit(0);
58 }