]>
| 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 | ||
| e43ec454 YQ |
56 | #ifdef TEST_COMPLEX |
| 57 | float _Complex fc = 1.0F + 2.0iF; | |
| 58 | double _Complex dc = 3.0 + 4.0i; | |
| 59 | long double _Complex ldc = 5.0L + 6.0iL; | |
| 60 | #endif /* TEST_COMPLEX */ | |
| 61 | ||
| c906108c SS |
62 | struct stag { |
| 63 | int s1; | |
| 64 | int s2; | |
| 65 | } st = { 101, 102 }; | |
| 66 | struct stag *stp = &st; | |
| 67 | ||
| 68 | union utag { | |
| 69 | int u1; | |
| 70 | long u2; | |
| 71 | } un; | |
| 72 | union utag *unp = &un; | |
| 73 | ||
| 74 | char carray[] = {'a', 'n', ' ', 'a', 'r', 'r', 'a', 'y', '\0'}; | |
| 75 | ||
| 76 | ||
| 77 | /* Test various permutations and interleaving of integral arguments */ | |
| 78 | ||
| 79 | ||
| 085dd6e6 | 80 | void call0a (char c, short s, int i, long l) |
| c906108c SS |
81 | { |
| 82 | c = 'a'; | |
| 83 | s = 5; | |
| 84 | i = 6; | |
| 85 | l = 7; | |
| 86 | } | |
| 87 | ||
| 085dd6e6 | 88 | void call0b (short s, int i, long l, char c) |
| c906108c SS |
89 | { |
| 90 | s = 6; i = 7; l = 8; c = 'j'; | |
| 91 | } | |
| 92 | ||
| 085dd6e6 | 93 | void call0c (int i, long l, char c, short s) |
| c906108c SS |
94 | { |
| 95 | i = 3; l = 4; c = 'k'; s = 5; | |
| 96 | } | |
| 97 | ||
| 085dd6e6 | 98 | void call0d (long l, char c, short s, int i) |
| c906108c SS |
99 | { |
| 100 | l = 7; c = 'z'; s = 8; i = 9; | |
| 101 | } | |
| 102 | ||
| 085dd6e6 | 103 | void call0e (char c1, long l, char c2, int i, char c3, short s, char c4, char c5) |
| c906108c SS |
104 | { |
| 105 | c1 = 'a'; l = 5; c2 = 'b'; i = 7; c3 = 'c'; s = 7; c4 = 'f'; c5 = 'g'; | |
| 106 | } | |
| 107 | ||
| 108 | ||
| 109 | /* Test various permutations and interleaving of unsigned integral arguments */ | |
| 110 | ||
| 111 | ||
| 085dd6e6 | 112 | void call1a (unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) |
| c906108c SS |
113 | { |
| 114 | uc = 5; us = 6; ui = 7; ul = 8; | |
| 115 | } | |
| 116 | ||
| 085dd6e6 | 117 | void call1b (unsigned short us, unsigned int ui, unsigned long ul, unsigned char uc) |
| c906108c SS |
118 | { |
| 119 | uc = 5; us = 6; ui = 7; ul = 8; | |
| 120 | } | |
| 121 | ||
| 085dd6e6 | 122 | void call1c (unsigned int ui, unsigned long ul, unsigned char uc, unsigned short us) |
| c906108c SS |
123 | { |
| 124 | uc = 5; us = 6; ui = 7; ul = 8; | |
| 125 | } | |
| 126 | ||
| 085dd6e6 | 127 | void call1d (unsigned long ul, unsigned char uc, unsigned short us, unsigned int ui) |
| c906108c SS |
128 | { |
| 129 | uc = 5; us = 6; ui = 7; ul = 8; | |
| 130 | } | |
| 131 | ||
| 085dd6e6 | 132 | 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) |
| c906108c SS |
133 | { |
| 134 | uc1 = 5; ul = 7; uc2 = 8; ui = 9; uc3 = 10; us = 11; uc4 = 12; uc5 = 55; | |
| 135 | } | |
| 136 | ||
| 137 | /* Test various permutations and interleaving of integral arguments with | |
| 138 | floating point arguments. */ | |
| 139 | ||
| 140 | ||
| 085dd6e6 | 141 | void call2a (char c, float f1, short s, double d1, int i, float f2, long l, double d2) |
| c906108c SS |
142 | { |
| 143 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
| 144 | } | |
| 145 | ||
| 085dd6e6 | 146 | void call2b (float f1, short s, double d1, int i, float f2, long l, double d2, char c) |
| c906108c SS |
147 | { |
| 148 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
| 149 | } | |
| 150 | ||
| 085dd6e6 | 151 | void call2c (short s, double d1, int i, float f2, long l, double d2, char c, float f1) |
| c906108c SS |
152 | { |
| 153 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
| 154 | } | |
| 155 | ||
| 085dd6e6 | 156 | void call2d (double d1, int i, float f2, long l, double d2, char c, float f1, short s) |
| c906108c SS |
157 | { |
| 158 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
| 159 | } | |
| 160 | ||
| 085dd6e6 | 161 | void call2e (int i, float f2, long l, double d2, char c, float f1, short s, double d1) |
| c906108c SS |
162 | { |
| 163 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
| 164 | } | |
| 165 | ||
| 085dd6e6 | 166 | void call2f (float f2, long l, double d2, char c, float f1, short s, double d1, int i) |
| c906108c SS |
167 | { |
| 168 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
| 169 | } | |
| 170 | ||
| 085dd6e6 | 171 | void call2g (long l, double d2, char c, float f1, short s, double d1, int i, float f2) |
| c906108c SS |
172 | { |
| 173 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
| 174 | } | |
| 175 | ||
| 085dd6e6 | 176 | void call2h (double d2, char c, float f1, short s, double d1, int i, float f2, long l) |
| c906108c SS |
177 | { |
| 178 | c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2; | |
| 179 | } | |
| 180 | ||
| 085dd6e6 | 181 | 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) |
| c906108c SS |
182 | { |
| 183 | c1 = 'a'; f1 = 0.0; c2 = 5; d1 = 0.0; c3 = 6; f2 = 0.1; c4 = 7; d2 = 0.2; | |
| 184 | c5 = 's'; c6 = 'f'; c7 = 'z'; s = 77; | |
| 185 | } | |
| 186 | ||
| 187 | ||
| 188 | /* Test pointers to various integral and floating types. */ | |
| 189 | ||
| 190 | ||
| 085dd6e6 | 191 | void call3a (char *cp, short *sp, int *ip, long *lp) |
| c906108c SS |
192 | { |
| 193 | cp = 0; sp = 0; ip = 0; lp = 0; | |
| 194 | } | |
| 195 | ||
| 085dd6e6 | 196 | void call3b (unsigned char *ucp, unsigned short *usp, unsigned int *uip, unsigned long *ulp) |
| c906108c SS |
197 | { |
| 198 | ucp = 0; usp = 0; uip = 0; ulp = 0; | |
| 199 | } | |
| 200 | ||
| 085dd6e6 | 201 | void call3c (float *fp, double *dp) |
| c906108c SS |
202 | { |
| 203 | fp = 0; dp = 0; | |
| 204 | } | |
| 205 | ||
| 206 | ||
| e43ec454 YQ |
207 | |
| 208 | #ifdef TEST_COMPLEX | |
| 209 | ||
| 210 | /* Test various _Complex type args. */ | |
| 211 | ||
| e43ec454 | 212 | void callca (float _Complex f1, float _Complex f2, float _Complex f3) |
| e43ec454 YQ |
213 | { |
| 214 | ||
| 215 | } | |
| 216 | ||
| e43ec454 | 217 | void callcb (double _Complex d1, double _Complex d2, double _Complex d3) |
| e43ec454 YQ |
218 | { |
| 219 | ||
| 220 | } | |
| 221 | ||
| e43ec454 | 222 | void callcc (long double _Complex ld1, long double _Complex ld2, long double _Complex ld3) |
| e43ec454 YQ |
223 | { |
| 224 | ||
| 225 | } | |
| 226 | ||
| e43ec454 | 227 | void callcd (float _Complex fc1, double _Complex dc1, long double _Complex ldc1) |
| e43ec454 YQ |
228 | { |
| 229 | } | |
| 230 | ||
| e43ec454 | 231 | void callce (double _Complex dc1, long double _Complex ldc1, float _Complex fc1) |
| e43ec454 YQ |
232 | { |
| 233 | } | |
| 234 | ||
| e43ec454 | 235 | void callcf (long double _Complex ldc1, float _Complex fc1, double _Complex dc1) |
| e43ec454 YQ |
236 | { |
| 237 | } | |
| 238 | ||
| 239 | ||
| 240 | /* Test passing _Complex type and integral. */ | |
| e43ec454 YQ |
241 | void callc1a (char c, short s, int i, unsigned int ui, long l, |
| 242 | float _Complex fc1, double _Complex dc1, | |
| 243 | long double _Complex ldc1) | |
| e43ec454 YQ |
244 | {} |
| 245 | ||
| e43ec454 YQ |
246 | void callc1b (long double _Complex ldc1, char c, short s, int i, |
| 247 | float _Complex fc1, unsigned int ui, long l, double _Complex dc1) | |
| e43ec454 YQ |
248 | {} |
| 249 | ||
| 250 | ||
| e43ec454 YQ |
251 | void callc2a (char c, short s, int i, unsigned int ui, long l, float f, |
| 252 | double d, float _Complex fc1, double _Complex dc1, | |
| 253 | long double _Complex ldc1) | |
| e43ec454 YQ |
254 | {} |
| 255 | ||
| e43ec454 YQ |
256 | void callc2b (float _Complex fc1, char c, short s, int i, unsigned int ui, |
| 257 | long double _Complex ldc1, long l, float f, double d, | |
| 258 | double _Complex dc1) | |
| e43ec454 YQ |
259 | {} |
| 260 | ||
| 261 | ||
| 262 | #endif /* TEST_COMPLEX */ | |
| 263 | ||
| c906108c SS |
264 | /* Test passing structures and unions by reference. */ |
| 265 | ||
| 266 | ||
| 085dd6e6 | 267 | void call4a (struct stag *stp) |
| 085dd6e6 | 268 | {stp = 0;} |
| c906108c | 269 | |
| 085dd6e6 | 270 | void call4b (union utag *unp) |
| c906108c SS |
271 | { |
| 272 | unp = 0; | |
| 273 | } | |
| 274 | ||
| 275 | ||
| 276 | /* Test passing structures and unions by value. */ | |
| 277 | ||
| 278 | ||
| 085dd6e6 | 279 | void call5a (struct stag st) |
| 085dd6e6 | 280 | {st.s1 = 5;} |
| c906108c | 281 | |
| 085dd6e6 | 282 | void call5b (union utag un) |
| 085dd6e6 | 283 | {un.u1 = 7;} |
| c906108c SS |
284 | |
| 285 | ||
| 286 | /* Test shuffling of args */ | |
| 287 | ||
| 288 | ||
| 085dd6e6 | 289 | void call6k () |
| c906108c | 290 | { |
| c906108c SS |
291 | } |
| 292 | ||
| 085dd6e6 | 293 | void call6j (unsigned long ul) |
| c906108c | 294 | { |
| 085dd6e6 JM |
295 | ul = ul; |
| 296 | call6k (); | |
| c906108c SS |
297 | } |
| 298 | ||
| 085dd6e6 | 299 | void call6i (unsigned int ui, unsigned long ul) |
| c906108c | 300 | { |
| 085dd6e6 JM |
301 | ui = ui; |
| 302 | call6j (ul); | |
| c906108c SS |
303 | } |
| 304 | ||
| 085dd6e6 | 305 | void call6h (unsigned short us, unsigned int ui, unsigned long ul) |
| c906108c | 306 | { |
| 085dd6e6 JM |
307 | us = us; |
| 308 | call6i (ui, ul); | |
| c906108c SS |
309 | } |
| 310 | ||
| 085dd6e6 | 311 | void call6g (unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) |
| c906108c | 312 | { |
| 085dd6e6 JM |
313 | uc = uc; |
| 314 | call6h (us, ui, ul); | |
| c906108c SS |
315 | } |
| 316 | ||
| 085dd6e6 | 317 | void call6f (double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) |
| c906108c SS |
318 | { |
| 319 | d = d; | |
| 320 | call6g (uc, us, ui, ul); | |
| 321 | } | |
| 322 | ||
| 085dd6e6 | 323 | void call6e (float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) |
| c906108c | 324 | { |
| 085dd6e6 JM |
325 | f = f; |
| 326 | call6f (d, uc, us, ui, ul); | |
| c906108c SS |
327 | } |
| 328 | ||
| 085dd6e6 | 329 | void call6d (long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) |
| c906108c | 330 | { |
| 085dd6e6 JM |
331 | l = l; |
| 332 | call6e (f, d, uc, us, ui, ul); | |
| c906108c SS |
333 | } |
| 334 | ||
| 085dd6e6 | 335 | void call6c (int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) |
| c906108c | 336 | { |
| 085dd6e6 JM |
337 | i = i; |
| 338 | call6d (l, f, d, uc, us, ui, ul); | |
| c906108c SS |
339 | } |
| 340 | ||
| 085dd6e6 | 341 | void call6b (short s, int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul) |
| c906108c | 342 | { |
| 085dd6e6 JM |
343 | s = s; |
| 344 | call6c (i, l, f, d, uc, us, ui, ul); | |
| c906108c SS |
345 | } |
| 346 | ||
| 085dd6e6 | 347 | 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) |
| c906108c | 348 | { |
| 085dd6e6 JM |
349 | c = c; |
| 350 | call6b (s, i, l, f, d, uc, us, ui, ul); | |
| c906108c SS |
351 | } |
| 352 | ||
| c906108c SS |
353 | /* Test shuffling of args, round robin */ |
| 354 | ||
| 355 | ||
| 085dd6e6 | 356 | 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) |
| c906108c | 357 | { |
| 085dd6e6 JM |
358 | c = 'a'; i = 7; s = 8; l = 7; f = 0.3; uc = 44; d = 0.44; us = 77; |
| 359 | ul = 43; ui = 33; | |
| c906108c SS |
360 | } |
| 361 | ||
| 085dd6e6 | 362 | 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) |
| c906108c | 363 | { |
| 085dd6e6 | 364 | call7k (c, i, s, l, f, uc, d, us, ul, ui); |
| c906108c SS |
365 | } |
| 366 | ||
| 085dd6e6 | 367 | 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) |
| c906108c | 368 | { |
| 085dd6e6 | 369 | call7j (ui, c, i, s, l, f, uc, d, us, ul); |
| c906108c SS |
370 | } |
| 371 | ||
| 085dd6e6 | 372 | 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) |
| c906108c | 373 | { |
| 085dd6e6 | 374 | call7i (ul, ui, c, i, s, l, f, uc, d, us); |
| c906108c SS |
375 | } |
| 376 | ||
| 085dd6e6 | 377 | 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) |
| c906108c | 378 | { |
| 085dd6e6 | 379 | call7h (us, ul, ui, c, i, s, l, f, uc, d); |
| c906108c SS |
380 | } |
| 381 | ||
| 085dd6e6 | 382 | 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) |
| c906108c SS |
383 | { |
| 384 | call7g (d, us, ul, ui, c, i, s, l, f, uc); | |
| 385 | } | |
| 386 | ||
| 085dd6e6 | 387 | 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) |
| c906108c | 388 | { |
| 085dd6e6 | 389 | call7f (uc, d, us, ul, ui, c, i, s, l, f); |
| c906108c SS |
390 | } |
| 391 | ||
| 085dd6e6 | 392 | 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) |
| c906108c | 393 | { |
| 085dd6e6 | 394 | call7e (f, uc, d, us, ul, ui, c, i, s, l); |
| c906108c SS |
395 | } |
| 396 | ||
| 085dd6e6 | 397 | 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) |
| c906108c | 398 | { |
| 085dd6e6 | 399 | call7d (l, f, uc, d, us, ul, ui, c, i, s); |
| c906108c SS |
400 | } |
| 401 | ||
| 085dd6e6 | 402 | 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) |
| c906108c | 403 | { |
| 085dd6e6 | 404 | call7c (s, l, f, uc, d, us, ul, ui, c, i); |
| c906108c SS |
405 | } |
| 406 | ||
| 085dd6e6 | 407 | 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) |
| c906108c | 408 | { |
| 085dd6e6 | 409 | call7b (i, s, l, f, uc, d, us, ul, ui, c); |
| c906108c SS |
410 | } |
| 411 | ||
| 412 | ||
| 413 | /* Test printing of structures passed as arguments to recursive functions. */ | |
| 414 | ||
| 415 | ||
| 416 | typedef struct s | |
| 417 | { | |
| 418 | short s; | |
| 419 | int i; | |
| 420 | long l; | |
| a5cbe675 | 421 | } SVAL; |
| c906108c | 422 | |
| 085dd6e6 | 423 | void hitbottom () |
| c906108c SS |
424 | { |
| 425 | } | |
| 426 | ||
| c67f2e15 AB |
427 | void use_a (SVAL a) |
| 428 | { | |
| 429 | /* Trick the compiler into thinking A is important. */ | |
| 430 | volatile SVAL dummy = a; | |
| 431 | } | |
| 432 | ||
| 085dd6e6 | 433 | void recurse (SVAL a, int depth) |
| c906108c SS |
434 | { |
| 435 | a.s = a.i = a.l = --depth; | |
| 436 | if (depth == 0) | |
| 437 | hitbottom (); | |
| 438 | else | |
| 439 | recurse (a, depth); | |
| c67f2e15 AB |
440 | |
| 441 | /* Ensure A is not discarded after the above calls. */ | |
| 442 | use_a (a); | |
| c906108c SS |
443 | } |
| 444 | ||
| 085dd6e6 | 445 | void test_struct_args () |
| c906108c SS |
446 | { |
| 447 | SVAL s; s.s = 5; s.i = 5; s.l = 5; | |
| 448 | ||
| 449 | recurse (s, 5); | |
| 450 | } | |
| 451 | ||
| 452 | /* On various machines (pa, 29k, and rs/6000, at least), a function which | |
| 453 | calls alloca may do things differently with respect to frames. So give | |
| 454 | it a try. */ | |
| 455 | ||
| 085dd6e6 | 456 | void localvars_after_alloca (char c, short s, int i, long l) |
| c906108c SS |
457 | { |
| 458 | #ifdef HAVE_STACK_ALLOCA | |
| 459 | /* No need to use the alloca.c alloca-on-top-of-malloc; it doesn't | |
| 460 | test what we are looking for, so if we don't have an alloca which | |
| 461 | allocates on the stack, just don't bother to call alloca at all. */ | |
| 462 | ||
| 463 | char *z = alloca (s + 50); | |
| 464 | #endif | |
| 465 | c = 'a'; | |
| 466 | s = 5; | |
| 467 | i = 6; | |
| 468 | l = 7; | |
| 469 | } | |
| 470 | ||
| 085dd6e6 | 471 | 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) |
| c906108c SS |
472 | { |
| 473 | c = 'a'; | |
| 474 | i = 7; s = 8; l = 7; uc = 44; us = 77; | |
| 475 | ul = 43; ui = 33; | |
| 476 | } | |
| 477 | ||
| 085dd6e6 | 478 | void call_after_alloca (char c, short s, int i, long l) |
| c906108c SS |
479 | { |
| 480 | #ifdef HAVE_STACK_ALLOCA | |
| 481 | /* No need to use the alloca.c alloca-on-top-of-malloc; it doesn't | |
| 482 | test what we are looking for, so if we don't have an alloca which | |
| 483 | allocates on the stack, just don't bother to call alloca at all. */ | |
| 484 | ||
| 485 | char *z = alloca (s + 50); | |
| 486 | #endif | |
| 487 | call_after_alloca_subr (c, s, i, l, 'b', 11, 12, (unsigned long)13); | |
| 488 | } | |
| 489 | ||
| 490 | \f | |
| 491 | ||
| 492 | /* The point behind this test is the PA will call this indirectly | |
| 493 | through dyncall. Unlike the indirect calls to call0a, this test | |
| 494 | will require a trampoline between dyncall and this function on the | |
| 495 | call path, then another trampoline on between this function and main | |
| 496 | on the return path. */ | |
| 085dd6e6 | 497 | double call_with_trampolines (double d1) |
| c906108c SS |
498 | { |
| 499 | return d1; | |
| 500 | } /* End of call_with_trampolines, this comment is needed by funcargs.exp */ | |
| 501 | ||
| 502 | /* Dummy functions which the testsuite can use to run to, etc. */ | |
| 503 | ||
| 504 | void | |
| 505 | marker_indirect_call () {} | |
| 506 | ||
| 507 | void | |
| 508 | marker_call_with_trampolines () {} | |
| 509 | \f | |
| 085dd6e6 | 510 | int main () |
| c906108c | 511 | { |
| 085dd6e6 JM |
512 | void (*pointer_to_call0a) (char, short, int, long) = (void (*)(char, short, int, long))call0a; |
| 513 | double (*pointer_to_call_with_trampolines) (double) = call_with_trampolines; | |
| c906108c | 514 | |
| c906108c SS |
515 | /* Test calling with basic integer types */ |
| 516 | call0a (c, s, i, l); | |
| 517 | call0b (s, i, l, c); | |
| 518 | call0c (i, l, c, s); | |
| 519 | call0d (l, c, s, i); | |
| 520 | call0e (c, l, c, i, c, s, c, c); | |
| 521 | ||
| 522 | /* Test calling with unsigned integer types */ | |
| 523 | call1a (uc, us, ui, ul); | |
| 524 | call1b (us, ui, ul, uc); | |
| 525 | call1c (ui, ul, uc, us); | |
| 526 | call1d (ul, uc, us, ui); | |
| 527 | call1e (uc, ul, uc, ui, uc, us, uc, uc); | |
| 528 | ||
| 529 | /* Test calling with integral types mixed with floating point types */ | |
| 530 | call2a (c, f, s, d, i, f, l, d); | |
| 531 | call2b (f, s, d, i, f, l, d, c); | |
| 532 | call2c (s, d, i, f, l, d, c, f); | |
| 533 | call2d (d, i, f, l, d, c, f, s); | |
| 534 | call2e (i, f, l, d, c, f, s, d); | |
| 535 | call2f (f, l, d, c, f, s, d, i); | |
| 536 | call2g (l, d, c, f, s, d, i, f); | |
| 537 | call2h (d, c, f, s, d, i, f, l); | |
| 04c12f60 | 538 | call2i (c, f, c, c, d, c, c, c, f, s, c, d); |
| c906108c | 539 | |
| e43ec454 YQ |
540 | #ifdef TEST_COMPLEX |
| 541 | /* Test calling with _Complex types. */ | |
| 542 | callca (fc, fc, fc); | |
| 543 | callcb (dc, dc, dc); | |
| 544 | callcc (ldc, ldc, ldc); | |
| 545 | callcd (fc, dc, ldc); | |
| 546 | callce (dc, ldc, fc); | |
| 547 | callcf (ldc, fc, dc); | |
| 548 | ||
| 549 | ||
| 550 | callc1a (c, s, i, ui, l, fc, dc, ldc); | |
| 551 | callc1b (ldc, c, s, i, fc, ui, l, dc); | |
| 552 | ||
| 553 | callc2a (c, s, i, ui, l, f, d, fc, dc, ldc); | |
| 554 | callc2b (fc, c, s, i, ui, ldc, l, f, d, dc); | |
| 555 | #endif /* TEST_COMPLEX */ | |
| 556 | ||
| c906108c SS |
557 | /* Test dereferencing pointers to various integral and floating types */ |
| 558 | ||
| 559 | call3a (cp, sp, ip, lp); | |
| 560 | call3b (ucp, usp, uip, ulp); | |
| 561 | call3c (fp, dp); | |
| 562 | ||
| 563 | /* Test dereferencing pointers to structs and unions */ | |
| 564 | ||
| 565 | call4a (stp); | |
| 566 | un.u1 = 1; | |
| 567 | call4b (unp); | |
| 568 | ||
| 569 | /* Test calling with structures and unions. */ | |
| 570 | ||
| 571 | call5a (st); | |
| 572 | un.u1 = 2; | |
| 573 | call5b (un); | |
| 574 | ||
| 575 | /* Test shuffling of args */ | |
| 576 | ||
| 577 | call6a (c, s, i, l, f, d, uc, us, ui, ul); | |
| 578 | call7a (c, i, s, l, f, uc, d, us, ul, ui); | |
| a5cbe675 | 579 | |
| c906108c SS |
580 | /* Test passing structures recursively. */ |
| 581 | ||
| 582 | test_struct_args (); | |
| 583 | ||
| 584 | localvars_after_alloca (c, s, i, l); | |
| 585 | ||
| 586 | call_after_alloca (c, s, i, l); | |
| 587 | ||
| 588 | /* This is for localvars_in_indirect_call. */ | |
| 589 | marker_indirect_call (); | |
| 590 | /* The comment on the following two lines is used by funcargs.exp, | |
| 591 | don't change it. */ | |
| 592 | (*pointer_to_call0a) (c, s, i, l); /* First step into call0a. */ | |
| 593 | (*pointer_to_call0a) (c, s, i, l); /* Second step into call0a. */ | |
| 594 | marker_call_with_trampolines (); | |
| 595 | (*pointer_to_call_with_trampolines) (d); /* Test multiple trampolines. */ | |
| 085dd6e6 | 596 | return 0; |
| c906108c | 597 | } |