ยปCore Development>Code coverage>Modules/_ctypes/libffi/testsuite/libffi.call/float2.c

Python code coverage for Modules/_ctypes/libffi/testsuite/libffi.call/float2.c

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