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

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

#countcontent
1n/a/* Area: closure_call
2n/a Purpose: Check multiple values passing from different type.
3n/a Also, exceed the limit of gpr and fpr registers on PowerPC
4n/a Darwin.
5n/a Limitations: none.
6n/a PR: none.
7n/a Originator: <andreast@gcc.gnu.org> 20030828 */
8n/a
9n/a
10n/a
11n/a
12n/a/* { dg-do run } */
13n/a#include "ffitest.h"
14n/a
15n/astatic void
16n/aclosure_loc_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
17n/a void* userdata)
18n/a{
19n/a *(ffi_arg*)resp =
20n/a (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) +
21n/a (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] +
22n/a (int)(*(signed short *)args[4]) +
23n/a (int)(*(unsigned long long *)args[5]) +
24n/a (int)*(int *)args[6] + (int)(*(int *)args[7]) +
25n/a (int)(*(double *)args[8]) + (int)*(int *)args[9] +
26n/a (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
27n/a (int)*(int *)args[12] + (int)(*(int *)args[13]) +
28n/a (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
29n/a
30n/a printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
31n/a (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]),
32n/a (int)(*(unsigned long long *)args[2]),
33n/a (int)*(int *)args[3], (int)(*(signed short *)args[4]),
34n/a (int)(*(unsigned long long *)args[5]),
35n/a (int)*(int *)args[6], (int)(*(int *)args[7]),
36n/a (int)(*(double *)args[8]), (int)*(int *)args[9],
37n/a (int)(*(int *)args[10]), (int)(*(float *)args[11]),
38n/a (int)*(int *)args[12], (int)(*(int *)args[13]),
39n/a (int)(*(int *)args[14]),*(int *)args[15],
40n/a (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
41n/a
42n/a}
43n/a
44n/atypedef int (*closure_loc_test_type0)(unsigned long long, int, unsigned long long,
45n/a int, signed short, unsigned long long, int,
46n/a int, double, int, int, float, int, int,
47n/a int, int);
48n/a
49n/aint main (void)
50n/a{
51n/a ffi_cif cif;
52n/a ffi_closure *pcl;
53n/a ffi_type * cl_arg_types[17];
54n/a int res;
55n/a void *codeloc;
56n/a
57n/a cl_arg_types[0] = &ffi_type_uint64;
58n/a cl_arg_types[1] = &ffi_type_sint;
59n/a cl_arg_types[2] = &ffi_type_uint64;
60n/a cl_arg_types[3] = &ffi_type_sint;
61n/a cl_arg_types[4] = &ffi_type_sshort;
62n/a cl_arg_types[5] = &ffi_type_uint64;
63n/a cl_arg_types[6] = &ffi_type_sint;
64n/a cl_arg_types[7] = &ffi_type_sint;
65n/a cl_arg_types[8] = &ffi_type_double;
66n/a cl_arg_types[9] = &ffi_type_sint;
67n/a cl_arg_types[10] = &ffi_type_sint;
68n/a cl_arg_types[11] = &ffi_type_float;
69n/a cl_arg_types[12] = &ffi_type_sint;
70n/a cl_arg_types[13] = &ffi_type_sint;
71n/a cl_arg_types[14] = &ffi_type_sint;
72n/a cl_arg_types[15] = &ffi_type_sint;
73n/a cl_arg_types[16] = NULL;
74n/a
75n/a /* Initialize the cif */
76n/a CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
77n/a &ffi_type_sint, cl_arg_types) == FFI_OK);
78n/a
79n/a pcl = ffi_closure_alloc(sizeof(ffi_closure), &codeloc);
80n/a CHECK(pcl != NULL);
81n/a CHECK(codeloc != NULL);
82n/a
83n/a CHECK(ffi_prep_closure_loc(pcl, &cif, closure_loc_test_fn0,
84n/a (void *) 3 /* userdata */, codeloc) == FFI_OK);
85n/a
86n/a CHECK(memcmp(pcl, codeloc, sizeof(*pcl)) == 0);
87n/a
88n/a res = (*((closure_loc_test_type0)codeloc))
89n/a (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13,
90n/a 19, 21, 1);
91n/a /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
92n/a printf("res: %d\n",res);
93n/a /* { dg-output "\nres: 680" } */
94n/a exit(0);
95n/a}