1/* Area: ffi_call 2 Purpose: Check return value float. 3 Limitations: none. 4 PR: none. 5 Originator: From the original ffitest.c */ 6 7/* { dg-do run } */ 8/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */ 9 10#include "ffitest.h" 11 12static int floating(int a, float b, double c, long double d, int e) 13{ 14 int i; 15 16 printf("%d\n", e); 17 printf("a:%d b:%f c:%f d:%llf e:%d\n", a, b, c, d, e); 18 i = (int) ((float)a/b + ((float)c/(float)d)); 19 20 return i; 21} 22 23int main (void) 24{ 25 ffi_cif cif; 26 ffi_type *args[MAX_ARGS]; 27 void *values[MAX_ARGS]; 28 ffi_arg rint; 29 30 float f; 31 signed int si1; 32 double d; 33 long double ld; 34 signed int si2; 35 36 args[0] = &ffi_type_sint; 37 values[0] = &si1; 38 args[1] = &ffi_type_float; 39 values[1] = &f; 40 args[2] = &ffi_type_double; 41 values[2] = &d; 42 args[3] = &ffi_type_longdouble; 43 values[3] = &ld; 44 args[4] = &ffi_type_sint; 45 values[4] = &si2; 46 47 /* Initialize the cif */ 48 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 5, 49 &ffi_type_sint, args) == FFI_OK); 50 51 si1 = 6; 52 f = 3.14159; 53 d = (double)1.0/(double)3.0; 54 ld = 2.71828182846L; 55 si2 = 10; 56 57 floating (si1, f, d, ld, si2); 58 59 printf("calling through ffi %d\n", si2); 60 ffi_call(&cif, FFI_FN(floating), &rint, values); 61 62 printf ("%d vs %d\n", (int)rint, floating (si1, f, d, ld, si2)); 63 64 CHECK(rint == floating(si1, f, d, ld, si2)); 65 66 exit (0); 67} 68