many_double.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Area: ffi_call
  2. Purpose: Check return value double, 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 double many(double f1,
  12. double f2,
  13. double f3,
  14. double f4,
  15. double f5,
  16. double f6,
  17. double f7,
  18. double f8,
  19. double f9,
  20. double f10,
  21. double f11,
  22. double f12,
  23. double f13)
  24. {
  25. #if 0
  26. printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n",
  27. (double) f1, (double) f2, (double) f3, (double) f4, (double) f5,
  28. (double) f6, (double) f7, (double) f8, (double) f9, (double) f10,
  29. (double) f11, (double) f12, (double) f13);
  30. #endif
  31. return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
  32. }
  33. int main (void)
  34. {
  35. ffi_cif cif;
  36. ffi_type *args[13];
  37. void *values[13];
  38. double fa[13];
  39. double f, ff;
  40. int i;
  41. for (i = 0; i < 13; i++)
  42. {
  43. args[i] = &ffi_type_double;
  44. values[i] = &fa[i];
  45. fa[i] = (double) i;
  46. }
  47. /* Initialize the cif */
  48. CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13,
  49. &ffi_type_double, args) == FFI_OK);
  50. ffi_call(&cif, FFI_FN(many), &f, values);
  51. ff = many(fa[0], fa[1],
  52. fa[2], fa[3],
  53. fa[4], fa[5],
  54. fa[6], fa[7],
  55. fa[8], fa[9],
  56. fa[10],fa[11],fa[12]);
  57. if (fabs(f - ff) < FLT_EPSILON)
  58. exit(0);
  59. else
  60. abort();
  61. }