1 |
14 |
jlechner |
/* Area: closure_call.
|
2 |
|
|
Purpose: Check multiple values passing from different type.
|
3 |
|
|
Also, exceed the limit of gpr and fpr registers on PowerPC
|
4 |
|
|
Darwin.
|
5 |
|
|
Limitations: none.
|
6 |
|
|
PR: none.
|
7 |
|
|
Originator: <andreast@gcc.gnu.org> 20030828 */
|
8 |
|
|
|
9 |
|
|
/* { dg-do run { xfail mips64*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
|
10 |
|
|
#include "ffitest.h"
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
static void closure_test_fn1(ffi_cif* cif,void* resp,void** args,
|
14 |
|
|
void* userdata)
|
15 |
|
|
{
|
16 |
|
|
*(ffi_arg*)resp =
|
17 |
|
|
(int)*(float *)args[0] +(int)(*(float *)args[1]) +
|
18 |
|
|
(int)(*(float *)args[2]) + (int)*(float *)args[3] +
|
19 |
|
|
(int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) +
|
20 |
|
|
(int)*(float *)args[6] + (int)(*(int *)args[7]) +
|
21 |
|
|
(int)(*(double*)args[8]) + (int)*(int *)args[9] +
|
22 |
|
|
(int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
|
23 |
|
|
(int)*(int *)args[12] + (int)(*(int *)args[13]) +
|
24 |
|
|
(int)(*(int *)args[14]) + *(int *)args[15] + (int)(long)userdata;
|
25 |
|
|
|
26 |
|
|
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
|
27 |
|
|
(int)*(float *)args[0], (int)(*(float *)args[1]),
|
28 |
|
|
(int)(*(float *)args[2]), (int)*(float *)args[3],
|
29 |
|
|
(int)(*(signed short *)args[4]), (int)(*(float *)args[5]),
|
30 |
|
|
(int)*(float *)args[6], (int)(*(int *)args[7]),
|
31 |
|
|
(int)(*(double *)args[8]), (int)*(int *)args[9],
|
32 |
|
|
(int)(*(int *)args[10]), (int)(*(float *)args[11]),
|
33 |
|
|
(int)*(int *)args[12], (int)(*(int *)args[13]),
|
34 |
|
|
(int)(*(int *)args[14]), *(int *)args[15],
|
35 |
|
|
(int)(long)userdata, (int)*(ffi_arg *)resp);
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
typedef int (*closure_test_type1)(float, float, float, float, signed short,
|
39 |
|
|
float, float, int, double, int, int, float,
|
40 |
|
|
int, int, int, int);
|
41 |
|
|
int main (void)
|
42 |
|
|
{
|
43 |
|
|
ffi_cif cif;
|
44 |
|
|
#ifndef USING_MMAP
|
45 |
|
|
static ffi_closure cl;
|
46 |
|
|
#endif
|
47 |
|
|
ffi_closure *pcl;
|
48 |
|
|
ffi_type * cl_arg_types[17];
|
49 |
|
|
int res;
|
50 |
|
|
|
51 |
|
|
#ifdef USING_MMAP
|
52 |
|
|
pcl = allocate_mmap (sizeof(ffi_closure));
|
53 |
|
|
#else
|
54 |
|
|
pcl = &cl;
|
55 |
|
|
#endif
|
56 |
|
|
|
57 |
|
|
cl_arg_types[0] = &ffi_type_float;
|
58 |
|
|
cl_arg_types[1] = &ffi_type_float;
|
59 |
|
|
cl_arg_types[2] = &ffi_type_float;
|
60 |
|
|
cl_arg_types[3] = &ffi_type_float;
|
61 |
|
|
cl_arg_types[4] = &ffi_type_sshort;
|
62 |
|
|
cl_arg_types[5] = &ffi_type_float;
|
63 |
|
|
cl_arg_types[6] = &ffi_type_float;
|
64 |
|
|
cl_arg_types[7] = &ffi_type_uint;
|
65 |
|
|
cl_arg_types[8] = &ffi_type_double;
|
66 |
|
|
cl_arg_types[9] = &ffi_type_uint;
|
67 |
|
|
cl_arg_types[10] = &ffi_type_uint;
|
68 |
|
|
cl_arg_types[11] = &ffi_type_float;
|
69 |
|
|
cl_arg_types[12] = &ffi_type_uint;
|
70 |
|
|
cl_arg_types[13] = &ffi_type_uint;
|
71 |
|
|
cl_arg_types[14] = &ffi_type_uint;
|
72 |
|
|
cl_arg_types[15] = &ffi_type_uint;
|
73 |
|
|
cl_arg_types[16] = NULL;
|
74 |
|
|
|
75 |
|
|
/* Initialize the cif */
|
76 |
|
|
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
|
77 |
|
|
&ffi_type_sint, cl_arg_types) == FFI_OK);
|
78 |
|
|
|
79 |
|
|
CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn1,
|
80 |
|
|
(void *) 3 /* userdata */) == FFI_OK);
|
81 |
|
|
|
82 |
|
|
res = (*((closure_test_type1)pcl))
|
83 |
|
|
(1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13,
|
84 |
|
|
19, 21, 1);
|
85 |
|
|
/* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */
|
86 |
|
|
printf("res: %d\n",res);
|
87 |
|
|
/* { dg-output "\nres: 255" } */
|
88 |
|
|
exit(0);
|
89 |
|
|
}
|