err_bad_abi.c 780 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* Area: ffi_prep_cif, ffi_prep_closure
  2. Purpose: Test error return for bad ABIs.
  3. Limitations: none.
  4. PR: none.
  5. Originator: Blake Chaffin 6/6/2007 */
  6. /* { dg-do run } */
  7. #include "ffitest.h"
  8. static void
  9. dummy_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
  10. void** args __UNUSED__, void* userdata __UNUSED__)
  11. {}
  12. int main (void)
  13. {
  14. ffi_cif cif;
  15. void *code;
  16. ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
  17. ffi_type* arg_types[1];
  18. arg_types[0] = NULL;
  19. CHECK(ffi_prep_cif(&cif, 255, 0, &ffi_type_void,
  20. arg_types) == FFI_BAD_ABI);
  21. CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &ffi_type_void,
  22. arg_types) == FFI_OK);
  23. cif.abi= 255;
  24. CHECK(ffi_prep_closure_loc(pcl, &cif, dummy_fn, NULL, code) == FFI_BAD_ABI);
  25. exit(0);
  26. }