many_complex.inc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* -*-c-*- */
  2. #include "ffitest.h"
  3. #include <stdlib.h>
  4. #include <complex.h>
  5. static _Complex T_C_TYPE many(_Complex T_C_TYPE c1,
  6. _Complex T_C_TYPE c2,
  7. _Complex T_C_TYPE c3,
  8. _Complex T_C_TYPE c4,
  9. _Complex T_C_TYPE c5,
  10. _Complex T_C_TYPE c6,
  11. _Complex T_C_TYPE c7,
  12. _Complex T_C_TYPE c8,
  13. _Complex T_C_TYPE c9,
  14. _Complex T_C_TYPE c10,
  15. _Complex T_C_TYPE c11,
  16. _Complex T_C_TYPE c12,
  17. _Complex T_C_TYPE c13)
  18. {
  19. printf("0 :%f,%fi\n"
  20. "1 :%f,%fi\n"
  21. "2 :%f,%fi\n"
  22. "3 :%f,%fi\n"
  23. "4 :%f,%fi\n"
  24. "5 :%f,%fi\n"
  25. "6 :%f,%fi\n"
  26. "7 :%f,%fi\n"
  27. "8 :%f,%fi\n"
  28. "9 :%f,%fi\n"
  29. "10:%f,%fi\n"
  30. "11:%f,%fi\n"
  31. "12:%f,%fi\n",
  32. T_CONV creal (c1), T_CONV cimag (c1),
  33. T_CONV creal (c2), T_CONV cimag (c2),
  34. T_CONV creal (c3), T_CONV cimag (c3),
  35. T_CONV creal (c4), T_CONV cimag (c4),
  36. T_CONV creal (c5), T_CONV cimag (c5),
  37. T_CONV creal (c6), T_CONV cimag (c6),
  38. T_CONV creal (c7), T_CONV cimag (c7),
  39. T_CONV creal (c8), T_CONV cimag (c8),
  40. T_CONV creal (c9), T_CONV cimag (c9),
  41. T_CONV creal (c10), T_CONV cimag (c10),
  42. T_CONV creal (c11), T_CONV cimag (c11),
  43. T_CONV creal (c12), T_CONV cimag (c12),
  44. T_CONV creal (c13), T_CONV cimag (c13));
  45. return (c1+c2-c3-c4+c5+c6+c7-c8-c9-c10-c11+c12+c13);
  46. }
  47. int main (void)
  48. {
  49. ffi_cif cif;
  50. ffi_type *args[13];
  51. void *values[13];
  52. _Complex T_C_TYPE ca[13];
  53. _Complex T_C_TYPE c, cc;
  54. int i;
  55. for (i = 0; i < 13; i++)
  56. {
  57. args[i] = &T_FFI_TYPE;
  58. values[i] = &ca[i];
  59. ca[i] = i + (-20 - i) * I;
  60. }
  61. /* Initialize the cif */
  62. CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13, &T_FFI_TYPE, args) == FFI_OK);
  63. ffi_call(&cif, FFI_FN(many), &c, values);
  64. cc = many(ca[0], ca[1], ca[2], ca[3], ca[4], ca[5], ca[6], ca[7], ca[8],
  65. ca[9], ca[10], ca[11], ca[12]);
  66. CHECK(creal (cc) == creal (c));
  67. CHECK(cimag (cc) == cimag (c));
  68. exit(0);
  69. }