cls_uchar_va.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Area: closure_call
  2. Purpose: Test anonymous unsigned char argument.
  3. Limitations: none.
  4. PR: none.
  5. Originator: ARM Ltd. */
  6. /* { dg-do run } */
  7. #include "ffitest.h"
  8. typedef unsigned char T;
  9. static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
  10. void* userdata __UNUSED__)
  11. {
  12. *(ffi_arg *)resp = *(T *)args[0];
  13. printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]);
  14. }
  15. typedef T (*cls_ret_T)(T, ...);
  16. int main (void)
  17. {
  18. ffi_cif cif;
  19. void *code;
  20. ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
  21. ffi_type * cl_arg_types[3];
  22. T res;
  23. cl_arg_types[0] = &ffi_type_uchar;
  24. cl_arg_types[1] = &ffi_type_uchar;
  25. cl_arg_types[2] = NULL;
  26. /* Initialize the cif */
  27. CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
  28. &ffi_type_uchar, cl_arg_types) == FFI_OK);
  29. CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
  30. res = ((((cls_ret_T)code)(67, 4)));
  31. /* { dg-output "67: 67 4" } */
  32. printf("res: %d\n", res);
  33. /* { dg-output "\nres: 67" } */
  34. exit(0);
  35. }