/js/src/ctypes/libffi/testsuite/libffi.call/many.c

http://github.com/zpao/v8monkey · C · 69 lines · 52 code · 10 blank · 7 comment · 3 complexity · f5260f5f182a88a7a32d7079b77a540b MD5 · raw file

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