2
Purpose: Check structures.
5
Originator: From the original ffitest.c */
17
static test_structure_8 struct8 (test_structure_8 ts)
30
ffi_type *args[MAX_ARGS];
31
void *values[MAX_ARGS];
33
ffi_type *ts8_type_elements[5];
35
ts8_type.alignment = 0;
36
ts8_type.type = FFI_TYPE_STRUCT;
37
ts8_type.elements = ts8_type_elements;
38
ts8_type_elements[0] = &ffi_type_float;
39
ts8_type_elements[1] = &ffi_type_float;
40
ts8_type_elements[2] = &ffi_type_float;
41
ts8_type_elements[3] = &ffi_type_float;
42
ts8_type_elements[4] = NULL;
44
test_structure_8 ts8_arg;
46
/* This is a hack to get a properly aligned result buffer */
47
test_structure_8 *ts8_result =
48
(test_structure_8 *) malloc (sizeof(test_structure_8));
53
/* Initialize the cif */
54
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts8_type, args) == FFI_OK);
61
printf ("%g\n", ts8_arg.f1);
62
printf ("%g\n", ts8_arg.f2);
63
printf ("%g\n", ts8_arg.f3);
64
printf ("%g\n", ts8_arg.f4);
66
ffi_call(&cif, FFI_FN(struct8), ts8_result, values);
68
printf ("%g\n", ts8_result->f1);
69
printf ("%g\n", ts8_result->f2);
70
printf ("%g\n", ts8_result->f3);
71
printf ("%g\n", ts8_result->f4);
73
CHECK(ts8_result->f1 == 5.55f + 1);
74
CHECK(ts8_result->f2 == 55.5f + 1);
75
CHECK(ts8_result->f3 == -5.55f + 1);
76
CHECK(ts8_result->f4 == -55.5f + 1);