Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

float2.c
Go to the documentation of this file.
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-excess-errors "fails" { target x86_64-*-mingw* x86_64-*-cygwin* x86_64-*-msys* } } */
8 /* { dg-do run { xfail x86_64-*-mingw* x86_64-*-cygwin* x86_64-*-msys* } } */
9
10 #include "ffitest.h"
11 #include "float.h"
12
13 static long double ldblit(float f)
14 {
15 return (long double) (((long double) f)/ (long double) 3.0);
16 }
17
18 int main (void)
19 {
20 ffi_cif cif;
21 ffi_type *args[MAX_ARGS];
22 void *values[MAX_ARGS];
23 float f;
24 long double ld;
25
26 args[0] = &ffi_type_float;
27 values[0] = &f;
28
29 /* Initialize the cif */
30 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
31 &ffi_type_longdouble, args) == FFI_OK);
32
33 f = 3.14159;
34
35 #if 1
36 /* This is ifdef'd out for now. long double support under SunOS/gcc
37 is pretty much non-existent. You'll get the odd bus error in library
38 routines like printf(). */
39 printf ("%Lf\n", ldblit(f));
40 #endif
41 ld = 666;
42 ffi_call(&cif, FFI_FN(ldblit), &ld, values);
43
44 #if 1
45 /* This is ifdef'd out for now. long double support under SunOS/gcc
46 is pretty much non-existent. You'll get the odd bus error in library
47 routines like printf(). */
48 printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON);
49 #endif
50
51 /* These are not always the same!! Check for a reasonable delta */
52 if (ld - ldblit(f) < LDBL_EPSILON)
53 puts("long double return value tests ok!");
54 else
55 CHECK(0);
56
57 exit(0);
58 }
printf
int int int printf(const char *__restrict,...) __attribute__((__format__(__printf__
exit
void exit(int __status) __attribute__((__noreturn__))
ffitest.h
double
double
Definition: rb_mjit_min_header-2.7.0.h:5923
puts
int puts(const char *)
CHECK
#define CHECK(sub)
Definition: compile.c:448
FFI_DEFAULT_ABI
@ FFI_DEFAULT_ABI
Definition: ffitarget.h:38
f
#define f
main
int main(void)
Definition: float2.c:18
ffi_prep_cif
ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, ffi_type *rtype, ffi_type **atypes)
Definition: prep_cif.c:226
MAX_ARGS
#define MAX_ARGS
Definition: function.c:15
ffi_call
void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
Definition: ffi.c:813