align_mixed.c 992 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Area: ffi_call
  2. Purpose: Check for proper argument alignment.
  3. Limitations: none.
  4. PR: none.
  5. Originator: <twalljava@java.net> (from many_win32.c) */
  6. /* { dg-do run } */
  7. #include "ffitest.h"
  8. static float ABI_ATTR align_arguments(int i1,
  9. double f2,
  10. int i3,
  11. double f4)
  12. {
  13. return i1+f2+i3+f4;
  14. }
  15. int main(void)
  16. {
  17. ffi_cif cif;
  18. ffi_type *args[4] = {
  19. &ffi_type_sint,
  20. &ffi_type_double,
  21. &ffi_type_sint,
  22. &ffi_type_double
  23. };
  24. double fa[2] = {1,2};
  25. int ia[2] = {1,2};
  26. void *values[4] = {&ia[0], &fa[0], &ia[1], &fa[1]};
  27. float f, ff;
  28. /* Initialize the cif */
  29. CHECK(ffi_prep_cif(&cif, ABI_NUM, 4,
  30. &ffi_type_float, args) == FFI_OK);
  31. ff = align_arguments(ia[0], fa[0], ia[1], fa[1]);
  32. ffi_call(&cif, FFI_FN(align_arguments), &f, values);
  33. if (f == ff)
  34. printf("align arguments tests ok!\n");
  35. else
  36. CHECK(0);
  37. exit(0);
  38. }