PR middle-end/20297
[official-gcc.git] / libffi / testsuite / libffi.call / closure_fn3.c
blobacfef78855f5cef15b2f8fda59257ed216c0f1b2
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 { xfail mips64*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
10 #include "ffitest.h"
12 static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args,
13 void* userdata)
15 *(ffi_arg*)resp =
16 (int)*(float *)args[0] +(int)(*(float *)args[1]) +
17 (int)(*(float *)args[2]) + (int)*(float *)args[3] +
18 (int)(*(float *)args[4]) + (int)(*(float *)args[5]) +
19 (int)*(float *)args[6] + (int)(*(float *)args[7]) +
20 (int)(*(double *)args[8]) + (int)*(int *)args[9] +
21 (int)(*(float *)args[10]) + (int)(*(float *)args[11]) +
22 (int)*(int *)args[12] + (int)(*(float *)args[13]) +
23 (int)(*(float *)args[14]) + *(int *)args[15] + (int)(long)userdata;
25 printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
26 (int)*(float *)args[0], (int)(*(float *)args[1]),
27 (int)(*(float *)args[2]), (int)*(float *)args[3],
28 (int)(*(float *)args[4]), (int)(*(float *)args[5]),
29 (int)*(float *)args[6], (int)(*(float *)args[7]),
30 (int)(*(double *)args[8]), (int)*(int *)args[9],
31 (int)(*(float *)args[10]), (int)(*(float *)args[11]),
32 (int)*(int *)args[12], (int)(*(float *)args[13]),
33 (int)(*(float *)args[14]), *(int *)args[15], (int)(long)userdata,
34 (int)*(ffi_arg *)resp);
38 typedef int (*closure_test_type3)(float, float, float, float, float, float,
39 float, float, double, int, float, float, int,
40 float, float, int);
42 int main (void)
44 ffi_cif cif;
45 #ifndef USING_MMAP
46 static ffi_closure cl;
47 #endif
48 ffi_closure *pcl;
49 ffi_type * cl_arg_types[17];
50 int res;
52 #ifdef USING_MMAP
53 pcl = allocate_mmap (sizeof(ffi_closure));
54 #else
55 pcl = &cl;
56 #endif
58 cl_arg_types[0] = &ffi_type_float;
59 cl_arg_types[1] = &ffi_type_float;
60 cl_arg_types[2] = &ffi_type_float;
61 cl_arg_types[3] = &ffi_type_float;
62 cl_arg_types[4] = &ffi_type_float;
63 cl_arg_types[5] = &ffi_type_float;
64 cl_arg_types[6] = &ffi_type_float;
65 cl_arg_types[7] = &ffi_type_float;
66 cl_arg_types[8] = &ffi_type_double;
67 cl_arg_types[9] = &ffi_type_uint;
68 cl_arg_types[10] = &ffi_type_float;
69 cl_arg_types[11] = &ffi_type_float;
70 cl_arg_types[12] = &ffi_type_uint;
71 cl_arg_types[13] = &ffi_type_float;
72 cl_arg_types[14] = &ffi_type_float;
73 cl_arg_types[15] = &ffi_type_uint;
74 cl_arg_types[16] = NULL;
76 /* Initialize the cif */
77 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
78 &ffi_type_sint, cl_arg_types) == FFI_OK);
80 CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn3,
81 (void *) 3 /* userdata */) == FFI_OK);
83 res = (*((closure_test_type3)pcl))
84 (1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9, 10, 11.11, 12.0, 13,
85 19.19, 21.21, 1);
86 /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 19 21 1 3: 135" } */
87 printf("res: %d\n",res);
88 /* { dg-output "\nres: 135" } */
89 exit(0);