return_fl3.c 967 B

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