many.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Area: ffi_call
  2. Purpose: Check return value float, with many arguments
  3. Limitations: none.
  4. PR: none.
  5. Originator: From the original ffitest.c */
  6. /* { dg-do run } */
  7. #include "ffitest.h"
  8. #include <stdlib.h>
  9. #include <float.h>
  10. #include <math.h>
  11. static float ABI_ATTR many(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13)
  12. {
  13. #if 0
  14. printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n",
  15. (double) f1, (double) f2, (double) f3, (double) f4, (double) f5,
  16. (double) f6, (double) f7, (double) f8, (double) f9, (double) f10,
  17. (double) f11, (double) f12, (double) f13);
  18. #endif
  19. return f1+f2+f3+f4+f5+f6+f7+f8+f9+f10+f11+f12+f13;
  20. }
  21. int main (void)
  22. {
  23. ffi_cif cif;
  24. ffi_type *args[13];
  25. void *values[13];
  26. float fa[13];
  27. float f, ff;
  28. int i;
  29. for (i = 0; i < 13; i++)
  30. {
  31. args[i] = &ffi_type_float;
  32. values[i] = &fa[i];
  33. fa[i] = (float) i;
  34. }
  35. /* Initialize the cif */
  36. CHECK(ffi_prep_cif(&cif, ABI_NUM, 13,
  37. &ffi_type_float, args) == FFI_OK);
  38. ffi_call(&cif, FFI_FN(many), &f, values);
  39. ff = many(fa[0], fa[1],
  40. fa[2], fa[3],
  41. fa[4], fa[5],
  42. fa[6], fa[7],
  43. fa[8], fa[9],
  44. fa[10],fa[11],fa[12]);
  45. if (fabs(f - ff) < FLT_EPSILON)
  46. exit(0);
  47. else
  48. abort();
  49. }