return_dbl1.c 1004 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Area: ffi_call
  2. Purpose: Check return value double.
  3. Limitations: none.
  4. PR: none.
  5. Originator: <andreast@gcc.gnu.org> 20050212 */
  6. /* { dg-do run } */
  7. #include "ffitest.h"
  8. static double return_dbl(double dbl1, float fl2, unsigned int in3, double dbl4)
  9. {
  10. return dbl1 + fl2 + in3 + dbl4;
  11. }
  12. int main (void)
  13. {
  14. ffi_cif cif;
  15. ffi_type *args[MAX_ARGS];
  16. void *values[MAX_ARGS];
  17. double dbl1, dbl4, rdbl;
  18. float fl2;
  19. unsigned int in3;
  20. args[0] = &ffi_type_double;
  21. args[1] = &ffi_type_float;
  22. args[2] = &ffi_type_uint;
  23. args[3] = &ffi_type_double;
  24. values[0] = &dbl1;
  25. values[1] = &fl2;
  26. values[2] = &in3;
  27. values[3] = &dbl4;
  28. /* Initialize the cif */
  29. CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
  30. &ffi_type_double, args) == FFI_OK);
  31. dbl1 = 127.0;
  32. fl2 = 128.0;
  33. in3 = 255;
  34. dbl4 = 512.7;
  35. ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values);
  36. printf ("%f vs %f\n", rdbl, return_dbl(dbl1, fl2, in3, dbl4));
  37. CHECK(rdbl == dbl1 + fl2 + in3 + dbl4);
  38. exit(0);
  39. }