annotate libffi/testsuite/libffi.call/huge_struct.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Area: ffi_call, closure_call
kono
parents:
diff changeset
2 Purpose: Check large structure returns.
kono
parents:
diff changeset
3 Limitations: none.
kono
parents:
diff changeset
4 PR: none.
kono
parents:
diff changeset
5 Originator: Blake Chaffin 6/18/2007
kono
parents:
diff changeset
6 */
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
kono
parents:
diff changeset
9 /* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
kono
parents:
diff changeset
10 /* { dg-options -Wformat=0 { target moxie*-*-elf } } */
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 #include "ffitest.h"
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 typedef struct BigStruct{
kono
parents:
diff changeset
15 uint8_t a;
kono
parents:
diff changeset
16 int8_t b;
kono
parents:
diff changeset
17 uint16_t c;
kono
parents:
diff changeset
18 int16_t d;
kono
parents:
diff changeset
19 uint32_t e;
kono
parents:
diff changeset
20 int32_t f;
kono
parents:
diff changeset
21 uint64_t g;
kono
parents:
diff changeset
22 int64_t h;
kono
parents:
diff changeset
23 float i;
kono
parents:
diff changeset
24 double j;
kono
parents:
diff changeset
25 long double k;
kono
parents:
diff changeset
26 char* l;
kono
parents:
diff changeset
27 uint8_t m;
kono
parents:
diff changeset
28 int8_t n;
kono
parents:
diff changeset
29 uint16_t o;
kono
parents:
diff changeset
30 int16_t p;
kono
parents:
diff changeset
31 uint32_t q;
kono
parents:
diff changeset
32 int32_t r;
kono
parents:
diff changeset
33 uint64_t s;
kono
parents:
diff changeset
34 int64_t t;
kono
parents:
diff changeset
35 float u;
kono
parents:
diff changeset
36 double v;
kono
parents:
diff changeset
37 long double w;
kono
parents:
diff changeset
38 char* x;
kono
parents:
diff changeset
39 uint8_t y;
kono
parents:
diff changeset
40 int8_t z;
kono
parents:
diff changeset
41 uint16_t aa;
kono
parents:
diff changeset
42 int16_t bb;
kono
parents:
diff changeset
43 uint32_t cc;
kono
parents:
diff changeset
44 int32_t dd;
kono
parents:
diff changeset
45 uint64_t ee;
kono
parents:
diff changeset
46 int64_t ff;
kono
parents:
diff changeset
47 float gg;
kono
parents:
diff changeset
48 double hh;
kono
parents:
diff changeset
49 long double ii;
kono
parents:
diff changeset
50 char* jj;
kono
parents:
diff changeset
51 uint8_t kk;
kono
parents:
diff changeset
52 int8_t ll;
kono
parents:
diff changeset
53 uint16_t mm;
kono
parents:
diff changeset
54 int16_t nn;
kono
parents:
diff changeset
55 uint32_t oo;
kono
parents:
diff changeset
56 int32_t pp;
kono
parents:
diff changeset
57 uint64_t qq;
kono
parents:
diff changeset
58 int64_t rr;
kono
parents:
diff changeset
59 float ss;
kono
parents:
diff changeset
60 double tt;
kono
parents:
diff changeset
61 long double uu;
kono
parents:
diff changeset
62 char* vv;
kono
parents:
diff changeset
63 uint8_t ww;
kono
parents:
diff changeset
64 int8_t xx;
kono
parents:
diff changeset
65 } BigStruct;
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 BigStruct
kono
parents:
diff changeset
68 test_large_fn(
kono
parents:
diff changeset
69 uint8_t ui8_1,
kono
parents:
diff changeset
70 int8_t si8_1,
kono
parents:
diff changeset
71 uint16_t ui16_1,
kono
parents:
diff changeset
72 int16_t si16_1,
kono
parents:
diff changeset
73 uint32_t ui32_1,
kono
parents:
diff changeset
74 int32_t si32_1,
kono
parents:
diff changeset
75 uint64_t ui64_1,
kono
parents:
diff changeset
76 int64_t si64_1,
kono
parents:
diff changeset
77 float f_1,
kono
parents:
diff changeset
78 double d_1,
kono
parents:
diff changeset
79 long double ld_1,
kono
parents:
diff changeset
80 char* p_1,
kono
parents:
diff changeset
81 uint8_t ui8_2,
kono
parents:
diff changeset
82 int8_t si8_2,
kono
parents:
diff changeset
83 uint16_t ui16_2,
kono
parents:
diff changeset
84 int16_t si16_2,
kono
parents:
diff changeset
85 uint32_t ui32_2,
kono
parents:
diff changeset
86 int32_t si32_2,
kono
parents:
diff changeset
87 uint64_t ui64_2,
kono
parents:
diff changeset
88 int64_t si64_2,
kono
parents:
diff changeset
89 float f_2,
kono
parents:
diff changeset
90 double d_2,
kono
parents:
diff changeset
91 long double ld_2,
kono
parents:
diff changeset
92 char* p_2,
kono
parents:
diff changeset
93 uint8_t ui8_3,
kono
parents:
diff changeset
94 int8_t si8_3,
kono
parents:
diff changeset
95 uint16_t ui16_3,
kono
parents:
diff changeset
96 int16_t si16_3,
kono
parents:
diff changeset
97 uint32_t ui32_3,
kono
parents:
diff changeset
98 int32_t si32_3,
kono
parents:
diff changeset
99 uint64_t ui64_3,
kono
parents:
diff changeset
100 int64_t si64_3,
kono
parents:
diff changeset
101 float f_3,
kono
parents:
diff changeset
102 double d_3,
kono
parents:
diff changeset
103 long double ld_3,
kono
parents:
diff changeset
104 char* p_3,
kono
parents:
diff changeset
105 uint8_t ui8_4,
kono
parents:
diff changeset
106 int8_t si8_4,
kono
parents:
diff changeset
107 uint16_t ui16_4,
kono
parents:
diff changeset
108 int16_t si16_4,
kono
parents:
diff changeset
109 uint32_t ui32_4,
kono
parents:
diff changeset
110 int32_t si32_4,
kono
parents:
diff changeset
111 uint64_t ui64_4,
kono
parents:
diff changeset
112 int64_t si64_4,
kono
parents:
diff changeset
113 float f_4,
kono
parents:
diff changeset
114 double d_4,
kono
parents:
diff changeset
115 long double ld_4,
kono
parents:
diff changeset
116 char* p_4,
kono
parents:
diff changeset
117 uint8_t ui8_5,
kono
parents:
diff changeset
118 int8_t si8_5)
kono
parents:
diff changeset
119 {
kono
parents:
diff changeset
120 BigStruct retVal = {
kono
parents:
diff changeset
121 ui8_1 + 1, si8_1 + 1, ui16_1 + 1, si16_1 + 1, ui32_1 + 1, si32_1 + 1,
kono
parents:
diff changeset
122 ui64_1 + 1, si64_1 + 1, f_1 + 1, d_1 + 1, ld_1 + 1, (char*)((intptr_t)p_1 + 1),
kono
parents:
diff changeset
123 ui8_2 + 2, si8_2 + 2, ui16_2 + 2, si16_2 + 2, ui32_2 + 2, si32_2 + 2,
kono
parents:
diff changeset
124 ui64_2 + 2, si64_2 + 2, f_2 + 2, d_2 + 2, ld_2 + 2, (char*)((intptr_t)p_2 + 2),
kono
parents:
diff changeset
125 ui8_3 + 3, si8_3 + 3, ui16_3 + 3, si16_3 + 3, ui32_3 + 3, si32_3 + 3,
kono
parents:
diff changeset
126 ui64_3 + 3, si64_3 + 3, f_3 + 3, d_3 + 3, ld_3 + 3, (char*)((intptr_t)p_3 + 3),
kono
parents:
diff changeset
127 ui8_4 + 4, si8_4 + 4, ui16_4 + 4, si16_4 + 4, ui32_4 + 4, si32_4 + 4,
kono
parents:
diff changeset
128 ui64_4 + 4, si64_4 + 4, f_4 + 4, d_4 + 4, ld_4 + 4, (char*)((intptr_t)p_4 + 4),
kono
parents:
diff changeset
129 ui8_5 + 5, si8_5 + 5};
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 printf("%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
132 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
133 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
134 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 ": "
kono
parents:
diff changeset
135 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
136 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
137 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
138 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 "\n",
kono
parents:
diff changeset
139 ui8_1, si8_1, ui16_1, si16_1, ui32_1, si32_1, ui64_1, si64_1, f_1, d_1, ld_1, (unsigned long)p_1,
kono
parents:
diff changeset
140 ui8_2, si8_2, ui16_2, si16_2, ui32_2, si32_2, ui64_2, si64_2, f_2, d_2, ld_2, (unsigned long)p_2,
kono
parents:
diff changeset
141 ui8_3, si8_3, ui16_3, si16_3, ui32_3, si32_3, ui64_3, si64_3, f_3, d_3, ld_3, (unsigned long)p_3,
kono
parents:
diff changeset
142 ui8_4, si8_4, ui16_4, si16_4, ui32_4, si32_4, ui64_4, si64_4, f_4, d_4, ld_4, (unsigned long)p_4, ui8_5, si8_5,
kono
parents:
diff changeset
143 retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
kono
parents:
diff changeset
144 retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
kono
parents:
diff changeset
145 retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
kono
parents:
diff changeset
146 retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
kono
parents:
diff changeset
147 retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
kono
parents:
diff changeset
148 retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
kono
parents:
diff changeset
149 retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
kono
parents:
diff changeset
150 retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 return retVal;
kono
parents:
diff changeset
153 }
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 static void
kono
parents:
diff changeset
156 cls_large_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__)
kono
parents:
diff changeset
157 {
kono
parents:
diff changeset
158 uint8_t ui8_1 = *(uint8_t*)args[0];
kono
parents:
diff changeset
159 int8_t si8_1 = *(int8_t*)args[1];
kono
parents:
diff changeset
160 uint16_t ui16_1 = *(uint16_t*)args[2];
kono
parents:
diff changeset
161 int16_t si16_1 = *(int16_t*)args[3];
kono
parents:
diff changeset
162 uint32_t ui32_1 = *(uint32_t*)args[4];
kono
parents:
diff changeset
163 int32_t si32_1 = *(int32_t*)args[5];
kono
parents:
diff changeset
164 uint64_t ui64_1 = *(uint64_t*)args[6];
kono
parents:
diff changeset
165 int64_t si64_1 = *(int64_t*)args[7];
kono
parents:
diff changeset
166 float f_1 = *(float*)args[8];
kono
parents:
diff changeset
167 double d_1 = *(double*)args[9];
kono
parents:
diff changeset
168 long double ld_1 = *(long double*)args[10];
kono
parents:
diff changeset
169 char* p_1 = *(char**)args[11];
kono
parents:
diff changeset
170 uint8_t ui8_2 = *(uint8_t*)args[12];
kono
parents:
diff changeset
171 int8_t si8_2 = *(int8_t*)args[13];
kono
parents:
diff changeset
172 uint16_t ui16_2 = *(uint16_t*)args[14];
kono
parents:
diff changeset
173 int16_t si16_2 = *(int16_t*)args[15];
kono
parents:
diff changeset
174 uint32_t ui32_2 = *(uint32_t*)args[16];
kono
parents:
diff changeset
175 int32_t si32_2 = *(int32_t*)args[17];
kono
parents:
diff changeset
176 uint64_t ui64_2 = *(uint64_t*)args[18];
kono
parents:
diff changeset
177 int64_t si64_2 = *(int64_t*)args[19];
kono
parents:
diff changeset
178 float f_2 = *(float*)args[20];
kono
parents:
diff changeset
179 double d_2 = *(double*)args[21];
kono
parents:
diff changeset
180 long double ld_2 = *(long double*)args[22];
kono
parents:
diff changeset
181 char* p_2 = *(char**)args[23];
kono
parents:
diff changeset
182 uint8_t ui8_3 = *(uint8_t*)args[24];
kono
parents:
diff changeset
183 int8_t si8_3 = *(int8_t*)args[25];
kono
parents:
diff changeset
184 uint16_t ui16_3 = *(uint16_t*)args[26];
kono
parents:
diff changeset
185 int16_t si16_3 = *(int16_t*)args[27];
kono
parents:
diff changeset
186 uint32_t ui32_3 = *(uint32_t*)args[28];
kono
parents:
diff changeset
187 int32_t si32_3 = *(int32_t*)args[29];
kono
parents:
diff changeset
188 uint64_t ui64_3 = *(uint64_t*)args[30];
kono
parents:
diff changeset
189 int64_t si64_3 = *(int64_t*)args[31];
kono
parents:
diff changeset
190 float f_3 = *(float*)args[32];
kono
parents:
diff changeset
191 double d_3 = *(double*)args[33];
kono
parents:
diff changeset
192 long double ld_3 = *(long double*)args[34];
kono
parents:
diff changeset
193 char* p_3 = *(char**)args[35];
kono
parents:
diff changeset
194 uint8_t ui8_4 = *(uint8_t*)args[36];
kono
parents:
diff changeset
195 int8_t si8_4 = *(int8_t*)args[37];
kono
parents:
diff changeset
196 uint16_t ui16_4 = *(uint16_t*)args[38];
kono
parents:
diff changeset
197 int16_t si16_4 = *(int16_t*)args[39];
kono
parents:
diff changeset
198 uint32_t ui32_4 = *(uint32_t*)args[40];
kono
parents:
diff changeset
199 int32_t si32_4 = *(int32_t*)args[41];
kono
parents:
diff changeset
200 uint64_t ui64_4 = *(uint64_t*)args[42];
kono
parents:
diff changeset
201 int64_t si64_4 = *(int64_t*)args[43];
kono
parents:
diff changeset
202 float f_4 = *(float*)args[44];
kono
parents:
diff changeset
203 double d_4 = *(double*)args[45];
kono
parents:
diff changeset
204 long double ld_4 = *(long double*)args[46];
kono
parents:
diff changeset
205 char* p_4 = *(char**)args[47];
kono
parents:
diff changeset
206 uint8_t ui8_5 = *(uint8_t*)args[48];
kono
parents:
diff changeset
207 int8_t si8_5 = *(int8_t*)args[49];
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 *(BigStruct*)resp = test_large_fn(
kono
parents:
diff changeset
210 ui8_1, si8_1, ui16_1, si16_1, ui32_1, si32_1, ui64_1, si64_1, f_1, d_1, ld_1, p_1,
kono
parents:
diff changeset
211 ui8_2, si8_2, ui16_2, si16_2, ui32_2, si32_2, ui64_2, si64_2, f_2, d_2, ld_2, p_2,
kono
parents:
diff changeset
212 ui8_3, si8_3, ui16_3, si16_3, ui32_3, si32_3, ui64_3, si64_3, f_3, d_3, ld_3, p_3,
kono
parents:
diff changeset
213 ui8_4, si8_4, ui16_4, si16_4, ui32_4, si32_4, ui64_4, si64_4, f_4, d_4, ld_4, p_4,
kono
parents:
diff changeset
214 ui8_5, si8_5);
kono
parents:
diff changeset
215 }
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 int
kono
parents:
diff changeset
218 main(int argc __UNUSED__, const char** argv __UNUSED__)
kono
parents:
diff changeset
219 {
kono
parents:
diff changeset
220 void *code;
kono
parents:
diff changeset
221 ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 ffi_cif cif;
kono
parents:
diff changeset
224 ffi_type* argTypes[51];
kono
parents:
diff changeset
225 void* argValues[51];
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 ffi_type ret_struct_type;
kono
parents:
diff changeset
228 ffi_type* st_fields[51];
kono
parents:
diff changeset
229 BigStruct retVal;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 uint8_t ui8 = 1;
kono
parents:
diff changeset
232 int8_t si8 = 2;
kono
parents:
diff changeset
233 uint16_t ui16 = 3;
kono
parents:
diff changeset
234 int16_t si16 = 4;
kono
parents:
diff changeset
235 uint32_t ui32 = 5;
kono
parents:
diff changeset
236 int32_t si32 = 6;
kono
parents:
diff changeset
237 uint64_t ui64 = 7;
kono
parents:
diff changeset
238 int64_t si64 = 8;
kono
parents:
diff changeset
239 float f = 9;
kono
parents:
diff changeset
240 double d = 10;
kono
parents:
diff changeset
241 long double ld = 11;
kono
parents:
diff changeset
242 char* p = (char*)0x12345678;
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 memset (&retVal, 0, sizeof(retVal));
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 ret_struct_type.size = 0;
kono
parents:
diff changeset
247 ret_struct_type.alignment = 0;
kono
parents:
diff changeset
248 ret_struct_type.type = FFI_TYPE_STRUCT;
kono
parents:
diff changeset
249 ret_struct_type.elements = st_fields;
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 st_fields[0] = st_fields[12] = st_fields[24] = st_fields[36] = st_fields[48] = &ffi_type_uint8;
kono
parents:
diff changeset
252 st_fields[1] = st_fields[13] = st_fields[25] = st_fields[37] = st_fields[49] = &ffi_type_sint8;
kono
parents:
diff changeset
253 st_fields[2] = st_fields[14] = st_fields[26] = st_fields[38] = &ffi_type_uint16;
kono
parents:
diff changeset
254 st_fields[3] = st_fields[15] = st_fields[27] = st_fields[39] = &ffi_type_sint16;
kono
parents:
diff changeset
255 st_fields[4] = st_fields[16] = st_fields[28] = st_fields[40] = &ffi_type_uint32;
kono
parents:
diff changeset
256 st_fields[5] = st_fields[17] = st_fields[29] = st_fields[41] = &ffi_type_sint32;
kono
parents:
diff changeset
257 st_fields[6] = st_fields[18] = st_fields[30] = st_fields[42] = &ffi_type_uint64;
kono
parents:
diff changeset
258 st_fields[7] = st_fields[19] = st_fields[31] = st_fields[43] = &ffi_type_sint64;
kono
parents:
diff changeset
259 st_fields[8] = st_fields[20] = st_fields[32] = st_fields[44] = &ffi_type_float;
kono
parents:
diff changeset
260 st_fields[9] = st_fields[21] = st_fields[33] = st_fields[45] = &ffi_type_double;
kono
parents:
diff changeset
261 st_fields[10] = st_fields[22] = st_fields[34] = st_fields[46] = &ffi_type_longdouble;
kono
parents:
diff changeset
262 st_fields[11] = st_fields[23] = st_fields[35] = st_fields[47] = &ffi_type_pointer;
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 st_fields[50] = NULL;
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 argTypes[0] = argTypes[12] = argTypes[24] = argTypes[36] = argTypes[48] = &ffi_type_uint8;
kono
parents:
diff changeset
267 argValues[0] = argValues[12] = argValues[24] = argValues[36] = argValues[48] = &ui8;
kono
parents:
diff changeset
268 argTypes[1] = argTypes[13] = argTypes[25] = argTypes[37] = argTypes[49] = &ffi_type_sint8;
kono
parents:
diff changeset
269 argValues[1] = argValues[13] = argValues[25] = argValues[37] = argValues[49] = &si8;
kono
parents:
diff changeset
270 argTypes[2] = argTypes[14] = argTypes[26] = argTypes[38] = &ffi_type_uint16;
kono
parents:
diff changeset
271 argValues[2] = argValues[14] = argValues[26] = argValues[38] = &ui16;
kono
parents:
diff changeset
272 argTypes[3] = argTypes[15] = argTypes[27] = argTypes[39] = &ffi_type_sint16;
kono
parents:
diff changeset
273 argValues[3] = argValues[15] = argValues[27] = argValues[39] = &si16;
kono
parents:
diff changeset
274 argTypes[4] = argTypes[16] = argTypes[28] = argTypes[40] = &ffi_type_uint32;
kono
parents:
diff changeset
275 argValues[4] = argValues[16] = argValues[28] = argValues[40] = &ui32;
kono
parents:
diff changeset
276 argTypes[5] = argTypes[17] = argTypes[29] = argTypes[41] = &ffi_type_sint32;
kono
parents:
diff changeset
277 argValues[5] = argValues[17] = argValues[29] = argValues[41] = &si32;
kono
parents:
diff changeset
278 argTypes[6] = argTypes[18] = argTypes[30] = argTypes[42] = &ffi_type_uint64;
kono
parents:
diff changeset
279 argValues[6] = argValues[18] = argValues[30] = argValues[42] = &ui64;
kono
parents:
diff changeset
280 argTypes[7] = argTypes[19] = argTypes[31] = argTypes[43] = &ffi_type_sint64;
kono
parents:
diff changeset
281 argValues[7] = argValues[19] = argValues[31] = argValues[43] = &si64;
kono
parents:
diff changeset
282 argTypes[8] = argTypes[20] = argTypes[32] = argTypes[44] = &ffi_type_float;
kono
parents:
diff changeset
283 argValues[8] = argValues[20] = argValues[32] = argValues[44] = &f;
kono
parents:
diff changeset
284 argTypes[9] = argTypes[21] = argTypes[33] = argTypes[45] = &ffi_type_double;
kono
parents:
diff changeset
285 argValues[9] = argValues[21] = argValues[33] = argValues[45] = &d;
kono
parents:
diff changeset
286 argTypes[10] = argTypes[22] = argTypes[34] = argTypes[46] = &ffi_type_longdouble;
kono
parents:
diff changeset
287 argValues[10] = argValues[22] = argValues[34] = argValues[46] = &ld;
kono
parents:
diff changeset
288 argTypes[11] = argTypes[23] = argTypes[35] = argTypes[47] = &ffi_type_pointer;
kono
parents:
diff changeset
289 argValues[11] = argValues[23] = argValues[35] = argValues[47] = &p;
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 argTypes[50] = NULL;
kono
parents:
diff changeset
292 argValues[50] = NULL;
kono
parents:
diff changeset
293
kono
parents:
diff changeset
294 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 50, &ret_struct_type, argTypes) == FFI_OK);
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 ffi_call(&cif, FFI_FN(test_large_fn), &retVal, argValues);
kono
parents:
diff changeset
297 /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
kono
parents:
diff changeset
298 printf("res: %" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
299 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
300 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
301 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 "\n",
kono
parents:
diff changeset
302 retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
kono
parents:
diff changeset
303 retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
kono
parents:
diff changeset
304 retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
kono
parents:
diff changeset
305 retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
kono
parents:
diff changeset
306 retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
kono
parents:
diff changeset
307 retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
kono
parents:
diff changeset
308 retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
kono
parents:
diff changeset
309 retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
kono
parents:
diff changeset
310 /* { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
kono
parents:
diff changeset
311
kono
parents:
diff changeset
312 CHECK(ffi_prep_closure_loc(pcl, &cif, cls_large_fn, NULL, code) == FFI_OK);
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 retVal = ((BigStruct(*)(
kono
parents:
diff changeset
315 uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
kono
parents:
diff changeset
316 uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
kono
parents:
diff changeset
317 uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
kono
parents:
diff changeset
318 uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
kono
parents:
diff changeset
319 uint8_t, int8_t))(code))(
kono
parents:
diff changeset
320 ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
kono
parents:
diff changeset
321 ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
kono
parents:
diff changeset
322 ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
kono
parents:
diff changeset
323 ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
kono
parents:
diff changeset
324 ui8, si8);
kono
parents:
diff changeset
325 /* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
kono
parents:
diff changeset
326 printf("res: %" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
327 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
328 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
kono
parents:
diff changeset
329 "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 "\n",
kono
parents:
diff changeset
330 retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
kono
parents:
diff changeset
331 retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
kono
parents:
diff changeset
332 retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
kono
parents:
diff changeset
333 retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
kono
parents:
diff changeset
334 retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
kono
parents:
diff changeset
335 retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
kono
parents:
diff changeset
336 retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
kono
parents:
diff changeset
337 retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
kono
parents:
diff changeset
338 /* { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 return 0;
kono
parents:
diff changeset
341 }