2 Purpose: Check structures.
5 Originator: From the original ffitest.c */
17 static test_structure_4 ABI_ATTR
struct4(test_structure_4 ts
)
19 ts
.ui3
= ts
.ui1
* ts
.ui2
* ts
.ui3
;
27 ffi_type
*args
[MAX_ARGS
];
28 void *values
[MAX_ARGS
];
30 ffi_type
*ts4_type_elements
[4];
32 test_structure_4 ts4_arg
;
34 /* This is a hack to get a properly aligned result buffer */
35 test_structure_4
*ts4_result
=
36 (test_structure_4
*) malloc (sizeof(test_structure_4
));
39 ts4_type
.alignment
= 0;
40 ts4_type
.type
= FFI_TYPE_STRUCT
;
41 ts4_type
.elements
= ts4_type_elements
;
42 ts4_type_elements
[0] = &ffi_type_uint
;
43 ts4_type_elements
[1] = &ffi_type_uint
;
44 ts4_type_elements
[2] = &ffi_type_uint
;
45 ts4_type_elements
[3] = NULL
;
50 /* Initialize the cif */
51 CHECK(ffi_prep_cif(&cif
, ABI_NUM
, 1, &ts4_type
, args
) == FFI_OK
);
57 ffi_call (&cif
, FFI_FN(struct4
), ts4_result
, values
);
59 CHECK(ts4_result
->ui3
== 2U * 3U * 4U);