ยปCore Development>Code coverage>Modules/_ctypes/libffi/testsuite/libffi.call/strlen2_win32.c

Python code coverage for Modules/_ctypes/libffi/testsuite/libffi.call/strlen2_win32.c

#countcontent
1n/a/* Area: ffi_call
2n/a Purpose: Check fastcall strlen call on X86_WIN32 systems.
3n/a Limitations: none.
4n/a PR: none.
5n/a Originator: From the original ffitest.c */
6n/a
7n/a/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8n/a
9n/a#include "ffitest.h"
10n/a
11n/astatic size_t __FASTCALL__ my_fastcall_strlen(char *s)
12n/a{
13n/a return (strlen(s));
14n/a}
15n/a
16n/aint main (void)
17n/a{
18n/a ffi_cif cif;
19n/a ffi_type *args[MAX_ARGS];
20n/a void *values[MAX_ARGS];
21n/a ffi_arg rint;
22n/a char *s;
23n/a args[0] = &ffi_type_pointer;
24n/a values[0] = (void*) &s;
25n/a
26n/a /* Initialize the cif */
27n/a CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1,
28n/a &ffi_type_sint, args) == FFI_OK);
29n/a
30n/a s = "a";
31n/a ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
32n/a CHECK(rint == 1);
33n/a
34n/a s = "1234567";
35n/a ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
36n/a CHECK(rint == 7);
37n/a
38n/a s = "1234567890123456789012345";
39n/a ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
40n/a CHECK(rint == 25);
41n/a
42n/a printf("fastcall strlen tests passed\n");
43n/a exit(0);
44n/a}