2012-02-02 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / libffi / testsuite / libffi.call / strlen2_win32.c
blobb348e434097904e54e74bd15430a111831cb7bb5
1 /* Area: ffi_call
2 Purpose: Check fastcall strlen call on X86_WIN32 systems.
3 Limitations: none.
4 PR: none.
5 Originator: From the original ffitest.c */
7 /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
9 #include "ffitest.h"
11 static size_t __attribute__((fastcall)) my_fastcall_strlen(char *s)
13 return (strlen(s));
16 int d
17 int main (void)
19 ffi_cif cif;
20 ffi_type *args[MAX_ARGS];
21 void *values[MAX_ARGS];
22 ffi_arg rint;
23 char *s;
24 args[0] = &ffi_type_pointer;
25 values[0] = (void*) &s;
27 /* Initialize the cif */
28 CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1,
29 &ffi_type_sint, args) == FFI_OK);
31 s = "a";
32 ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
33 CHECK(rint == 1);
35 s = "1234567";
36 ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
37 CHECK(rint == 7);
39 s = "1234567890123456789012345";
40 ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
41 CHECK(rint == 25);
43 printf("fastcall strlen tests passed\n");
44 exit(0);