return_sc.c 726 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* Area: ffi_call
  2. Purpose: Check return value signed char.
  3. Limitations: none.
  4. PR: none.
  5. Originator: From the original ffitest.c */
  6. /* { dg-do run } */
  7. #include "ffitest.h"
  8. static signed char return_sc(signed char sc)
  9. {
  10. return sc;
  11. }
  12. int main (void)
  13. {
  14. ffi_cif cif;
  15. ffi_type *args[MAX_ARGS];
  16. void *values[MAX_ARGS];
  17. ffi_arg rint;
  18. signed char sc;
  19. args[0] = &ffi_type_schar;
  20. values[0] = ≻
  21. /* Initialize the cif */
  22. CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
  23. &ffi_type_schar, args) == FFI_OK);
  24. for (sc = (signed char) -127;
  25. sc < (signed char) 127; sc++)
  26. {
  27. ffi_call(&cif, FFI_FN(return_sc), &rint, values);
  28. CHECK((signed char)rint == sc);
  29. }
  30. exit(0);
  31. }