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