2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libffi / testsuite / libffi.call / strlen.c
blob3de45de7aaac6ffdce3c806132ac1a7bccfe4b09
1 /* Area: ffi_call
2 Purpose: Check strlen function call.
3 Limitations: none.
4 PR: none.
5 Originator: From the original ffitest.c */
7 /* { dg-do run } */
8 #include "ffitest.h"
10 static size_t my_strlen(char *s)
12 return (strlen(s));
15 int main (void)
17 ffi_cif cif;
18 ffi_type *args[MAX_ARGS];
19 void *values[MAX_ARGS];
20 ffi_arg rint;
21 char *s;
23 args[0] = &ffi_type_pointer;
24 values[0] = (void*) &s;
26 /* Initialize the cif */
27 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
28 &ffi_type_sint, args) == FFI_OK);
30 s = "a";
31 ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
32 CHECK(rint == 1);
34 s = "1234567";
35 ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
36 CHECK(rint == 7);
38 s = "1234567890123456789012345";
39 ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
40 CHECK(rint == 25);
42 exit (0);