15 printf("%.1f,%.1fi %.1f,%.1fi\n",
16 T_CONV creal (p.x), T_CONV cimag (p.x),
17 T_CONV creal (p.y), T_CONV cimag (p.y));
22 closure_test_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
23 void** args, void* userdata __UNUSED__)
25 closure_test_fn(*(Cs*)args[0]);
28 int main(int argc __UNUSED__, char** argv __UNUSED__)
33 ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
34 ffi_type *cl_arg_types[1];
37 ffi_type* ts1_type_elements[4];
39 Cs arg = { 1.0 + 11.0 * I, 2.0 + 22.0 * I};
42 ts1_type.alignment = 0;
43 ts1_type.type = FFI_TYPE_STRUCT;
44 ts1_type.elements = ts1_type_elements;
46 ts1_type_elements[0] = &T_FFI_TYPE;
47 ts1_type_elements[1] = &T_FFI_TYPE;
48 ts1_type_elements[2] = NULL;
50 cl_arg_types[0] = &ts1_type;
52 /* Initialize the cif */
53 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
54 &ffi_type_void, cl_arg_types) == FFI_OK);
56 CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_gn, NULL, code) == FFI_OK);
60 ((void*(*)(Cs))(code))(arg);
61 /* { dg-output "1.0,11.0i 2.0,22.0i\n" } */
62 CHECK (gc.x == arg.x && gc.y == arg.y);
67 /* { dg-output "1.0,11.0i 2.0,22.0i\n" } */
68 CHECK (gc.x == arg.x && gc.y == arg.y);