2 Purpose: Check structures.
5 Originator: From the original ffitest.c */
17 static test_structure_1 ABI_ATTR
struct1(test_structure_1 ts
)
29 ffi_type
*args
[MAX_ARGS
];
30 void *values
[MAX_ARGS
];
32 ffi_type
*ts1_type_elements
[4];
34 test_structure_1 ts1_arg
;
36 /* This is a hack to get a properly aligned result buffer */
37 test_structure_1
*ts1_result
=
38 (test_structure_1
*) malloc (sizeof(test_structure_1
));
41 ts1_type
.alignment
= 0;
42 ts1_type
.type
= FFI_TYPE_STRUCT
;
43 ts1_type
.elements
= ts1_type_elements
;
44 ts1_type_elements
[0] = &ffi_type_uchar
;
45 ts1_type_elements
[1] = &ffi_type_double
;
46 ts1_type_elements
[2] = &ffi_type_uint
;
47 ts1_type_elements
[3] = NULL
;
52 /* Initialize the cif */
53 CHECK(ffi_prep_cif(&cif
, ABI_NUM
, 1,
54 &ts1_type
, args
) == FFI_OK
);
60 ffi_call(&cif
, FFI_FN(struct1
), ts1_result
, values
);
62 CHECK(ts1_result
->ui
== 556);
63 CHECK(ts1_result
->d
== 3.14159 - 1);