28 static C C_fn (
int x,
int y,
int z,
C source,
int i,
int j,
int k)
36 printf (
"%d, %d, %d, %d, %d, %d\n", x, y, z,
i, j, k);
38 printf (
"%.1f, %.1f, %.1f, %.1f, "
39 "%.1f, %.1f, %.1f, %.1f\n",
52 ffi_type* struct_fields_source_a[3];
53 ffi_type* struct_fields_source_b[3];
54 ffi_type* struct_fields_source_c[3];
55 ffi_type* arg_types[8];
57 ffi_type struct_type_a, struct_type_b, struct_type_c;
59 struct A source_fld_a = {1.0, 2.0};
60 struct B source_fld_b = {4.0, 8.0};
64 struct C source = {source_fld_a, source_fld_b};
66 struct_type_a.size = 0;
67 struct_type_a.alignment = 0;
68 struct_type_a.type = FFI_TYPE_STRUCT;
69 struct_type_a.elements = struct_fields_source_a;
71 struct_type_b.size = 0;
72 struct_type_b.alignment = 0;
73 struct_type_b.type = FFI_TYPE_STRUCT;
74 struct_type_b.elements = struct_fields_source_b;
76 struct_type_c.size = 0;
77 struct_type_c.alignment = 0;
78 struct_type_c.type = FFI_TYPE_STRUCT;
79 struct_type_c.elements = struct_fields_source_c;
81 struct_fields_source_a[0] = &ffi_type_float;
82 struct_fields_source_a[1] = &ffi_type_float;
83 struct_fields_source_a[2] =
NULL;
85 struct_fields_source_b[0] = &ffi_type_float;
86 struct_fields_source_b[1] = &ffi_type_float;
87 struct_fields_source_b[2] =
NULL;
89 struct_fields_source_c[0] = &struct_type_a;
90 struct_fields_source_c[1] = &struct_type_b;
91 struct_fields_source_c[2] =
NULL;
93 arg_types[0] = &ffi_type_sint32;
94 arg_types[1] = &ffi_type_sint32;
95 arg_types[2] = &ffi_type_sint32;
96 arg_types[3] = &struct_type_c;
97 arg_types[4] = &ffi_type_sint32;
98 arg_types[5] = &ffi_type_sint32;
99 arg_types[6] = &ffi_type_sint32;
111 arg_types) == FFI_OK);
113 ffi_call (&cif, FFI_FN (C_fn), &result, args);