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

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

#countcontent
1n/a/* { dg-do run } */
2n/a#include "ffitest.h"
3n/a
4n/atypedef struct
5n/a{
6n/a unsigned char uc;
7n/a double d;
8n/a unsigned int ui;
9n/a} test_structure_1;
10n/a
11n/astatic test_structure_1 struct1(test_structure_1 ts)
12n/a{
13n/a ts.uc++;
14n/a ts.d--;
15n/a ts.ui++;
16n/a
17n/a return ts;
18n/a}
19n/a
20n/aint main (void)
21n/a{
22n/a ffi_cif cif;
23n/a ffi_type *args[MAX_ARGS];
24n/a void *values[MAX_ARGS];
25n/a ffi_type ts1_type;
26n/a ffi_type *ts1_type_elements[4];
27n/a
28n/a memset(&cif, 1, sizeof(cif));
29n/a ts1_type.size = 0;
30n/a ts1_type.alignment = 0;
31n/a ts1_type.type = FFI_TYPE_STRUCT;
32n/a ts1_type.elements = ts1_type_elements;
33n/a ts1_type_elements[0] = &ffi_type_uchar;
34n/a ts1_type_elements[1] = &ffi_type_double;
35n/a ts1_type_elements[2] = &ffi_type_uint;
36n/a ts1_type_elements[3] = NULL;
37n/a
38n/a test_structure_1 ts1_arg;
39n/a /* This is a hack to get a properly aligned result buffer */
40n/a test_structure_1 *ts1_result =
41n/a (test_structure_1 *) malloc (sizeof(test_structure_1));
42n/a
43n/a args[0] = &ts1_type;
44n/a values[0] = &ts1_arg;
45n/a
46n/a /* Initialize the cif */
47n/a CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
48n/a &ts1_type, args) == FFI_OK);
49n/a
50n/a ts1_arg.uc = '\x01';
51n/a ts1_arg.d = 3.14159;
52n/a ts1_arg.ui = 555;
53n/a
54n/a ffi_call(&cif, FFI_FN(struct1), ts1_result, values);
55n/a
56n/a CHECK(ts1_result->ui == 556);
57n/a CHECK(ts1_result->d == 3.14159 - 1);
58n/a
59n/a free (ts1_result);
60n/a exit(0);
61n/a}