strlen.c 844 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Area: ffi_call
  2. Purpose: Check strlen function call.
  3. Limitations: none.
  4. PR: none.
  5. Originator: From the original ffitest.c */
  6. /* { dg-do run } */
  7. #include "ffitest.h"
  8. static size_t ABI_ATTR my_strlen(char *s)
  9. {
  10. return (strlen(s));
  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. char *s;
  19. args[0] = &ffi_type_pointer;
  20. values[0] = (void*) &s;
  21. /* Initialize the cif */
  22. CHECK(ffi_prep_cif(&cif, ABI_NUM, 1,
  23. &ffi_type_sint, args) == FFI_OK);
  24. s = "a";
  25. ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
  26. CHECK(rint == 1);
  27. s = "1234567";
  28. ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
  29. CHECK(rint == 7);
  30. s = "1234567890123456789012345";
  31. ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
  32. CHECK(rint == 25);
  33. exit (0);
  34. }