va_1.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Area: ffi_call
  2. Purpose: Test passing struct in variable argument lists.
  3. Limitations: none.
  4. PR: none.
  5. Originator: ARM Ltd. */
  6. /* { dg-do run } */
  7. #include "ffitest.h"
  8. #include <stdarg.h>
  9. struct small_tag
  10. {
  11. unsigned char a;
  12. unsigned char b;
  13. };
  14. struct large_tag
  15. {
  16. unsigned a;
  17. unsigned b;
  18. unsigned c;
  19. unsigned d;
  20. unsigned e;
  21. };
  22. int
  23. main (void)
  24. {
  25. ffi_cif cif;
  26. ffi_type* arg_types[15];
  27. ffi_type s_type;
  28. ffi_type *s_type_elements[3];
  29. ffi_type l_type;
  30. ffi_type *l_type_elements[6];
  31. s_type.size = 0;
  32. s_type.alignment = 0;
  33. s_type.type = FFI_TYPE_STRUCT;
  34. s_type.elements = s_type_elements;
  35. s_type_elements[0] = &ffi_type_uchar;
  36. s_type_elements[1] = &ffi_type_uchar;
  37. s_type_elements[2] = NULL;
  38. l_type.size = 0;
  39. l_type.alignment = 0;
  40. l_type.type = FFI_TYPE_STRUCT;
  41. l_type.elements = l_type_elements;
  42. l_type_elements[0] = &ffi_type_uint;
  43. l_type_elements[1] = &ffi_type_uint;
  44. l_type_elements[2] = &ffi_type_uint;
  45. l_type_elements[3] = &ffi_type_uint;
  46. l_type_elements[4] = &ffi_type_uint;
  47. l_type_elements[5] = NULL;
  48. arg_types[0] = &ffi_type_sint;
  49. arg_types[1] = &s_type;
  50. arg_types[2] = &l_type;
  51. arg_types[3] = &s_type;
  52. arg_types[4] = &ffi_type_uchar;
  53. arg_types[5] = &ffi_type_schar;
  54. arg_types[6] = &ffi_type_ushort;
  55. arg_types[7] = &ffi_type_sshort;
  56. arg_types[8] = &ffi_type_uint;
  57. arg_types[9] = &ffi_type_sint;
  58. arg_types[10] = &ffi_type_ulong;
  59. arg_types[11] = &ffi_type_slong;
  60. arg_types[12] = &ffi_type_double;
  61. arg_types[13] = &ffi_type_double;
  62. arg_types[14] = NULL;
  63. CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 14, &ffi_type_sint, arg_types) == FFI_BAD_ARGTYPE);
  64. return 0;
  65. }