Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* Test passing of arguments to functions. Use various sorts of arguments, |
2 | including basic types, pointers to those types, structures, lots of | |
3 | args, etc, in various combinations. */ | |
4 | ||
5 | /* AIX requires this to be the first thing in the file. */ | |
6 | #ifdef __GNUC__ | |
7 | # define alloca __builtin_alloca | |
8 | # define HAVE_STACK_ALLOCA 1 | |
9 | #else /* not __GNUC__ */ | |
10 | # ifdef _AIX | |
11 | #pragma alloca | |
12 | # define HAVE_STACK_ALLOCA 1 | |
13 | # else /* Not AIX */ | |
14 | # ifdef sparc | |
15 | # include <alloca.h> | |
16 | # define HAVE_STACK_ALLOCA 1 | |
17 | # ifdef __STDC__ | |
18 | void *alloca (); | |
19 | # else | |
20 | char *alloca (); | |
21 | # endif /* __STDC__ */ | |
22 | # endif /* sparc */ | |
23 | # endif /* Not AIX */ | |
24 | #endif /* not __GNUC__ */ | |
25 | ||
26 | char c = 'a'; | |
27 | char *cp = &c; | |
28 | ||
29 | unsigned char uc = 'b'; | |
30 | unsigned char *ucp = &uc; | |
31 | ||
32 | short s = 1; | |
33 | short *sp = &s; | |
34 | ||
35 | unsigned short us = 6; | |
36 | unsigned short *usp = &us; | |
37 | ||
38 | int i = 2; | |
39 | int *ip = &i; | |
40 | ||
41 | unsigned int ui = 7; | |
42 | unsigned int *uip = &ui; | |
43 | ||
44 | long l = 3; | |
45 | long *lp = &l; | |
46 | ||
47 | unsigned long ul = 8; | |
48 | unsigned long *ulp = &ul; | |
49 | ||
50 | float f = 4.0; | |
51 | float *fp = &f; | |
52 | ||
53 | double d = 5.0; | |
54 | double *dp = &d; | |
55 | ||
56 | struct stag { | |
57 | int s1; | |
58 | int s2; | |
59 | } st = { 101, 102 }; | |
60 | struct stag *stp = &st; | |
61 | ||
62 | union utag { | |
63 | int u1; | |
64 | long u2; | |
65 | } un; | |
66 | union utag *unp = &un; | |
67 | ||
68 | char carray[] = {'a', 'n', ' ', 'a', 'r', 'r', 'a', 'y', '\0'}; | |
69 | ||
70 | ||
71 | /* Test various permutations and interleaving of integral arguments */ | |
72 | ||
73 | ||
085dd6e6 JM |
74 | #ifdef PROTOTYPES |
75 | void call0a (char c, short s, int i, long l) | |
76 | #else | |
c906108c SS |
77 | call0a (c, s, i, l) |
78 | char c; short s; int i; long l; | |
085dd6e6 | 79 | #endif |
c906108c SS |
80 | { |
81 | c = 'a'; | |
82 | s = 5; | |
83 | i = 6; | |
84 | l = 7; | |
85 | } | |
86 | ||
085dd6e6 JM |
87 | #ifdef PROTOTYPES |
88 | void call0b (short s, int i, long l, char c) | |
89 | #else | |
c906108c SS |
90 | call0b (s, i, l, c) |
91 | short s; int i; long l; char c; | |
085dd6e6 | 92 | #endif |
c906108c SS |
93 | { |
94 | s = 6; i = 7; l = 8; c = 'j'; | |
95 | } | |
96 | ||
085dd6e6 JM |
97 | #ifdef PROTOTYPES |
98 | void call0c (int i, long l, char c, short s) | |
99 | #else | |
c906108c SS |
100 | call0c (i, l, c, s) |
101 | int i; long l; char c; short s; | |
085dd6e6 | 102 | #endif |
c906108c SS |
103 | { |
104 | i = 3; l = 4; c = 'k'; s = 5; | |
105 | } | |
106 | ||
085dd6e6 JM |
107 | #ifdef PROTOTYPES |
108 | void call0d (long l, char c, short s, int i) | |
109 | #else | |
c906108c SS |
110 | call0d (l, c, s, i) |
111 | long l; char c; short s; int i; | |
085dd6e6 | 112 | #endif |
c906108c SS |
113 | { |
114 | l = 7; c = 'z'; s = 8; i = 9; | |
115 | } | |
116 | ||
085dd6e6 JM |
117 | #ifdef PROTOTYPES |
118 | void call0e (char c1, long l, char c2, int i, char c3, short s, char c4, char c5) | |
119 | #else | |
c906108c SS |
120 | call0e (c1, l, c2, i, c3, s, c4, c5) |
121 | char c1; long l; char c2; int i; char c3; short s; char c4; char c5; | |
085dd6e6 | 122 | #endif |
c906108c SS |
123 | { |
124 | c1 = 'a'; l = 5; c2 = 'b'; i = 7; c3 = 'c'; s = 7; c4 = 'f'; c5 = 'g'; | |
125 | } | |
126 | ||
127 | ||
128 | /* Test various permutations and interleaving of unsigned integral arguments */ | |
129 | ||
130 | ||
085dd6e6 JM |
131 | #ifdef PROTOTYPES |
132 | void call1a (unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) | |
133 | #else | |
c906108c SS |
134 | call1a (uc, us, ui, ul) |
135 | unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul; | |
085dd6e6 | 136 | #endif |
c906108c SS |
137 | { |
138 | uc = 5; us = 6; ui = 7; ul = 8; | |
139 | } | |
140 | ||
085dd6e6 JM |
141 | #ifdef PROTOTYPES |
142 | void call1b (unsigned short us, unsigned int ui, unsigned long ul, unsigned char uc) | |
143 | #else | |
c906108c SS |
144 | call1b (us, ui, ul, uc) |
145 | unsigned short us; unsigned int ui; unsigned long ul; unsigned char uc; | |
085dd6e6 | 146 | #endif |
c906108c SS |
147 | { |
148 | uc = 5; us = 6; ui = 7; ul = 8; | |
149 | } | |
150 | ||
085dd6e6 JM |
151 | #ifdef PROTOTYPES |
152 | void call1c (unsigned int ui, unsigned long ul, unsigned char uc, unsigned short us) | |
153 | #else | |
c906108c SS |
154 | call1c (ui, ul, uc, us) |
155 | unsigned int ui; unsigned long ul; unsigned char uc; unsigned short us; | |
085dd6e6 | 156 | #endif |
c906108c SS |
157 | { |
158 | uc = 5; us = 6; ui = 7; ul = 8; | |
159 | } | |
160 | ||
085dd6e6 JM |
161 | #ifdef PROTOTYPES |
162 | void call1d (unsigned long ul, unsigned char uc, unsigned short us, unsigned int ui) | |
163 | #else | |
c906108c SS |
164 | call1d (ul, uc, us, ui) |
165 | unsigned long ul; unsigned char uc; unsigned short us; unsigned int ui; | |
085dd6e6 | 166 | #endif |
c906108c SS |
167 | { |
168 | uc = 5; us = 6; ui = 7; ul = 8; | |
169 | } | |
170 | ||
085dd6e6 JM |
171 | #ifdef PROTOTYPES |
172 | void call1e (unsigned char uc1, unsigned long ul, unsigned char uc2, unsigned int ui, unsigned char uc3, unsigned short us, unsigned char uc4, unsigned char uc5) | |
173 | #else | |
c906108c SS |
174 | call1e (uc1, ul, uc2, ui, uc3, us, uc4, uc5) |
175 | unsigned char uc1; unsigned long ul; unsigned char uc2; unsigned int ui; | |
176 | unsigned char uc3; unsigned short us; unsigned char uc4; unsigned char uc5; | |
085dd6e6 | 177 | #endif |
c906108c SS |
178 | { |
179 | uc1 = 5; ul = 7; uc2 = 8; ui = 9; uc3 = 10; us = 11; uc4 = 12; uc5 = 55; | |
180 | } | |
181 | ||
182 | /* Test various permutations and interleaving of integral arguments with | |
183 | floating point arguments. */ | |
184 | ||
185 | ||
085dd6e6 JM |
186 | #ifdef PROTOTYPES |
187 | void call2a (char c, float f1, short s, double d1, int i, float f2, long l, double d2) | |
188 | #else | |
c906108c SS |
189 | call2a (c, f1, s, d1, i, f2, l, d2) |
190 | char c; float f1; short s; double d1; int i; float f2; long l; double d2; | |
085dd6e6 | 191 | #endif |
c906108c SS |
192 | { |
193 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
194 | } | |
195 | ||
085dd6e6 JM |
196 | #ifdef PROTOTYPES |
197 | void call2b (float f1, short s, double d1, int i, float f2, long l, double d2, char c) | |
198 | #else | |
c906108c SS |
199 | call2b (f1, s, d1, i, f2, l, d2, c) |
200 | float f1; short s; double d1; int i; float f2; long l; double d2; char c; | |
085dd6e6 | 201 | #endif |
c906108c SS |
202 | { |
203 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
204 | } | |
205 | ||
085dd6e6 JM |
206 | #ifdef PROTOTYPES |
207 | void call2c (short s, double d1, int i, float f2, long l, double d2, char c, float f1) | |
208 | #else | |
c906108c SS |
209 | call2c (s, d1, i, f2, l, d2, c, f1) |
210 | short s; double d1; int i; float f2; long l; double d2; char c; float f1; | |
085dd6e6 | 211 | #endif |
c906108c SS |
212 | { |
213 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
214 | } | |
215 | ||
085dd6e6 JM |
216 | #ifdef PROTOTYPES |
217 | void call2d (double d1, int i, float f2, long l, double d2, char c, float f1, short s) | |
218 | #else | |
c906108c SS |
219 | call2d (d1, i, f2, l, d2, c, f1, s) |
220 | double d1; int i; float f2; long l; double d2; char c; float f1; short s; | |
085dd6e6 | 221 | #endif |
c906108c SS |
222 | { |
223 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
224 | } | |
225 | ||
085dd6e6 JM |
226 | #ifdef PROTOTYPES |
227 | void call2e (int i, float f2, long l, double d2, char c, float f1, short s, double d1) | |
228 | #else | |
c906108c SS |
229 | call2e (i, f2, l, d2, c, f1, s, d1) |
230 | int i; float f2; long l; double d2; char c; float f1; short s; double d1; | |
085dd6e6 | 231 | #endif |
c906108c SS |
232 | { |
233 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
234 | } | |
235 | ||
085dd6e6 JM |
236 | #ifdef PROTOTYPES |
237 | void call2f (float f2, long l, double d2, char c, float f1, short s, double d1, int i) | |
238 | #else | |
c906108c SS |
239 | call2f (f2, l, d2, c, f1, s, d1, i) |
240 | float f2; long l; double d2; char c; float f1; short s; double d1; int i; | |
085dd6e6 | 241 | #endif |
c906108c SS |
242 | { |
243 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
244 | } | |
245 | ||
085dd6e6 JM |
246 | #ifdef PROTOTYPES |
247 | void call2g (long l, double d2, char c, float f1, short s, double d1, int i, float f2) | |
248 | #else | |
c906108c SS |
249 | call2g (l, d2, c, f1, s, d1, i, f2) |
250 | long l; double d2; char c; float f1; short s; double d1; int i; float f2; | |
085dd6e6 | 251 | #endif |
c906108c SS |
252 | { |
253 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
254 | } | |
255 | ||
085dd6e6 JM |
256 | #ifdef PROTOTYPES |
257 | void call2h (double d2, char c, float f1, short s, double d1, int i, float f2, long l) | |
258 | #else | |
c906108c SS |
259 | call2h (d2, c, f1, s, d1, i, f2, l) |
260 | double d2; char c; float f1; short s; double d1; int i; float f2; long l; | |
085dd6e6 | 261 | #endif |
c906108c SS |
262 | { |
263 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
264 | } | |
265 | ||
085dd6e6 JM |
266 | #ifdef PROTOTYPES |
267 | void call2i (char c1, float f1, char c2, char c3, double d1, char c4, char c5, char c6, float f2, short s, char c7, double d2) | |
268 | #else | |
c906108c SS |
269 | call2i (c1, f1, c2, c3, d1, c4, c5, c6, f2, s, c7, d2) |
270 | char c1; float f1; char c2; char c3; double d1; char c4; char c5; char c6; | |
271 | float f2; short s; char c7; double d2; | |
085dd6e6 | 272 | #endif |
c906108c SS |
273 | { |
274 | c1 = 'a'; f1 = 0.0; c2 = 5; d1 = 0.0; c3 = 6; f2 = 0.1; c4 = 7; d2 = 0.2; | |
275 | c5 = 's'; c6 = 'f'; c7 = 'z'; s = 77; | |
276 | } | |
277 | ||
278 | ||
279 | /* Test pointers to various integral and floating types. */ | |
280 | ||
281 | ||
085dd6e6 JM |
282 | #ifdef PROTOTYPES |
283 | void call3a (char *cp, short *sp, int *ip, long *lp) | |
284 | #else | |
c906108c SS |
285 | call3a (cp, sp, ip, lp) |
286 | char *cp; short *sp; int *ip; long *lp; | |
085dd6e6 | 287 | #endif |
c906108c SS |
288 | { |
289 | cp = 0; sp = 0; ip = 0; lp = 0; | |
290 | } | |
291 | ||
085dd6e6 JM |
292 | #ifdef PROTOTYPES |
293 | void call3b (unsigned char *ucp, unsigned short *usp, unsigned int *uip, unsigned long *ulp) | |
294 | #else | |
c906108c SS |
295 | call3b (ucp, usp, uip, ulp) |
296 | unsigned char *ucp; unsigned short *usp; unsigned int *uip; | |
297 | unsigned long *ulp; | |
085dd6e6 | 298 | #endif |
c906108c SS |
299 | { |
300 | ucp = 0; usp = 0; uip = 0; ulp = 0; | |
301 | } | |
302 | ||
085dd6e6 JM |
303 | #ifdef PROTOTYPES |
304 | void call3c (float *fp, double *dp) | |
305 | #else | |
c906108c SS |
306 | call3c (fp, dp) |
307 | float *fp; double *dp; | |
085dd6e6 | 308 | #endif |
c906108c SS |
309 | { |
310 | fp = 0; dp = 0; | |
311 | } | |
312 | ||
313 | ||
314 | /* Test passing structures and unions by reference. */ | |
315 | ||
316 | ||
085dd6e6 JM |
317 | #ifdef PROTOTYPES |
318 | void call4a (struct stag *stp) | |
319 | #else | |
c906108c | 320 | call4a (stp) |
085dd6e6 JM |
321 | struct stag *stp; |
322 | #endif | |
323 | {stp = 0;} | |
c906108c | 324 | |
085dd6e6 JM |
325 | #ifdef PROTOTYPES |
326 | void call4b (union utag *unp) | |
327 | #else | |
c906108c SS |
328 | call4b (unp) |
329 | union utag *unp; | |
085dd6e6 | 330 | #endif |
c906108c SS |
331 | { |
332 | unp = 0; | |
333 | } | |
334 | ||
335 | ||
336 | /* Test passing structures and unions by value. */ | |
337 | ||
338 | ||
085dd6e6 JM |
339 | #ifdef PROTOTYPES |
340 | void call5a (struct stag st) | |
341 | #else | |
c906108c | 342 | call5a (st) |
085dd6e6 JM |
343 | struct stag st; |
344 | #endif | |
345 | {st.s1 = 5;} | |
c906108c | 346 | |
085dd6e6 JM |
347 | #ifdef PROTOTYPES |
348 | void call5b (union utag un) | |
349 | #else | |
c906108c | 350 | call5b (un) |
085dd6e6 JM |
351 | union utag un; |
352 | #endif | |
353 | {un.u1 = 7;} | |
c906108c SS |
354 | |
355 | ||
356 | /* Test shuffling of args */ | |
357 | ||
358 | ||
085dd6e6 | 359 | void call6k () |
c906108c | 360 | { |
c906108c SS |
361 | } |
362 | ||
085dd6e6 JM |
363 | #ifdef PROTOTYPES |
364 | void call6j (unsigned long ul) | |
365 | #else | |
366 | call6j (ul) | |
367 | unsigned long ul; | |
368 | #endif | |
c906108c | 369 | { |
085dd6e6 JM |
370 | ul = ul; |
371 | call6k (); | |
c906108c SS |
372 | } |
373 | ||
085dd6e6 JM |
374 | #ifdef PROTOTYPES |
375 | void call6i (unsigned int ui, unsigned long ul) | |
376 | #else | |
377 | call6i (ui, ul) | |
378 | unsigned int ui; unsigned long ul; | |
379 | #endif | |
c906108c | 380 | { |
085dd6e6 JM |
381 | ui = ui; |
382 | call6j (ul); | |
c906108c SS |
383 | } |
384 | ||
085dd6e6 JM |
385 | #ifdef PROTOTYPES |
386 | void call6h (unsigned short us, unsigned int ui, unsigned long ul) | |
387 | #else | |
388 | call6h (us, ui, ul) | |
389 | unsigned short us; unsigned int ui; unsigned long ul; | |
390 | #endif | |
c906108c | 391 | { |
085dd6e6 JM |
392 | us = us; |
393 | call6i (ui, ul); | |
c906108c SS |
394 | } |
395 | ||
085dd6e6 JM |
396 | #ifdef PROTOTYPES |
397 | void call6g (unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) | |
398 | #else | |
399 | call6g (uc, us, ui, ul) | |
c906108c | 400 | unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul; |
085dd6e6 | 401 | #endif |
c906108c | 402 | { |
085dd6e6 JM |
403 | uc = uc; |
404 | call6h (us, ui, ul); | |
c906108c SS |
405 | } |
406 | ||
085dd6e6 JM |
407 | #ifdef PROTOTYPES |
408 | void call6f (double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) | |
409 | #else | |
c906108c SS |
410 | call6f (d, uc, us, ui, ul) |
411 | double d; | |
412 | unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul; | |
085dd6e6 | 413 | #endif |
c906108c SS |
414 | { |
415 | d = d; | |
416 | call6g (uc, us, ui, ul); | |
417 | } | |
418 | ||
085dd6e6 JM |
419 | #ifdef PROTOTYPES |
420 | void call6e (float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) | |
421 | #else | |
422 | call6e (f, d, uc, us, ui, ul) | |
423 | float f; double d; | |
c906108c | 424 | unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul; |
085dd6e6 | 425 | #endif |
c906108c | 426 | { |
085dd6e6 JM |
427 | f = f; |
428 | call6f (d, uc, us, ui, ul); | |
c906108c SS |
429 | } |
430 | ||
085dd6e6 JM |
431 | #ifdef PROTOTYPES |
432 | void call6d (long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) | |
433 | #else | |
434 | call6d (l, f, d, uc, us, ui, ul) | |
435 | long l; float f; double d; | |
436 | unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul; | |
437 | #endif | |
c906108c | 438 | { |
085dd6e6 JM |
439 | l = l; |
440 | call6e (f, d, uc, us, ui, ul); | |
c906108c SS |
441 | } |
442 | ||
085dd6e6 JM |
443 | #ifdef PROTOTYPES |
444 | void call6c (int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) | |
445 | #else | |
446 | call6c (i, l, f, d, uc, us, ui, ul) | |
447 | int i; long l; float f; double d; | |
448 | unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul; | |
449 | #endif | |
c906108c | 450 | { |
085dd6e6 JM |
451 | i = i; |
452 | call6d (l, f, d, uc, us, ui, ul); | |
c906108c SS |
453 | } |
454 | ||
085dd6e6 JM |
455 | #ifdef PROTOTYPES |
456 | void call6b (short s, int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) | |
457 | #else | |
458 | call6b (s, i, l, f, d, uc, us, ui, ul) | |
459 | short s; int i; long l; float f; double d; | |
460 | unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul; | |
461 | #endif | |
c906108c | 462 | { |
085dd6e6 JM |
463 | s = s; |
464 | call6c (i, l, f, d, uc, us, ui, ul); | |
c906108c SS |
465 | } |
466 | ||
085dd6e6 JM |
467 | #ifdef PROTOTYPES |
468 | void call6a (char c, short s, int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) | |
469 | #else | |
470 | call6a (c, s, i, l, f, d, uc, us, ui, ul) | |
471 | char c; short s; int i; long l; float f; double d; | |
472 | unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul; | |
473 | #endif | |
c906108c | 474 | { |
085dd6e6 JM |
475 | c = c; |
476 | call6b (s, i, l, f, d, uc, us, ui, ul); | |
c906108c SS |
477 | } |
478 | ||
c906108c SS |
479 | /* Test shuffling of args, round robin */ |
480 | ||
481 | ||
085dd6e6 JM |
482 | #ifdef PROTOTYPES |
483 | void call7k (char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui) | |
484 | #else | |
485 | call7k (c, i, s, l, f, uc, d, us, ul, ui) | |
c906108c | 486 | char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; |
085dd6e6 | 487 | #endif |
c906108c | 488 | { |
085dd6e6 JM |
489 | c = 'a'; i = 7; s = 8; l = 7; f = 0.3; uc = 44; d = 0.44; us = 77; |
490 | ul = 43; ui = 33; | |
c906108c SS |
491 | } |
492 | ||
085dd6e6 JM |
493 | #ifdef PROTOTYPES |
494 | void call7j (unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul) | |
495 | #else | |
496 | call7j (ui, c, i, s, l, f, uc, d, us, ul) | |
497 | unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; | |
498 | #endif | |
c906108c | 499 | { |
085dd6e6 | 500 | call7k (c, i, s, l, f, uc, d, us, ul, ui); |
c906108c SS |
501 | } |
502 | ||
085dd6e6 JM |
503 | #ifdef PROTOTYPES |
504 | void call7i (unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us) | |
505 | #else | |
506 | call7i (ul, ui, c, i, s, l, f, uc, d, us) | |
507 | unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; | |
508 | #endif | |
c906108c | 509 | { |
085dd6e6 | 510 | call7j (ui, c, i, s, l, f, uc, d, us, ul); |
c906108c SS |
511 | } |
512 | ||
085dd6e6 JM |
513 | #ifdef PROTOTYPES |
514 | void call7h (unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc, double d) | |
515 | #else | |
516 | call7h (us, ul, ui, c, i, s, l, f, uc, d) | |
517 | unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; double d; | |
518 | #endif | |
c906108c | 519 | { |
085dd6e6 | 520 | call7i (ul, ui, c, i, s, l, f, uc, d, us); |
c906108c SS |
521 | } |
522 | ||
085dd6e6 JM |
523 | #ifdef PROTOTYPES |
524 | void call7g (double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc) | |
525 | #else | |
526 | call7g (d, us, ul, ui, c, i, s, l, f, uc) | |
527 | double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; | |
528 | #endif | |
c906108c | 529 | { |
085dd6e6 | 530 | call7h (us, ul, ui, c, i, s, l, f, uc, d); |
c906108c SS |
531 | } |
532 | ||
085dd6e6 JM |
533 | #ifdef PROTOTYPES |
534 | void call7f (unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f) | |
535 | #else | |
c906108c SS |
536 | call7f (uc, d, us, ul, ui, c, i, s, l, f) |
537 | unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; | |
085dd6e6 | 538 | #endif |
c906108c SS |
539 | { |
540 | call7g (d, us, ul, ui, c, i, s, l, f, uc); | |
541 | } | |
542 | ||
085dd6e6 JM |
543 | #ifdef PROTOTYPES |
544 | void call7e (float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l) | |
545 | #else | |
546 | call7e (f, uc, d, us, ul, ui, c, i, s, l) | |
547 | float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; | |
548 | #endif | |
c906108c | 549 | { |
085dd6e6 | 550 | call7f (uc, d, us, ul, ui, c, i, s, l, f); |
c906108c SS |
551 | } |
552 | ||
085dd6e6 JM |
553 | #ifdef PROTOTYPES |
554 | void call7d (long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s) | |
555 | #else | |
556 | call7d (l, f, uc, d, us, ul, ui, c, i, s) | |
557 | long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; | |
558 | #endif | |
c906108c | 559 | { |
085dd6e6 | 560 | call7e (f, uc, d, us, ul, ui, c, i, s, l); |
c906108c SS |
561 | } |
562 | ||
085dd6e6 JM |
563 | #ifdef PROTOTYPES |
564 | void call7c (short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i) | |
565 | #else | |
566 | call7c (s, l, f, uc, d, us, ul, ui, c, i) | |
567 | short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; | |
568 | #endif | |
c906108c | 569 | { |
085dd6e6 | 570 | call7d (l, f, uc, d, us, ul, ui, c, i, s); |
c906108c SS |
571 | } |
572 | ||
085dd6e6 JM |
573 | #ifdef PROTOTYPES |
574 | void call7b (int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c) | |
575 | #else | |
576 | call7b (i, s, l, f, uc, d, us, ul, ui, c) | |
577 | int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; | |
578 | #endif | |
c906108c | 579 | { |
085dd6e6 | 580 | call7c (s, l, f, uc, d, us, ul, ui, c, i); |
c906108c SS |
581 | } |
582 | ||
085dd6e6 JM |
583 | #ifdef PROTOTYPES |
584 | void call7a (char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui) | |
585 | #else | |
586 | call7a (c, i, s, l, f, uc, d, us, ul, ui) | |
c906108c | 587 | char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; |
085dd6e6 | 588 | #endif |
c906108c | 589 | { |
085dd6e6 | 590 | call7b (i, s, l, f, uc, d, us, ul, ui, c); |
c906108c SS |
591 | } |
592 | ||
593 | ||
594 | /* Test printing of structures passed as arguments to recursive functions. */ | |
595 | ||
596 | ||
597 | typedef struct s | |
598 | { | |
599 | short s; | |
600 | int i; | |
601 | long l; | |
602 | } SVAL; | |
603 | ||
085dd6e6 | 604 | void hitbottom () |
c906108c SS |
605 | { |
606 | } | |
607 | ||
085dd6e6 JM |
608 | #ifdef PROTOTYPES |
609 | void recurse (SVAL a, int depth) | |
610 | #else | |
c906108c SS |
611 | void recurse (a, depth) |
612 | SVAL a; | |
613 | int depth; | |
085dd6e6 | 614 | #endif |
c906108c SS |
615 | { |
616 | a.s = a.i = a.l = --depth; | |
617 | if (depth == 0) | |
618 | hitbottom (); | |
619 | else | |
620 | recurse (a, depth); | |
621 | } | |
622 | ||
085dd6e6 | 623 | void test_struct_args () |
c906108c SS |
624 | { |
625 | SVAL s; s.s = 5; s.i = 5; s.l = 5; | |
626 | ||
627 | recurse (s, 5); | |
628 | } | |
629 | ||
630 | /* On various machines (pa, 29k, and rs/6000, at least), a function which | |
631 | calls alloca may do things differently with respect to frames. So give | |
632 | it a try. */ | |
633 | ||
085dd6e6 JM |
634 | #ifdef PROTOTYPES |
635 | void localvars_after_alloca (char c, short s, int i, long l) | |
636 | #else | |
c906108c SS |
637 | int |
638 | localvars_after_alloca (c, s, i, l) | |
639 | char c; | |
640 | short s; | |
641 | int i; | |
642 | long l; | |
085dd6e6 | 643 | #endif |
c906108c SS |
644 | { |
645 | #ifdef HAVE_STACK_ALLOCA | |
646 | /* No need to use the alloca.c alloca-on-top-of-malloc; it doesn't | |
647 | test what we are looking for, so if we don't have an alloca which | |
648 | allocates on the stack, just don't bother to call alloca at all. */ | |
649 | ||
650 | char *z = alloca (s + 50); | |
651 | #endif | |
652 | c = 'a'; | |
653 | s = 5; | |
654 | i = 6; | |
655 | l = 7; | |
656 | } | |
657 | ||
085dd6e6 JM |
658 | #ifdef PROTOTYPES |
659 | void call_after_alloca_subr (char c, short s, int i, long l, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) | |
660 | #else | |
c906108c SS |
661 | void |
662 | call_after_alloca_subr (c, s, i, l, uc, us, ui, ul) | |
663 | char c; int i; short s; long l; unsigned char uc; unsigned short us; unsigned long ul; unsigned int ui; | |
085dd6e6 | 664 | #endif |
c906108c SS |
665 | { |
666 | c = 'a'; | |
667 | i = 7; s = 8; l = 7; uc = 44; us = 77; | |
668 | ul = 43; ui = 33; | |
669 | } | |
670 | ||
085dd6e6 JM |
671 | #ifdef PROTOTYPES |
672 | void call_after_alloca (char c, short s, int i, long l) | |
673 | #else | |
c906108c SS |
674 | int |
675 | call_after_alloca (c, s, i, l) | |
676 | char c; | |
677 | short s; | |
678 | int i; | |
679 | long l; | |
085dd6e6 | 680 | #endif |
c906108c SS |
681 | { |
682 | #ifdef HAVE_STACK_ALLOCA | |
683 | /* No need to use the alloca.c alloca-on-top-of-malloc; it doesn't | |
684 | test what we are looking for, so if we don't have an alloca which | |
685 | allocates on the stack, just don't bother to call alloca at all. */ | |
686 | ||
687 | char *z = alloca (s + 50); | |
688 | #endif | |
689 | call_after_alloca_subr (c, s, i, l, 'b', 11, 12, (unsigned long)13); | |
690 | } | |
691 | ||
692 | \f | |
693 | ||
694 | /* The point behind this test is the PA will call this indirectly | |
695 | through dyncall. Unlike the indirect calls to call0a, this test | |
696 | will require a trampoline between dyncall and this function on the | |
697 | call path, then another trampoline on between this function and main | |
698 | on the return path. */ | |
085dd6e6 JM |
699 | #ifdef PROTOTYPES |
700 | double call_with_trampolines (double d1) | |
701 | #else | |
c906108c SS |
702 | double |
703 | call_with_trampolines (d1) | |
704 | double d1; | |
085dd6e6 | 705 | #endif |
c906108c SS |
706 | { |
707 | return d1; | |
708 | } /* End of call_with_trampolines, this comment is needed by funcargs.exp */ | |
709 | ||
710 | /* Dummy functions which the testsuite can use to run to, etc. */ | |
711 | ||
712 | void | |
713 | marker_indirect_call () {} | |
714 | ||
715 | void | |
716 | marker_call_with_trampolines () {} | |
717 | \f | |
085dd6e6 | 718 | int main () |
c906108c | 719 | { |
085dd6e6 JM |
720 | void (*pointer_to_call0a) (char, short, int, long) = (void (*)(char, short, int, long))call0a; |
721 | double (*pointer_to_call_with_trampolines) (double) = call_with_trampolines; | |
c906108c SS |
722 | |
723 | #ifdef usestubs | |
724 | set_debug_traps(); | |
725 | breakpoint(); | |
726 | #endif | |
727 | /* Test calling with basic integer types */ | |
728 | call0a (c, s, i, l); | |
729 | call0b (s, i, l, c); | |
730 | call0c (i, l, c, s); | |
731 | call0d (l, c, s, i); | |
732 | call0e (c, l, c, i, c, s, c, c); | |
733 | ||
734 | /* Test calling with unsigned integer types */ | |
735 | call1a (uc, us, ui, ul); | |
736 | call1b (us, ui, ul, uc); | |
737 | call1c (ui, ul, uc, us); | |
738 | call1d (ul, uc, us, ui); | |
739 | call1e (uc, ul, uc, ui, uc, us, uc, uc); | |
740 | ||
741 | /* Test calling with integral types mixed with floating point types */ | |
742 | call2a (c, f, s, d, i, f, l, d); | |
743 | call2b (f, s, d, i, f, l, d, c); | |
744 | call2c (s, d, i, f, l, d, c, f); | |
745 | call2d (d, i, f, l, d, c, f, s); | |
746 | call2e (i, f, l, d, c, f, s, d); | |
747 | call2f (f, l, d, c, f, s, d, i); | |
748 | call2g (l, d, c, f, s, d, i, f); | |
749 | call2h (d, c, f, s, d, i, f, l); | |
750 | call2i (c, f, c, c, d, c, c, c, f, s, c, d);; | |
751 | ||
752 | /* Test dereferencing pointers to various integral and floating types */ | |
753 | ||
754 | call3a (cp, sp, ip, lp); | |
755 | call3b (ucp, usp, uip, ulp); | |
756 | call3c (fp, dp); | |
757 | ||
758 | /* Test dereferencing pointers to structs and unions */ | |
759 | ||
760 | call4a (stp); | |
761 | un.u1 = 1; | |
762 | call4b (unp); | |
763 | ||
764 | /* Test calling with structures and unions. */ | |
765 | ||
766 | call5a (st); | |
767 | un.u1 = 2; | |
768 | call5b (un); | |
769 | ||
770 | /* Test shuffling of args */ | |
771 | ||
772 | call6a (c, s, i, l, f, d, uc, us, ui, ul); | |
773 | call7a (c, i, s, l, f, uc, d, us, ul, ui); | |
774 | ||
775 | /* Test passing structures recursively. */ | |
776 | ||
777 | test_struct_args (); | |
778 | ||
779 | localvars_after_alloca (c, s, i, l); | |
780 | ||
781 | call_after_alloca (c, s, i, l); | |
782 | ||
783 | /* This is for localvars_in_indirect_call. */ | |
784 | marker_indirect_call (); | |
785 | /* The comment on the following two lines is used by funcargs.exp, | |
786 | don't change it. */ | |
787 | (*pointer_to_call0a) (c, s, i, l); /* First step into call0a. */ | |
788 | (*pointer_to_call0a) (c, s, i, l); /* Second step into call0a. */ | |
789 | marker_call_with_trampolines (); | |
790 | (*pointer_to_call_with_trampolines) (d); /* Test multiple trampolines. */ | |
085dd6e6 | 791 | return 0; |
c906108c | 792 | } |