2 Purpose: Check structures.
5 Originator: From the original ffitest.c */
16 static test_structure_7
struct7 (test_structure_7 ts
)
28 ffi_type
*args
[MAX_ARGS
];
29 void *values
[MAX_ARGS
];
31 ffi_type
*ts7_type_elements
[4];
33 ts7_type
.alignment
= 0;
34 ts7_type
.type
= FFI_TYPE_STRUCT
;
35 ts7_type
.elements
= ts7_type_elements
;
36 ts7_type_elements
[0] = &ffi_type_float
;
37 ts7_type_elements
[1] = &ffi_type_float
;
38 ts7_type_elements
[2] = &ffi_type_double
;
39 ts7_type_elements
[3] = NULL
;
42 test_structure_7 ts7_arg
;
44 /* This is a hack to get a properly aligned result buffer */
45 test_structure_7
*ts7_result
=
46 (test_structure_7
*) malloc (sizeof(test_structure_7
));
51 /* Initialize the cif */
52 CHECK(ffi_prep_cif(&cif
, FFI_DEFAULT_ABI
, 1, &ts7_type
, args
) == FFI_OK
);
58 printf ("%g\n", ts7_arg
.f1
);
59 printf ("%g\n", ts7_arg
.f2
);
60 printf ("%g\n", ts7_arg
.d
);
62 ffi_call(&cif
, FFI_FN(struct7
), ts7_result
, values
);
64 printf ("%g\n", ts7_result
->f1
);
65 printf ("%g\n", ts7_result
->f2
);
66 printf ("%g\n", ts7_result
->d
);
68 CHECK(ts7_result
->f1
== 5.55f
+ 1);
69 CHECK(ts7_result
->f2
== 55.5f
+ 1);
70 CHECK(ts7_result
->d
== 6.66 + 1);