2 Purpose: Check structures.
5 Originator: From the original ffitest.c */
16 static test_structure_9
struct9 (test_structure_9 ts
)
27 ffi_type
*args
[MAX_ARGS
];
28 void *values
[MAX_ARGS
];
30 ffi_type
*ts9_type_elements
[3];
32 test_structure_9 ts9_arg
;
34 /* This is a hack to get a properly aligned result buffer */
35 test_structure_9
*ts9_result
=
36 (test_structure_9
*) malloc (sizeof(test_structure_9
));
39 ts9_type
.alignment
= 0;
40 ts9_type
.type
= FFI_TYPE_STRUCT
;
41 ts9_type
.elements
= ts9_type_elements
;
42 ts9_type_elements
[0] = &ffi_type_float
;
43 ts9_type_elements
[1] = &ffi_type_sint
;
44 ts9_type_elements
[2] = NULL
;
49 /* Initialize the cif */
50 CHECK(ffi_prep_cif(&cif
, FFI_DEFAULT_ABI
, 1, &ts9_type
, args
) == FFI_OK
);
55 printf ("%g\n", ts9_arg
.f
);
56 printf ("%d\n", ts9_arg
.i
);
58 ffi_call(&cif
, FFI_FN(struct9
), ts9_result
, values
);
60 printf ("%g\n", ts9_result
->f
);
61 printf ("%d\n", ts9_result
->i
);
63 CHECK(ts9_result
->f
== 5.55f
+ 1);
64 CHECK(ts9_result
->i
== 5 + 1);