*** empty log message ***
[official-gcc.git] / libffi / testsuite / libffi.call / closure_fn0.c
blob5413d9e78c3289b84f989561401b16c15db655d8
1 /* 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 */
9 /* { dg-do run } */
10 #include "ffitest.h"
12 static void
13 closure_test_fn0(ffi_cif* cif,void* resp,void** args, void* userdata)
15 *(ffi_arg*)resp =
16 (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) +
17 (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] +
18 (int)(*(signed short *)args[4]) +
19 (int)(*(unsigned long long *)args[5]) +
20 (int)*(int *)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;
26 printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
27 (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]),
28 (int)(*(unsigned long long *)args[2]),
29 (int)*(int *)args[3], (int)(*(signed short *)args[4]),
30 (int)(*(unsigned long long *)args[5]),
31 (int)*(int *)args[6], (int)(*(int *)args[7]),
32 (int)(*(double *)args[8]), (int)*(int *)args[9],
33 (int)(*(int *)args[10]), (int)(*(float *)args[11]),
34 (int)*(int *)args[12], (int)(*(int *)args[13]),
35 (int)(*(int *)args[14]),*(int *)args[15],
36 (int)(long)userdata, (int)*(ffi_arg *)resp);
40 typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long,
41 int, signed short, unsigned long long, int,
42 int, double, int, int, float, int, int,
43 int, int);
45 int main (void)
47 ffi_cif cif;
48 static ffi_closure cl;
49 ffi_closure *pcl = &cl;
50 ffi_type * cl_arg_types[17];
52 cl_arg_types[0] = &ffi_type_uint64;
53 cl_arg_types[1] = &ffi_type_uint;
54 cl_arg_types[2] = &ffi_type_uint64;
55 cl_arg_types[3] = &ffi_type_uint;
56 cl_arg_types[4] = &ffi_type_sshort;
57 cl_arg_types[5] = &ffi_type_uint64;
58 cl_arg_types[6] = &ffi_type_uint;
59 cl_arg_types[7] = &ffi_type_uint;
60 cl_arg_types[8] = &ffi_type_double;
61 cl_arg_types[9] = &ffi_type_uint;
62 cl_arg_types[10] = &ffi_type_uint;
63 cl_arg_types[11] = &ffi_type_float;
64 cl_arg_types[12] = &ffi_type_uint;
65 cl_arg_types[13] = &ffi_type_uint;
66 cl_arg_types[14] = &ffi_type_uint;
67 cl_arg_types[15] = &ffi_type_uint;
68 cl_arg_types[16] = NULL;
70 /* Initialize the cif */
71 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
72 &ffi_type_sint, cl_arg_types) == FFI_OK);
74 CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn0,
75 (void *) 3 /* userdata */) == FFI_OK);
77 (*((closure_test_type0)pcl))
78 (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13,
79 19, 21, 1);
80 /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
81 exit(0);