1 /* Area: ffi_call, closure_call
2 Purpose: Check passing of multiple signed char values.
5 Originator: <hos@tamanegi.org> 20031129 */
7 /* { dg-do run { xfail mips64*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
10 signed char test_func_fn(signed char a1, signed char a2)
16 printf("%d %d: %d\n", a1, a2, result);
22 static void test_func_gn(ffi_cif *cif, void *rval, void **avals, void *data)
26 a1 = *(signed char *)avals[0];
27 a2 = *(signed char *)avals[1];
29 *(ffi_arg *)rval = test_func_fn(a1, a2);
33 typedef signed char (*test_type)(signed char, signed char);
39 static ffi_closure cl;
43 ffi_type * cl_arg_types[3];
45 signed char a, b, res_closure;
48 pcl = allocate_mmap (sizeof(ffi_closure));
60 cl_arg_types[0] = &ffi_type_schar;
61 cl_arg_types[1] = &ffi_type_schar;
62 cl_arg_types[2] = NULL;
64 /* Initialize the cif */
65 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
66 &ffi_type_schar, cl_arg_types) == FFI_OK);
68 ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
69 /* { dg-output "2 125: 127" } */
70 printf("res: %d\n", res_call);
71 /* { dg-output "\nres: 127" } */
73 CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
75 res_closure = (*((test_type)pcl))(2, 125);
76 /* { dg-output "\n2 125: 127" } */
77 printf("res: %d\n", res_closure);
78 /* { dg-output "\nres: 127" } */