1 #include <stdarg.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 
5 /*
6  * 07/21/08: This test case does the same thing as struct-pass-small, except
7  * that the struct is 9 or 17 bytes long instead of 2 bytes. This is to
8  * ensure that alignment is correctly dealt with in this case as well
9  */
10 struct tiny {
11 	char c;
12 	long dummy;
13 	char d;
14 };
15 
16 /*
17  * Check that small structs are passed correctly (aligned to dword
18  * boundary on both sides) via stdarg
19  */
20 void
21 f(int n, ...);
22 
23 /*
24  * Check that small structs are passed correctly (aligned to dword
25  * boundary on both sides)
26  */
27 void
28 f2(int n, struct tiny x1, struct tiny x2, struct tiny x3, ...);
29 
30 /*
31  * Check that small structs are passed correctly (aligned to dword
32  * boundary on both sides) even with intervening (and alignment-
33  * changing) small types
34  */
35 void
36 f3(int n, char dummy, struct tiny x1, char dummy2, struct tiny x2, short dummy3, long foo, struct tiny x3, ...);
37 
38 /*
39  * Check that small structs are passed correctly (aligned to dword
40  * boundary on both sides) even with intervening (and alignment-
41  * changing) small types
42  */
43 void
44 f4(int n, ...);
45 
46 int
main()47 main ()
48 {
49 	struct tiny x[3];
50 
51 	x[0].c = 10;
52 	x[1].c = 11;
53 	x[2].c = 12;
54 	x[0].d = 20;
55 	x[1].d = 21;
56 	x[2].d = 22;
57 
58 	printf("%d, %d\n", x[0].c, x[0].d);
59 	printf("%d, %d\n", x[1].c, x[1].d);
60 	printf("%d, %d\n", x[2].c, x[2].d);
61 	puts("===");
62 
63 	f(3, x[0], x[1], x[2], (long)123);
64 	f2(3, x[0], x[1], x[2], (long)123);
65 	f3(3,    11,   x[0],   22,    x[1],   33,    77777,  x[2], (long)123);
66 	f4(0, 1/*char*/, x[0], 2L, 3.4, x[1], (char)5, (short)6, 7LL, x[2]);
67 	exit(0);
68 }
69 
70