1 #include "compat-common.h"
2 
3 #define T(N, TYPE)						\
4 struct S##TYPE##N { TYPE i[N]; };				\
5 								\
6 struct S##TYPE##N g1s##TYPE##N, g2s##TYPE##N;			\
7 struct S##TYPE##N g3s##TYPE##N, g4s##TYPE##N;			\
8 struct S##TYPE##N g5s##TYPE##N, g6s##TYPE##N;			\
9 struct S##TYPE##N g7s##TYPE##N, g8s##TYPE##N;			\
10 struct S##TYPE##N g9s##TYPE##N, g10s##TYPE##N;			\
11 struct S##TYPE##N g11s##TYPE##N, g12s##TYPE##N;			\
12 struct S##TYPE##N g13s##TYPE##N, g14s##TYPE##N;			\
13 struct S##TYPE##N g15s##TYPE##N, g16s##TYPE##N;			\
14 								\
15 extern void init##TYPE (TYPE *p, int i);			\
16 extern void checkg##TYPE##N (void);				\
17 extern void							\
18 test##TYPE##N (struct S##TYPE##N s1, struct S##TYPE##N s2,	\
19 	       struct S##TYPE##N s3, struct S##TYPE##N s4,	\
20 	       struct S##TYPE##N s5, struct S##TYPE##N s6,	\
21 	       struct S##TYPE##N s7, struct S##TYPE##N s8,	\
22 	       struct S##TYPE##N s9, struct S##TYPE##N s10,	\
23 	       struct S##TYPE##N s11, struct S##TYPE##N s12,	\
24 	       struct S##TYPE##N s13, struct S##TYPE##N s14,	\
25 	       struct S##TYPE##N s15, struct S##TYPE##N s16);	\
26 extern void testva##TYPE##N (int n, ...);			\
27 								\
28 								\
29 void								\
30 init##TYPE##N (struct S##TYPE##N *p, int i)			\
31 {								\
32   int j;							\
33   for (j = 0; j < N; j++)					\
34     init##TYPE(&p->i[j], i+j);					\
35 }								\
36 								\
37 void								\
38 check##TYPE##N (struct S##TYPE##N *p, int i)			\
39 {								\
40   int j;							\
41   for (j = 0; j < N; j++)					\
42     check##TYPE(p->i[j], i+j);					\
43 }								\
44 								\
45 void								\
46 test2_##TYPE##N (struct S##TYPE##N s1, struct S##TYPE##N s2,	\
47 		 struct S##TYPE##N s3, struct S##TYPE##N s4,	\
48 		 struct S##TYPE##N s5, struct S##TYPE##N s6,	\
49 		 struct S##TYPE##N s7, struct S##TYPE##N s8)	\
50 {								\
51   test##TYPE##N (s1, g2s##TYPE##N, s2, g4s##TYPE##N,		\
52 		 s3, g6s##TYPE##N, s4, g8s##TYPE##N,		\
53 		 s5, g10s##TYPE##N, s6, g12s##TYPE##N,		\
54 		 s7, g14s##TYPE##N, s8, g16s##TYPE##N);		\
55 }								\
56 								\
57 void								\
58 testit##TYPE##N (void)						\
59 {								\
60   DEBUG_FPUTS (#TYPE "[" #N "]");				\
61   DEBUG_FPUTS (" init: ");					\
62   init##TYPE##N  ( &g1s##TYPE##N,  1*16);			\
63   init##TYPE##N  ( &g2s##TYPE##N,  2*16);			\
64   init##TYPE##N  ( &g3s##TYPE##N,  3*16);			\
65   init##TYPE##N  ( &g4s##TYPE##N,  4*16);			\
66   init##TYPE##N  ( &g5s##TYPE##N,  5*16);			\
67   init##TYPE##N  ( &g6s##TYPE##N,  6*16);			\
68   init##TYPE##N  ( &g7s##TYPE##N,  7*16);			\
69   init##TYPE##N  ( &g8s##TYPE##N,  8*16);			\
70   init##TYPE##N  ( &g9s##TYPE##N,  9*16);			\
71   init##TYPE##N  (&g10s##TYPE##N, 10*16);			\
72   init##TYPE##N  (&g11s##TYPE##N, 11*16);			\
73   init##TYPE##N  (&g12s##TYPE##N, 12*16);			\
74   init##TYPE##N  (&g13s##TYPE##N, 13*16);			\
75   init##TYPE##N  (&g14s##TYPE##N, 14*16);			\
76   init##TYPE##N  (&g15s##TYPE##N, 15*16);			\
77   init##TYPE##N  (&g16s##TYPE##N, 16*16);			\
78   checkg##TYPE##N ();						\
79   DEBUG_NL;							\
80   DEBUG_FPUTS (#TYPE "[" #N "]");				\
81   DEBUG_FPUTS (" test: ");					\
82   test##TYPE##N (g1s##TYPE##N, g2s##TYPE##N,			\
83 		 g3s##TYPE##N, g4s##TYPE##N,			\
84 		 g5s##TYPE##N, g6s##TYPE##N,			\
85 		 g7s##TYPE##N, g8s##TYPE##N,			\
86 		 g9s##TYPE##N, g10s##TYPE##N,			\
87 		 g11s##TYPE##N, g12s##TYPE##N,			\
88 		 g13s##TYPE##N, g14s##TYPE##N,			\
89 		 g15s##TYPE##N, g16s##TYPE##N);			\
90   DEBUG_NL;							\
91   DEBUG_FPUTS (#TYPE "[" #N "]");				\
92   DEBUG_FPUTS (" testva:");					\
93   DEBUG_NL;							\
94   testva##TYPE##N (16,						\
95 		   g1s##TYPE##N, g2s##TYPE##N,			\
96 		   g3s##TYPE##N, g4s##TYPE##N,			\
97 		   g5s##TYPE##N, g6s##TYPE##N,			\
98 		   g7s##TYPE##N, g8s##TYPE##N,			\
99 		   g9s##TYPE##N, g10s##TYPE##N,			\
100 		   g11s##TYPE##N, g12s##TYPE##N,		\
101 		   g13s##TYPE##N, g14s##TYPE##N,		\
102 		   g15s##TYPE##N, g16s##TYPE##N);		\
103   DEBUG_NL;							\
104   DEBUG_FPUTS (#TYPE "[" #N "]");				\
105   DEBUG_FPUTS (" test2: ");					\
106   test2_##TYPE##N (g1s##TYPE##N, g3s##TYPE##N,			\
107 		   g5s##TYPE##N, g7s##TYPE##N,			\
108 		   g9s##TYPE##N, g11s##TYPE##N,			\
109 		   g13s##TYPE##N, g15s##TYPE##N);		\
110   DEBUG_NL;							\
111 }
112 
113 typedef struct { char c; } Sc;
114 typedef struct { short s; } Ss;
115 typedef struct { int i; } Si;
116 typedef struct { short s; char c; } Ssc;
117 typedef struct { int i; short s; } Sis;
118 typedef struct { char c; short s; int i; } Scsi;
119 typedef struct { char c; int i; short s; } Scis;
120 
121 extern void abort (void);
122 
checkSc(Sc x,int i)123 void checkSc (Sc x, int i) { if (x.c != i/16) DEBUG_CHECK }
checkSs(Ss x,int i)124 void checkSs (Ss x, int i) { if (x.s != i) DEBUG_CHECK }
checkSi(Si x,int i)125 void checkSi (Si x, int i) { if (x.i != i) DEBUG_CHECK }
checkSsc(Ssc x,int i)126 void checkSsc (Ssc x, int i)
127 { if (x.s != i || x.c != (i/16)+1) DEBUG_CHECK }
checkSis(Sis x,int i)128 void checkSis (Sis x, int i)
129 { if (x.i != i || x.s != i+1) DEBUG_CHECK }
checkScsi(Scsi x,int i)130 void checkScsi (Scsi x, int i)
131 { if (x.c != i/16 || x.s != i+1 || x.i != i+2) DEBUG_CHECK }
checkScis(Scis x,int i)132 void checkScis (Scis x, int i)
133 { if (x.c != i/16 || x.i != i+1 || x.s != i+2) DEBUG_CHECK }
134 
135 T(0, Scsi)
136 T(1, Scsi)
137 T(2, Scsi)
138 T(3, Scsi)
139 T(4, Scsi)
140 T(5, Scsi)
141 T(6, Scsi)
142 T(7, Scsi)
143 T(8, Scsi)
144 T(9, Scsi)
145 T(10, Scsi)
146 T(11, Scsi)
147 T(12, Scsi)
148 T(13, Scsi)
149 T(14, Scsi)
150 T(15, Scsi)
151 T(0, Scis)
152 T(1, Scis)
153 T(2, Scis)
154 T(3, Scis)
155 T(4, Scis)
156 T(5, Scis)
157 T(6, Scis)
158 T(7, Scis)
159 T(8, Scis)
160 T(9, Scis)
161 T(10, Scis)
162 T(11, Scis)
163 T(12, Scis)
164 T(13, Scis)
165 T(14, Scis)
166 T(15, Scis)
167 
168 #undef T
169 
170 void
struct_by_value_9_x()171 struct_by_value_9_x ()
172 {
173 DEBUG_INIT
174 
175 #define T(N, TYPE) testit##TYPE##N ();
176 
177 T(0, Scsi)
178 T(1, Scsi)
179 T(2, Scsi)
180 T(3, Scsi)
181 T(4, Scsi)
182 T(5, Scsi)
183 T(6, Scsi)
184 T(7, Scsi)
185 T(8, Scsi)
186 T(9, Scsi)
187 T(10, Scsi)
188 T(11, Scsi)
189 T(12, Scsi)
190 T(13, Scsi)
191 T(14, Scsi)
192 T(15, Scsi)
193 T(0, Scis)
194 T(1, Scis)
195 T(2, Scis)
196 T(3, Scis)
197 T(4, Scis)
198 T(5, Scis)
199 T(6, Scis)
200 T(7, Scis)
201 T(8, Scis)
202 T(9, Scis)
203 T(10, Scis)
204 T(11, Scis)
205 T(12, Scis)
206 T(13, Scis)
207 T(14, Scis)
208 T(15, Scis)
209 
210 DEBUG_FINI
211 
212 if (fails != 0)
213   abort ();
214 
215 #undef T
216 }
217