1 /* Structure layout test generator.
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3 Contributed by Jakub Jelinek <jakub@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
22 /* Compile with gcc -o struct-layout-1_generate{,.c} generate_random{,_r}.c */
24 /* N.B. -- This program cannot use libiberty as that will not work
25 when testing an installed compiler. */
31 /* We use our own pseudo-random number generator, so that it gives the same
32 values on all hosts. */
33 #include "generate-random.h"
35 #if LLONG_MAX != 9223372036854775807LL && __LONG_LONG_MAX__ != 9223372036854775807LL
36 # error Need 64-bit long long
39 typedef unsigned int hashval_t
;
60 unsigned long long int maxval
;
64 struct types base_types
[] = {
65 /* As we don't know whether char will be signed or not, just limit ourselves
66 to unsigned values less than maximum signed char value. */
67 { "char", TYPE_UINT
, 127, 'C' },
68 { "signed char", TYPE_INT
, 127, 'C' },
69 { "unsigned char", TYPE_UINT
, 255, 'C' },
70 { "short int", TYPE_INT
, 32767, 'S' },
71 { "unsigned short int", TYPE_UINT
, 65535, 'S' },
72 { "int", TYPE_INT
, 2147483647, 'I' },
73 { "unsigned int", TYPE_UINT
, 4294967295U, 'I' },
74 { "long int", TYPE_INT
, 9223372036854775807LL, 'L' },
75 { "unsigned long int", TYPE_UINT
, 18446744073709551615ULL, 'L' },
76 { "long long int", TYPE_INT
, 9223372036854775807LL, 'Q' },
77 { "unsigned long long int", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
78 { "bool", TYPE_UINT
, 1, 'B' },
79 { "void *", TYPE_PTR
, 0, 0 },
80 { "char *", TYPE_PTR
, 0, 0 },
81 { "int *", TYPE_PTR
, 0, 0 },
82 { "float", TYPE_FLOAT
, 0, 0 },
83 { "double", TYPE_FLOAT
, 0, 0 },
84 { "long double", TYPE_FLOAT
, 0, 0 },
86 { "Tchar", TYPE_UINT
, 127, 'C' },
87 { "Tschar", TYPE_INT
, 127, 'C' },
88 { "Tuchar", TYPE_UINT
, 255, 'C' },
89 { "Tshort", TYPE_INT
, 32767, 'S' },
90 { "Tushort", TYPE_UINT
, 65535, 'S' },
91 { "Tint", TYPE_INT
, 2147483647, 'I' },
92 { "Tuint", TYPE_UINT
, 4294967295U, 'I' },
93 { "Tlong", TYPE_INT
, 9223372036854775807LL, 'L' },
94 { "Tulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
95 { "Tllong", TYPE_INT
, 9223372036854775807LL, 'Q' },
96 { "Tullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
97 { "Tbool", TYPE_UINT
, 1, 'B' },
98 { "size_t", TYPE_UINT
, 18446744073709551615ULL, 0 },
99 { "Tptr", TYPE_PTR
, 0, 0 },
100 { "Tcptr", TYPE_PTR
, 0, 0 },
101 { "Tiptr", TYPE_PTR
, 0, 0 },
102 { "Tfnptr", TYPE_FNPTR
, 0, 0 },
103 { "Tfloat", TYPE_FLOAT
, 0, 0 },
104 { "Tdouble", TYPE_FLOAT
, 0, 0 },
105 { "Tldouble", TYPE_FLOAT
, 0, 0 },
106 { "enum E0", TYPE_UENUM
, 0, ' ' },
107 { "enum E1", TYPE_UENUM
, 1, ' ' },
108 { "enum E2", TYPE_SENUM
, 3, ' ' },
109 { "enum E3", TYPE_SENUM
, 127, ' ' },
110 { "enum E4", TYPE_UENUM
, 255, ' ' },
111 { "enum E5", TYPE_SENUM
, 32767, ' ' },
112 { "enum E6", TYPE_UENUM
, 65535, ' ' },
113 { "enum E7", TYPE_SENUM
, 2147483647, ' ' },
114 { "enum E8", TYPE_UENUM
, 4294967295U, ' ' },
115 { "enum E9", TYPE_SENUM
, 1099511627775LL, ' ' },
116 { "TE0", TYPE_UENUM
, 0, ' ' },
117 { "TE1", TYPE_UENUM
, 1, ' ' },
118 { "TE2", TYPE_SENUM
, 3, ' ' },
119 { "TE3", TYPE_SENUM
, 127, ' ' },
120 { "TE4", TYPE_UENUM
, 255, ' ' },
121 { "TE5", TYPE_SENUM
, 32767, ' ' },
122 { "TE6", TYPE_UENUM
, 65535, ' ' },
123 { "TE7", TYPE_SENUM
, 2147483647, ' ' },
124 { "TE8", TYPE_UENUM
, 4294967295U, ' ' },
125 { "TE9", TYPE_SENUM
, 1099511627775LL, ' ' },
126 /* vector-defs.h typedefs */
127 { "qi", TYPE_INT
, 127, 0 },
128 { "hi", TYPE_INT
, 32767, 0 },
129 { "si", TYPE_INT
, 2147483647, 0 },
130 { "di", TYPE_INT
, 9223372036854775807LL, 0 },
131 { "sf", TYPE_FLOAT
, 0, 0 },
132 { "df", TYPE_FLOAT
, 0, 0 }
133 #define NTYPES2 (sizeof (base_types) / sizeof (base_types[0]))
135 struct types complex_types
[] = {
136 { "_Complex char", TYPE_CUINT
, 127, 0 },
137 { "_Complex signed char", TYPE_CINT
, 127, 0 },
138 { "_Complex unsigned char", TYPE_CUINT
, 255, 0 },
139 { "_Complex short int", TYPE_CINT
, 32767, 0 },
140 { "_Complex unsigned short int", TYPE_CUINT
, 65535, 0 },
141 { "_Complex int", TYPE_CINT
, 2147483647, 0 },
142 { "_Complex unsigned int", TYPE_CUINT
, 4294967295U, 0 },
143 { "_Complex long int", TYPE_CINT
, 9223372036854775807LL, 0 },
144 { "_Complex unsigned long int", TYPE_CUINT
, 18446744073709551615ULL, 0 },
145 { "_Complex long long int", TYPE_CINT
, 9223372036854775807LL, 0 },
146 { "_Complex unsigned long long int", TYPE_CUINT
, 18446744073709551615ULL, 0 },
147 { "_Complex float", TYPE_CFLOAT
, 0, 0 },
148 { "_Complex double", TYPE_CFLOAT
, 0, 0 },
149 { "_Complex long double", TYPE_CFLOAT
, 0, 0 },
150 { "Tcchar", TYPE_CUINT
, 127, 0 },
151 { "Tcschar", TYPE_CINT
, 127, 0 },
152 { "Tcuchar", TYPE_CUINT
, 255, 0 },
153 { "Tcshort", TYPE_CINT
, 32767, 0 },
154 { "Tcushort", TYPE_CUINT
, 65535, 0 },
155 { "Tcint", TYPE_CINT
, 2147483647, 0 },
156 { "Tcuint", TYPE_CUINT
, 4294967295U, 0 },
157 { "Tclong", TYPE_CINT
, 9223372036854775807LL, 0 },
158 { "Tculong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
159 { "Tcllong", TYPE_CINT
, 9223372036854775807LL, 0 },
160 { "Tcullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
161 { "Tcfloat", TYPE_CFLOAT
, 0, 0 },
162 { "Tcdouble", TYPE_CFLOAT
, 0, 0 },
163 { "Tcldouble", TYPE_CFLOAT
, 0, 0 }
164 #define NCTYPES2 (sizeof (complex_types) / sizeof (complex_types[0]))
166 struct types vector_types
[] = {
167 /* vector-defs.h typedefs */
168 { "v8qi", TYPE_OTHER
, 0, 0 },
169 { "v16qi", TYPE_OTHER
, 0, 0 },
170 { "v2hi", TYPE_OTHER
, 0, 0 },
171 { "v4hi", TYPE_OTHER
, 0, 0 },
172 { "v8hi", TYPE_OTHER
, 0, 0 },
173 { "v2si", TYPE_OTHER
, 0, 0 },
174 { "v4si", TYPE_OTHER
, 0, 0 },
175 { "v1di", TYPE_OTHER
, 0, 0 },
176 { "v2di", TYPE_OTHER
, 0, 0 },
177 { "v2sf", TYPE_OTHER
, 0, 0 },
178 { "v4sf", TYPE_OTHER
, 0, 0 },
179 { "v16sf", TYPE_OTHER
, 0, 0 },
180 { "v2df", TYPE_OTHER
, 0, 0 },
181 { "u8qi", TYPE_OTHER
, 0, 0 },
182 { "u16qi", TYPE_OTHER
, 0, 0 },
183 { "u2hi", TYPE_OTHER
, 0, 0 },
184 { "u4hi", TYPE_OTHER
, 0, 0 },
185 { "u8hi", TYPE_OTHER
, 0, 0 },
186 { "u2si", TYPE_OTHER
, 0, 0 },
187 { "u4si", TYPE_OTHER
, 0, 0 },
188 { "u1di", TYPE_OTHER
, 0, 0 },
189 { "u2di", TYPE_OTHER
, 0, 0 },
190 { "u2sf", TYPE_OTHER
, 0, 0 },
191 { "u4sf", TYPE_OTHER
, 0, 0 },
192 { "u16sf", TYPE_OTHER
, 0, 0 },
193 { "u2df", TYPE_OTHER
, 0, 0 },
194 { "__m64", TYPE_OTHER
, 0, 0 },
195 { "__m128", TYPE_OTHER
, 0, 0 }
196 #define NVTYPES2 (sizeof (vector_types) / sizeof (vector_types[0]))
198 struct types attrib_types
[] = {
199 { "Talchar", TYPE_UINT
, 127, 'C' },
200 { "Talschar", TYPE_INT
, 127, 'C' },
201 { "Taluchar", TYPE_UINT
, 255, 'C' },
202 { "Talshort", TYPE_INT
, 32767, 'S' },
203 { "Talushort", TYPE_UINT
, 65535, 'S' },
204 { "Talint", TYPE_INT
, 2147483647, 'I' },
205 { "Taluint", TYPE_UINT
, 4294967295U, 'I' },
206 { "Tallong", TYPE_INT
, 9223372036854775807LL, 'L' },
207 { "Talulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
208 { "Talllong", TYPE_INT
, 9223372036854775807LL, 'Q' },
209 { "Talullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
210 { "Talbool", TYPE_UINT
, 1, 'B' },
211 { "Talptr", TYPE_PTR
, 0, 0 },
212 { "Talcptr", TYPE_PTR
, 0, 0 },
213 { "Taliptr", TYPE_PTR
, 0, 0 },
214 { "Talfloat", TYPE_FLOAT
, 0, 0 },
215 { "Taldouble", TYPE_FLOAT
, 0, 0 },
216 { "Talldouble", TYPE_FLOAT
, 0, 0 },
217 { "TalE0", TYPE_UENUM
, 0, ' ' },
218 { "TalE1", TYPE_UENUM
, 1, ' ' },
219 { "TalE2", TYPE_SENUM
, 3, ' ' },
220 { "TalE3", TYPE_SENUM
, 127, ' ' },
221 { "TalE4", TYPE_UENUM
, 255, ' ' },
222 { "TalE5", TYPE_SENUM
, 32767, ' ' },
223 { "TalE6", TYPE_UENUM
, 65535, ' ' },
224 { "TalE7", TYPE_SENUM
, 2147483647, ' ' },
225 { "TalE8", TYPE_UENUM
, 4294967295U, ' ' },
226 { "TalE9", TYPE_SENUM
, 1099511627775LL, ' ' },
227 { "Tal1char", TYPE_UINT
, 127, 'C' },
228 { "Tal1schar", TYPE_INT
, 127, 'C' },
229 { "Tal1uchar", TYPE_UINT
, 255, 'C' },
230 { "Tal1short", TYPE_INT
, 32767, 'S' },
231 { "Tal1ushort", TYPE_UINT
, 65535, 'S' },
232 { "Tal1int", TYPE_INT
, 2147483647, 'I' },
233 { "Tal1uint", TYPE_UINT
, 4294967295U, 'I' },
234 { "Tal1long", TYPE_INT
, 9223372036854775807LL, 'L' },
235 { "Tal1ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
236 { "Tal1llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
237 { "Tal1ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
238 { "Tal1bool", TYPE_UINT
, 1, 'B' },
239 { "Tal1ptr", TYPE_PTR
, 0, 0 },
240 { "Tal1cptr", TYPE_PTR
, 0, 0 },
241 { "Tal1iptr", TYPE_PTR
, 0, 0 },
242 { "Tal1float", TYPE_FLOAT
, 0, 0 },
243 { "Tal1double", TYPE_FLOAT
, 0, 0 },
244 { "Tal1ldouble", TYPE_FLOAT
, 0, 0 },
245 { "Tal1E0", TYPE_UENUM
, 0, ' ' },
246 { "Tal1E1", TYPE_UENUM
, 1, ' ' },
247 { "Tal1E2", TYPE_SENUM
, 3, ' ' },
248 { "Tal1E3", TYPE_SENUM
, 127, ' ' },
249 { "Tal1E4", TYPE_UENUM
, 255, ' ' },
250 { "Tal1E5", TYPE_SENUM
, 32767, ' ' },
251 { "Tal1E6", TYPE_UENUM
, 65535, ' ' },
252 { "Tal1E7", TYPE_SENUM
, 2147483647, ' ' },
253 { "Tal1E8", TYPE_UENUM
, 4294967295U, ' ' },
254 { "Tal1E9", TYPE_SENUM
, 1099511627775LL, ' ' },
255 { "Tal2char", TYPE_UINT
, 127, 'C' },
256 { "Tal2schar", TYPE_INT
, 127, 'C' },
257 { "Tal2uchar", TYPE_UINT
, 255, 'C' },
258 { "Tal2short", TYPE_INT
, 32767, 'S' },
259 { "Tal2ushort", TYPE_UINT
, 65535, 'S' },
260 { "Tal2int", TYPE_INT
, 2147483647, 'I' },
261 { "Tal2uint", TYPE_UINT
, 4294967295U, 'I' },
262 { "Tal2long", TYPE_INT
, 9223372036854775807LL, 'L' },
263 { "Tal2ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
264 { "Tal2llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
265 { "Tal2ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
266 { "Tal2bool", TYPE_UINT
, 1, 'B' },
267 { "Tal2ptr", TYPE_PTR
, 0, 0 },
268 { "Tal2cptr", TYPE_PTR
, 0, 0 },
269 { "Tal2iptr", TYPE_PTR
, 0, 0 },
270 { "Tal2float", TYPE_FLOAT
, 0, 0 },
271 { "Tal2double", TYPE_FLOAT
, 0, 0 },
272 { "Tal2ldouble", TYPE_FLOAT
, 0, 0 },
273 { "Tal2E0", TYPE_UENUM
, 0, ' ' },
274 { "Tal2E1", TYPE_UENUM
, 1, ' ' },
275 { "Tal2E2", TYPE_SENUM
, 3, ' ' },
276 { "Tal2E3", TYPE_SENUM
, 127, ' ' },
277 { "Tal2E4", TYPE_UENUM
, 255, ' ' },
278 { "Tal2E5", TYPE_SENUM
, 32767, ' ' },
279 { "Tal2E6", TYPE_UENUM
, 65535, ' ' },
280 { "Tal2E7", TYPE_SENUM
, 2147483647, ' ' },
281 { "Tal2E8", TYPE_UENUM
, 4294967295U, ' ' },
282 { "Tal2E9", TYPE_SENUM
, 1099511627775LL, ' ' },
283 { "Tal4char", TYPE_UINT
, 127, 'C' },
284 { "Tal4schar", TYPE_INT
, 127, 'C' },
285 { "Tal4uchar", TYPE_UINT
, 255, 'C' },
286 { "Tal4short", TYPE_INT
, 32767, 'S' },
287 { "Tal4ushort", TYPE_UINT
, 65535, 'S' },
288 { "Tal4int", TYPE_INT
, 2147483647, 'I' },
289 { "Tal4uint", TYPE_UINT
, 4294967295U, 'I' },
290 { "Tal4long", TYPE_INT
, 9223372036854775807LL, 'L' },
291 { "Tal4ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
292 { "Tal4llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
293 { "Tal4ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
294 { "Tal4bool", TYPE_UINT
, 1, 'B' },
295 { "Tal4ptr", TYPE_PTR
, 0, 0 },
296 { "Tal4cptr", TYPE_PTR
, 0, 0 },
297 { "Tal4iptr", TYPE_PTR
, 0, 0 },
298 { "Tal4float", TYPE_FLOAT
, 0, 0 },
299 { "Tal4double", TYPE_FLOAT
, 0, 0 },
300 { "Tal4ldouble", TYPE_FLOAT
, 0, 0 },
301 { "Tal4E0", TYPE_UENUM
, 0, ' ' },
302 { "Tal4E1", TYPE_UENUM
, 1, ' ' },
303 { "Tal4E2", TYPE_SENUM
, 3, ' ' },
304 { "Tal4E3", TYPE_SENUM
, 127, ' ' },
305 { "Tal4E4", TYPE_UENUM
, 255, ' ' },
306 { "Tal4E5", TYPE_SENUM
, 32767, ' ' },
307 { "Tal4E6", TYPE_UENUM
, 65535, ' ' },
308 { "Tal4E7", TYPE_SENUM
, 2147483647, ' ' },
309 { "Tal4E8", TYPE_UENUM
, 4294967295U, ' ' },
310 { "Tal4E9", TYPE_SENUM
, 1099511627775LL, ' ' },
311 { "Tal8char", TYPE_UINT
, 127, 'C' },
312 { "Tal8schar", TYPE_INT
, 127, 'C' },
313 { "Tal8uchar", TYPE_UINT
, 255, 'C' },
314 { "Tal8short", TYPE_INT
, 32767, 'S' },
315 { "Tal8ushort", TYPE_UINT
, 65535, 'S' },
316 { "Tal8int", TYPE_INT
, 2147483647, 'I' },
317 { "Tal8uint", TYPE_UINT
, 4294967295U, 'I' },
318 { "Tal8long", TYPE_INT
, 9223372036854775807LL, 'L' },
319 { "Tal8ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
320 { "Tal8llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
321 { "Tal8ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
322 { "Tal8bool", TYPE_UINT
, 1, 'B' },
323 { "Tal8ptr", TYPE_PTR
, 0, 0 },
324 { "Tal8cptr", TYPE_PTR
, 0, 0 },
325 { "Tal8iptr", TYPE_PTR
, 0, 0 },
326 { "Tal8float", TYPE_FLOAT
, 0, 0 },
327 { "Tal8double", TYPE_FLOAT
, 0, 0 },
328 { "Tal8ldouble", TYPE_FLOAT
, 0, 0 },
329 { "Tal8E0", TYPE_UENUM
, 0, ' ' },
330 { "Tal8E1", TYPE_UENUM
, 1, ' ' },
331 { "Tal8E2", TYPE_SENUM
, 3, ' ' },
332 { "Tal8E3", TYPE_SENUM
, 127, ' ' },
333 { "Tal8E4", TYPE_UENUM
, 255, ' ' },
334 { "Tal8E5", TYPE_SENUM
, 32767, ' ' },
335 { "Tal8E6", TYPE_UENUM
, 65535, ' ' },
336 { "Tal8E7", TYPE_SENUM
, 2147483647, ' ' },
337 { "Tal8E8", TYPE_UENUM
, 4294967295U, ' ' },
338 { "Tal8E9", TYPE_SENUM
, 1099511627775LL, ' ' },
339 { "Tal16char", TYPE_UINT
, 127, 'C' },
340 { "Tal16schar", TYPE_INT
, 127, 'C' },
341 { "Tal16uchar", TYPE_UINT
, 255, 'C' },
342 { "Tal16short", TYPE_INT
, 32767, 'S' },
343 { "Tal16ushort", TYPE_UINT
, 65535, 'S' },
344 { "Tal16int", TYPE_INT
, 2147483647, 'I' },
345 { "Tal16uint", TYPE_UINT
, 4294967295U, 'I' },
346 { "Tal16long", TYPE_INT
, 9223372036854775807LL, 'L' },
347 { "Tal16ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
348 { "Tal16llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
349 { "Tal16ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
350 { "Tal16bool", TYPE_UINT
, 1, 'B' },
351 { "Tal16ptr", TYPE_PTR
, 0, 0 },
352 { "Tal16cptr", TYPE_PTR
, 0, 0 },
353 { "Tal16iptr", TYPE_PTR
, 0, 0 },
354 { "Tal16float", TYPE_FLOAT
, 0, 0 },
355 { "Tal16double", TYPE_FLOAT
, 0, 0 },
356 { "Tal16ldouble", TYPE_FLOAT
, 0, 0 },
357 { "Tal16E0", TYPE_UENUM
, 0, ' ' },
358 { "Tal16E1", TYPE_UENUM
, 1, ' ' },
359 { "Tal16E2", TYPE_SENUM
, 3, ' ' },
360 { "Tal16E3", TYPE_SENUM
, 127, ' ' },
361 { "Tal16E4", TYPE_UENUM
, 255, ' ' },
362 { "Tal16E5", TYPE_SENUM
, 32767, ' ' },
363 { "Tal16E6", TYPE_UENUM
, 65535, ' ' },
364 { "Tal16E7", TYPE_SENUM
, 2147483647, ' ' },
365 { "Tal16E8", TYPE_UENUM
, 4294967295U, ' ' },
366 { "Tal16E9", TYPE_SENUM
, 1099511627775LL, ' ' }
367 #define NATYPES2 (sizeof (attrib_types) / sizeof (attrib_types[0]))
369 struct types complex_attrib_types
[] = {
370 { "Talcchar", TYPE_CUINT
, 127, 0 },
371 { "Talcschar", TYPE_CINT
, 127, 0 },
372 { "Talcuchar", TYPE_CUINT
, 255, 0 },
373 { "Talcshort", TYPE_CINT
, 32767, 0 },
374 { "Talcushort", TYPE_CUINT
, 65535, 0 },
375 { "Talcint", TYPE_CINT
, 2147483647, 0 },
376 { "Talcuint", TYPE_CUINT
, 4294967295U, 0 },
377 { "Talclong", TYPE_CINT
, 9223372036854775807LL, 0 },
378 { "Talculong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
379 { "Talcllong", TYPE_CINT
, 9223372036854775807LL, 0 },
380 { "Talcullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
381 { "Talcfloat", TYPE_CFLOAT
, 0, 0 },
382 { "Talcdouble", TYPE_CFLOAT
, 0, 0 },
383 { "Talcldouble", TYPE_CFLOAT
, 0, 0 },
384 { "Tal1cchar", TYPE_CUINT
, 127, 0 },
385 { "Tal1cschar", TYPE_CINT
, 127, 0 },
386 { "Tal1cuchar", TYPE_CUINT
, 255, 0 },
387 { "Tal1cshort", TYPE_CINT
, 32767, 0 },
388 { "Tal1cushort", TYPE_CUINT
, 65535, 0 },
389 { "Tal1cint", TYPE_CINT
, 2147483647, 0 },
390 { "Tal1cuint", TYPE_CUINT
, 4294967295U, 0 },
391 { "Tal1clong", TYPE_CINT
, 9223372036854775807LL, 0 },
392 { "Tal1culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
393 { "Tal1cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
394 { "Tal1cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
395 { "Tal1cfloat", TYPE_CFLOAT
, 0, 0 },
396 { "Tal1cdouble", TYPE_CFLOAT
, 0, 0 },
397 { "Tal1cldouble", TYPE_CFLOAT
, 0, 0 },
398 { "Tal2cchar", TYPE_CUINT
, 127, 0 },
399 { "Tal2cschar", TYPE_CINT
, 127, 0 },
400 { "Tal2cuchar", TYPE_CUINT
, 255, 0 },
401 { "Tal2cshort", TYPE_CINT
, 32767, 0 },
402 { "Tal2cushort", TYPE_CUINT
, 65535, 0 },
403 { "Tal2cint", TYPE_CINT
, 2147483647, 0 },
404 { "Tal2cuint", TYPE_CUINT
, 4294967295U, 0 },
405 { "Tal2clong", TYPE_CINT
, 9223372036854775807LL, 0 },
406 { "Tal2culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
407 { "Tal2cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
408 { "Tal2cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
409 { "Tal2cfloat", TYPE_CFLOAT
, 0, 0 },
410 { "Tal2cdouble", TYPE_CFLOAT
, 0, 0 },
411 { "Tal2cldouble", TYPE_CFLOAT
, 0, 0 },
412 { "Tal4cchar", TYPE_CUINT
, 127, 0 },
413 { "Tal4cschar", TYPE_CINT
, 127, 0 },
414 { "Tal4cuchar", TYPE_CUINT
, 255, 0 },
415 { "Tal4cshort", TYPE_CINT
, 32767, 0 },
416 { "Tal4cushort", TYPE_CUINT
, 65535, 0 },
417 { "Tal4cint", TYPE_CINT
, 2147483647, 0 },
418 { "Tal4cuint", TYPE_CUINT
, 4294967295U, 0 },
419 { "Tal4clong", TYPE_CINT
, 9223372036854775807LL, 0 },
420 { "Tal4culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
421 { "Tal4cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
422 { "Tal4cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
423 { "Tal4cfloat", TYPE_CFLOAT
, 0, 0 },
424 { "Tal4cdouble", TYPE_CFLOAT
, 0, 0 },
425 { "Tal4cldouble", TYPE_CFLOAT
, 0, 0 },
426 { "Tal8cchar", TYPE_CUINT
, 127, 0 },
427 { "Tal8cschar", TYPE_CINT
, 127, 0 },
428 { "Tal8cuchar", TYPE_CUINT
, 255, 0 },
429 { "Tal8cshort", TYPE_CINT
, 32767, 0 },
430 { "Tal8cushort", TYPE_CUINT
, 65535, 0 },
431 { "Tal8cint", TYPE_CINT
, 2147483647, 0 },
432 { "Tal8cuint", TYPE_CUINT
, 4294967295U, 0 },
433 { "Tal8clong", TYPE_CINT
, 9223372036854775807LL, 0 },
434 { "Tal8culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
435 { "Tal8cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
436 { "Tal8cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
437 { "Tal8cfloat", TYPE_CFLOAT
, 0, 0 },
438 { "Tal8cdouble", TYPE_CFLOAT
, 0, 0 },
439 { "Tal8cldouble", TYPE_CFLOAT
, 0, 0 },
440 { "Tal16cchar", TYPE_CUINT
, 127, 0 },
441 { "Tal16cschar", TYPE_CINT
, 127, 0 },
442 { "Tal16cuchar", TYPE_CUINT
, 255, 0 },
443 { "Tal16cshort", TYPE_CINT
, 32767, 0 },
444 { "Tal16cushort", TYPE_CUINT
, 65535, 0 },
445 { "Tal16cint", TYPE_CINT
, 2147483647, 0 },
446 { "Tal16cuint", TYPE_CUINT
, 4294967295U, 0 },
447 { "Tal16clong", TYPE_CINT
, 9223372036854775807LL, 0 },
448 { "Tal16culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
449 { "Tal16cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
450 { "Tal16cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
451 { "Tal16cfloat", TYPE_CFLOAT
, 0, 0 },
452 { "Tal16cdouble", TYPE_CFLOAT
, 0, 0 },
453 { "Tal16cldouble", TYPE_CFLOAT
, 0, 0 }
454 #define NCATYPES2 (sizeof (complex_attrib_types) / sizeof (complex_attrib_types[0]))
456 struct types attrib_array_types
[] = {
457 { "Talx1char", TYPE_UINT
, 127, 'C' },
458 { "Talx1schar", TYPE_INT
, 127, 'C' },
459 { "Talx1uchar", TYPE_UINT
, 255, 'C' },
460 { "Talx1short", TYPE_INT
, 32767, 'S' },
461 { "Talx1ushort", TYPE_UINT
, 65535, 'S' },
462 { "Talx1int", TYPE_INT
, 2147483647, 'I' },
463 { "Talx1uint", TYPE_UINT
, 4294967295U, 'I' },
464 { "Talx1long", TYPE_INT
, 9223372036854775807LL, 'L' },
465 { "Talx1ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
466 { "Talx1llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
467 { "Talx1ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
468 { "Talx1bool", TYPE_UINT
, 1, 'B' },
469 { "Talx1ptr", TYPE_PTR
, 0, 0 },
470 { "Talx1cptr", TYPE_PTR
, 0, 0 },
471 { "Talx1iptr", TYPE_PTR
, 0, 0 },
472 { "Talx1float", TYPE_FLOAT
, 0, 0 },
473 { "Talx1double", TYPE_FLOAT
, 0, 0 },
474 { "Talx1ldouble", TYPE_FLOAT
, 0, 0 },
475 { "Talx1E0", TYPE_UENUM
, 0, ' ' },
476 { "Talx1E1", TYPE_UENUM
, 1, ' ' },
477 { "Talx1E2", TYPE_SENUM
, 3, ' ' },
478 { "Talx1E3", TYPE_SENUM
, 127, ' ' },
479 { "Talx1E4", TYPE_UENUM
, 255, ' ' },
480 { "Talx1E5", TYPE_SENUM
, 32767, ' ' },
481 { "Talx1E6", TYPE_UENUM
, 65535, ' ' },
482 { "Talx1E7", TYPE_SENUM
, 2147483647, ' ' },
483 { "Talx1E8", TYPE_UENUM
, 4294967295U, ' ' },
484 { "Talx1E9", TYPE_SENUM
, 1099511627775LL, ' ' },
485 { "Talx2short", TYPE_INT
, 32767, 'S' },
486 { "Talx2ushort", TYPE_UINT
, 65535, 'S' },
487 { "Talx2int", TYPE_INT
, 2147483647, 'I' },
488 { "Talx2uint", TYPE_UINT
, 4294967295U, 'I' },
489 { "Talx2long", TYPE_INT
, 9223372036854775807LL, 'L' },
490 { "Talx2ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
491 { "Talx2llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
492 { "Talx2ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
493 { "Talx2ptr", TYPE_PTR
, 0, 0 },
494 { "Talx2cptr", TYPE_PTR
, 0, 0 },
495 { "Talx2iptr", TYPE_PTR
, 0, 0 },
496 { "Talx2float", TYPE_FLOAT
, 0, 0 },
497 { "Talx2double", TYPE_FLOAT
, 0, 0 },
498 { "Talx2ldouble", TYPE_FLOAT
, 0, 0 },
499 { "Talx2E0", TYPE_UENUM
, 0, ' ' },
500 { "Talx2E1", TYPE_UENUM
, 1, ' ' },
501 { "Talx2E2", TYPE_SENUM
, 3, ' ' },
502 { "Talx2E3", TYPE_SENUM
, 127, ' ' },
503 { "Talx2E4", TYPE_UENUM
, 255, ' ' },
504 { "Talx2E5", TYPE_SENUM
, 32767, ' ' },
505 { "Talx2E6", TYPE_UENUM
, 65535, ' ' },
506 { "Talx2E7", TYPE_SENUM
, 2147483647, ' ' },
507 { "Talx2E8", TYPE_UENUM
, 4294967295U, ' ' },
508 { "Talx2E9", TYPE_SENUM
, 1099511627775LL, ' ' },
509 { "Talx4int", TYPE_INT
, 2147483647, 'I' },
510 { "Talx4uint", TYPE_UINT
, 4294967295U, 'I' },
511 { "Talx4long", TYPE_INT
, 9223372036854775807LL, 'L' },
512 { "Talx4ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
513 { "Talx4llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
514 { "Talx4ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
515 { "Talx4ptr", TYPE_PTR
, 0, 0 },
516 { "Talx4cptr", TYPE_PTR
, 0, 0 },
517 { "Talx4iptr", TYPE_PTR
, 0, 0 },
518 { "Talx4float", TYPE_FLOAT
, 0, 0 },
519 { "Talx4double", TYPE_FLOAT
, 0, 0 },
520 { "Talx4ldouble", TYPE_FLOAT
, 0, 0 },
521 { "Talx4E0", TYPE_UENUM
, 0, ' ' },
522 { "Talx4E1", TYPE_UENUM
, 1, ' ' },
523 { "Talx4E2", TYPE_SENUM
, 3, ' ' },
524 { "Talx4E3", TYPE_SENUM
, 127, ' ' },
525 { "Talx4E4", TYPE_UENUM
, 255, ' ' },
526 { "Talx4E5", TYPE_SENUM
, 32767, ' ' },
527 { "Talx4E6", TYPE_UENUM
, 65535, ' ' },
528 { "Talx4E7", TYPE_SENUM
, 2147483647, ' ' },
529 { "Talx4E8", TYPE_UENUM
, 4294967295U, ' ' },
530 { "Talx4E9", TYPE_SENUM
, 1099511627775LL, ' ' },
531 { "Taly8long", TYPE_INT
, 9223372036854775807LL, 'L' },
532 { "Taly8ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
533 { "Talx8llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
534 { "Talx8ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
535 { "Taly8ptr", TYPE_PTR
, 0, 0 },
536 { "Taly8cptr", TYPE_PTR
, 0, 0 },
537 { "Taly8iptr", TYPE_PTR
, 0, 0 },
538 { "Talx8double", TYPE_FLOAT
, 0, 0 },
539 { "Talx8ldouble", TYPE_FLOAT
, 0, 0 }
540 #define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0]))
542 struct types complex_attrib_array_types
[] = {
543 { "Talx1cchar", TYPE_CUINT
, 127, 0 },
544 { "Talx1cschar", TYPE_CINT
, 127, 0 },
545 { "Talx1cuchar", TYPE_CUINT
, 255, 0 },
546 { "Talx1cshort", TYPE_CINT
, 32767, 0 },
547 { "Talx1cushort", TYPE_CUINT
, 65535, 0 },
548 { "Talx1cint", TYPE_CINT
, 2147483647, 0 },
549 { "Talx1cuint", TYPE_CUINT
, 4294967295U, 0 },
550 { "Talx1clong", TYPE_CINT
, 9223372036854775807LL, 0 },
551 { "Talx1culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
552 { "Talx1cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
553 { "Talx1cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
554 { "Talx1cfloat", TYPE_CFLOAT
, 0, 0 },
555 { "Talx1cdouble", TYPE_CFLOAT
, 0, 0 },
556 { "Talx1cldouble", TYPE_CFLOAT
, 0, 0 },
557 { "Talx2cchar", TYPE_CUINT
, 127, 0 },
558 { "Talx2cschar", TYPE_CINT
, 127, 0 },
559 { "Talx2cuchar", TYPE_CUINT
, 255, 0 },
560 { "Talx2cshort", TYPE_CINT
, 32767, 0 },
561 { "Talx2cushort", TYPE_CUINT
, 65535, 0 },
562 { "Talx2cint", TYPE_CINT
, 2147483647, 0 },
563 { "Talx2cuint", TYPE_CUINT
, 4294967295U, 0 },
564 { "Talx2clong", TYPE_CINT
, 9223372036854775807LL, 0 },
565 { "Talx2culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
566 { "Talx2cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
567 { "Talx2cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
568 { "Talx2cfloat", TYPE_CFLOAT
, 0, 0 },
569 { "Talx2cdouble", TYPE_CFLOAT
, 0, 0 },
570 { "Talx2cldouble", TYPE_CFLOAT
, 0, 0 },
571 { "Talx4cshort", TYPE_CINT
, 32767, 0 },
572 { "Talx4cushort", TYPE_CUINT
, 65535, 0 },
573 { "Talx4cint", TYPE_CINT
, 2147483647, 0 },
574 { "Talx4cuint", TYPE_CUINT
, 4294967295U, 0 },
575 { "Talx4clong", TYPE_CINT
, 9223372036854775807LL, 0 },
576 { "Talx4culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
577 { "Talx4cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
578 { "Talx4cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
579 { "Talx4cfloat", TYPE_CFLOAT
, 0, 0 },
580 { "Talx4cdouble", TYPE_CFLOAT
, 0, 0 },
581 { "Talx4cldouble", TYPE_CFLOAT
, 0, 0 },
582 { "Talx8cint", TYPE_CINT
, 2147483647, 0 },
583 { "Talx8cuint", TYPE_CUINT
, 4294967295U, 0 },
584 { "Talx8clong", TYPE_CINT
, 9223372036854775807LL, 0 },
585 { "Talx8culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
586 { "Talx8cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
587 { "Talx8cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
588 { "Talx8cfloat", TYPE_CFLOAT
, 0, 0 },
589 { "Talx8cdouble", TYPE_CFLOAT
, 0, 0 },
590 { "Talx8cldouble", TYPE_CFLOAT
, 0, 0 },
591 { "Taly16clong", TYPE_CINT
, 9223372036854775807LL, 0 },
592 { "Taly16culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
593 { "Talx16cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
594 { "Talx16cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
595 { "Talx16cdouble", TYPE_CFLOAT
, 0, 0 },
596 { "Talx16cldouble", TYPE_CFLOAT
, 0, 0 }
597 #define NCAATYPES2 (sizeof (complex_attrib_array_types) / sizeof (complex_attrib_array_types[0]))
600 struct types bitfld_types
[NTYPES2
];
602 struct types aligned_bitfld_types
[NATYPES2
];
603 int n_aligned_bitfld_types
;
605 const char *attributes
[] = {
626 #define NATTRIBS2 (sizeof (attributes) / sizeof (attributes[0]))
643 enum ETYPE etype
: 8;
648 unsigned char arr_len
;
651 /* Used to chain together entries in the hash table. */
655 /* A prime number giving the number of slots in the hash table. */
656 #define HASH_SIZE 32749
657 static struct entry
*hash_table
[HASH_SIZE
];
659 static int idx
, limidx
, output_one
, short_enums
;
660 static const char *destdir
;
661 static const char *srcdir
;
665 switchfiles (int fields
)
668 static char *destbuf
, *destptr
;
679 size_t len
= strlen (destdir
);
680 destbuf
= malloc (len
+ 20);
683 memcpy (destbuf
, destdir
, len
);
684 if (!len
|| destbuf
[len
- 1] != '/')
685 destbuf
[len
++] = '/';
686 destptr
= destbuf
+ len
;
688 sprintf (destptr
, "t%03d_main.c", filecnt
);
689 outfile
= fopen (destbuf
, "w");
693 fputs ("failed to create test files\n", stderr
);
697 /* { dg-options \"-I%s\" } */\n\
698 /* { dg-options \"-I%s -fno-common\" { target hppa*-*-hpux* } } */\n\
699 /* { dg-options \"-I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
700 #include \"struct-layout-1.h\"\n\
702 #define TX(n, type, attrs, fields, ops) extern void test##n (void);\n\
703 #include \"t%03d_test.h\"\n\
708 #define TX(n, type, attrs, fields, ops) test##n ();\n\
709 #include \"t%03d_test.h\"\n\
717 }\n", srcdir
, srcdir
, srcdir
, filecnt
, filecnt
);
719 sprintf (destptr
, "t%03d_x.c", filecnt
);
720 outfile
= fopen (destbuf
, "w");
724 /* { dg-options \"-w -I%s\" } */\n\
725 /* { dg-options \"-w -I%s -fno-common\" { target hppa*-*-hpux* } } */\n\
726 /* { dg-options \"-w -I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
727 #include \"struct-layout-1_x1.h\"\n\
728 #include \"t%03d_test.h\"\n\
729 #include \"struct-layout-1_x2.h\"\n\
730 #include \"t%03d_test.h\"\n", srcdir
, srcdir
, srcdir
, filecnt
, filecnt
);
732 sprintf (destptr
, "t%03d_y.c", filecnt
);
733 outfile
= fopen (destbuf
, "w");
737 /* { dg-options \"-w -I%s\" } */\n\
738 /* { dg-options \"-w -I%s -fno-common\" { target hppa*-*-hpux* } } */\n\
739 /* { dg-options \"-w -I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
740 #include \"struct-layout-1_y1.h\"\n\
741 #include \"t%03d_test.h\"\n\
742 #include \"struct-layout-1_y2.h\"\n\
743 #include \"t%03d_test.h\"\n", srcdir
, srcdir
, srcdir
, filecnt
, filecnt
);
745 sprintf (destptr
, "t%03d_test.h", filecnt
);
746 outfile
= fopen (destbuf
, "w");
751 else if (fields
<= 4)
753 else if (fields
<= 6)
759 unsigned long long int
762 unsigned long long int ret
;
763 ret
= generate_random () & 0xffffff;
764 ret
|= (generate_random () & 0xffffffLL
) << 24;
765 ret
|= ((unsigned long long int) generate_random ()) << 48;
770 subfield (struct entry
*e
, char *letter
)
779 case ETYPE_STRUCT_ARRAY
:
780 case ETYPE_UNION_ARRAY
:
781 type
= e
[0].attrib
? 1 + (generate_random () & 3) : 0;
782 if (e
[0].etype
== ETYPE_STRUCT
|| e
[0].etype
== ETYPE_STRUCT_ARRAY
)
786 if (e
[0].etype
== ETYPE_STRUCT_ARRAY
|| e
[0].etype
== ETYPE_UNION_ARRAY
)
788 if (e
[0].arr_len
== 255)
789 snprintf (buf
, 20, "%c[]", *letter
);
791 snprintf (buf
, 20, "%c[%d]", *letter
, e
[0].arr_len
);
792 /* If this is an array type, do not put aligned attributes on
793 elements. Aligning elements to a value greater than their
794 size will result in a compiler error. */
796 && ((strncmp (e
[0].attrib
, "atal", 4) == 0)
797 || strncmp (e
[0].attrib
, "atpaal", 6) == 0))
811 fprintf (outfile
, "%s{", p
);
814 fprintf (outfile
, "%s %s{", e
[0].attrib
, p
);
817 fprintf (outfile
, "%s %s{", p
, e
[0].attrib
);
821 for (i
= 1; i
<= e
[0].len
; )
822 i
+= subfield (e
+ i
, letter
);
829 fprintf (outfile
, "}%s;", buf
);
832 fprintf (outfile
, "}%s %s;", e
[0].attrib
, buf
);
835 fprintf (outfile
, "}%s %s;", buf
, e
[0].attrib
);
841 if (e
[0].etype
== ETYPE_ARRAY
)
843 if (e
[0].arr_len
== 255)
844 snprintf (buf
, 20, "%c[]", *letter
);
846 snprintf (buf
, 20, "%c[%d]", *letter
, e
[0].arr_len
);
856 /* If this is an array type, do not put aligned attributes on
857 elements. Aligning elements to a value greater than their
858 size will result in a compiler error. */
859 if (e
[0].etype
== ETYPE_ARRAY
860 && ((strncmp (e
[0].attrib
, "atal", 4) == 0)
861 || strncmp (e
[0].attrib
, "atpaal", 6) == 0))
864 type
= generate_random () % 3;
868 fprintf (outfile
, "%s %s %s;", e
[0].attrib
, e
[0].type
->name
,
872 fprintf (outfile
, "%s %s %s;", e
[0].type
->name
, e
[0].attrib
,
876 fprintf (outfile
, "%s %s %s;", e
[0].type
->name
, buf
,
882 fprintf (outfile
, "%s %s;", e
[0].type
->name
, buf
);
888 switch (generate_random () % 3)
891 fprintf (outfile
, "%s %s:0;", e
[0].attrib
, e
[0].type
->name
);
894 fprintf (outfile
, "%s %s:0;", e
[0].type
->name
, e
[0].attrib
);
897 fprintf (outfile
, "%s:0 %s;", e
[0].type
->name
, e
[0].attrib
);
901 fprintf (outfile
, "%s:0;", e
[0].type
->name
);
905 switch (e
[0].type
->bitfld
)
912 snprintf (buf
, 20, "B%cN(%d)", e
[0].type
->bitfld
, e
[0].len
);
916 snprintf (buf
, 20, "%d", e
[0].len
);
922 switch (generate_random () % 3)
925 fprintf (outfile
, "%s %s %c:%s;", e
[0].attrib
, e
[0].type
->name
,
929 fprintf (outfile
, "%s %s %c:%s;", e
[0].type
->name
, e
[0].attrib
,
933 fprintf (outfile
, "%s %c:%s %s;", e
[0].type
->name
, *letter
,
938 fprintf (outfile
, "%s %c:%s;", e
[0].type
->name
, *letter
, buf
);
949 output_FNB (char mode
, struct entry
*e
)
951 unsigned long long int l1
, l2
, m
;
955 if (e
->type
->type
== TYPE_OTHER
)
959 fprintf (outfile
, "N(%d,%s)", idx
, namebuf
);
962 fprintf (outfile
, "%c(%d,%s,", mode
, idx
, namebuf
);
965 switch (e
->type
->type
)
968 signs
= generate_random () & 3;
971 m
&= e
->len
> 1 ? (1ULL << (e
->len
- 1)) - 1 : 1;
974 fprintf (outfile
, "%s%llu%s,%s%llu%s",
975 (signs
& 1) ? "-" : "", l1
, l1
> 2147483647 ? "LL" : "",
976 (signs
& 2) ? "-" : "", l2
, l2
> 2147483647 ? "LL" : "");
981 m
&= (1ULL << e
->len
) - 1;
984 fprintf (outfile
, "%lluU%s,%lluU%s", l1
, l1
> 4294967295U ? "LL" : "",
985 l2
, l2
> 4294967295U ? "LL" : "");
990 signs
= generate_random () & 3;
991 fprintf (outfile
, "%s%f,%s%f", (signs
& 1) ? "-" : "",
992 ((double) l1
) / 64, (signs
& 2) ? "-" : "", ((double) l2
) / 64);
995 signs
= generate_random () & 3;
996 l1
&= e
->type
->maxval
;
997 l2
&= e
->type
->maxval
;
998 fprintf (outfile
, "CINT(%s%llu%s,%s%llu%s),",
999 (signs
& 1) ? "-" : "", l1
, l1
> 2147483647 ? "LL" : "",
1000 (signs
& 2) ? "-" : "", l2
, l2
> 2147483647 ? "LL" : "");
1001 signs
= generate_random () & 3;
1004 l1
&= e
->type
->maxval
;
1005 l2
&= e
->type
->maxval
;
1006 fprintf (outfile
, "CINT(%s%llu%s,%s%llu%s)",
1007 (signs
& 1) ? "-" : "", l1
, l1
> 2147483647 ? "LL" : "",
1008 (signs
& 2) ? "-" : "", l2
, l2
> 2147483647 ? "LL" : "");
1011 l1
&= e
->type
->maxval
;
1012 l2
&= e
->type
->maxval
;
1013 fprintf (outfile
, "CINT(%lluU%s,%lluU%s),",
1014 l1
, l1
> 4294967295U ? "LL" : "",
1015 l2
, l2
> 4294967295U ? "LL" : "");
1018 l1
&= e
->type
->maxval
;
1019 l2
&= e
->type
->maxval
;
1020 fprintf (outfile
, "CINT(%lluU%s,%lluU%s)",
1021 l1
, l1
> 4294967295U ? "LL" : "",
1022 l2
, l2
> 4294967295U ? "LL" : "");
1027 signs
= generate_random () & 3;
1028 fprintf (outfile
, "CDBL(%s%f,%s%f),",
1029 (signs
& 1) ? "-" : "", ((double) l1
) / 64,
1030 (signs
& 2) ? "-" : "", ((double) l2
) / 64);
1035 signs
= generate_random () & 3;
1036 fprintf (outfile
, "CDBL(%s%f,%s%f)",
1037 (signs
& 1) ? "-" : "", ((double) l1
) / 64,
1038 (signs
& 2) ? "-" : "", ((double) l2
) / 64);
1041 if (e
->type
->maxval
== 0)
1042 fputs ("e0_0,e0_0", outfile
);
1043 else if (e
->type
->maxval
== 1)
1044 fprintf (outfile
, "e1_%lld,e1_%lld", l1
& 1, l2
& 1);
1047 p
= strchr (e
->type
->name
, '\0');
1048 while (--p
>= e
->type
->name
&& *p
>= '0' && *p
<= '9');
1053 l1
+= e
->type
->maxval
- 6;
1055 l2
+= e
->type
->maxval
- 6;
1056 fprintf (outfile
, "e%s_%lld,e%s_%lld", p
, l1
, p
, l2
);
1060 p
= strchr (e
->type
->name
, '\0');
1061 while (--p
>= e
->type
->name
&& *p
>= '0' && *p
<= '9');
1065 fprintf (outfile
, "e%s_%s%lld,e%s_%s%lld",
1066 p
, l1
< 3 ? "m" : "",
1067 l1
== 3 ? 0LL : e
->type
->maxval
- (l1
& 3),
1068 p
, l2
< 3 ? "m" : "",
1069 l2
== 3 ? 0LL : e
->type
->maxval
- (l2
& 3));
1074 fprintf (outfile
, "(%s)&intarray[%lld],(%s)&intarray[%lld]",
1075 e
->type
->name
, l1
, e
->type
->name
, l2
);
1080 fprintf (outfile
, "fn%lld,fn%lld", l1
, l2
);
1085 fputs (")", outfile
);
1089 subvalues (struct entry
*e
, char *p
, char *letter
)
1093 if (p
>= namebuf
+ sizeof (namebuf
) - 32)
1100 case ETYPE_STRUCT_ARRAY
:
1101 case ETYPE_UNION_ARRAY
:
1102 if (e
[0].arr_len
== 0 || e
[0].arr_len
== 255)
1104 *letter
+= 1 + e
[0].len
;
1105 return 1 + e
[0].len
;
1107 i
= generate_random () % e
[0].arr_len
;
1108 snprintf (p
, sizeof (namebuf
) - (p
- namebuf
) - 1,
1109 "%c[%d]", *letter
, i
);
1110 q
= strchr (p
, '\0');
1116 for (i
= 1; i
<= e
[0].len
; )
1118 i
+= subvalues (e
+ i
, q
, letter
);
1119 if (e
[0].etype
== ETYPE_UNION
|| e
[0].etype
== ETYPE_UNION_ARRAY
)
1121 *letter
+= e
[0].len
- i
+ 1;
1125 return 1 + e
[0].len
;
1128 output_FNB ('F', e
);
1131 if (e
[0].arr_len
== 0 || e
[0].arr_len
== 255)
1136 i
= generate_random () % e
[0].arr_len
;
1137 snprintf (p
, sizeof (namebuf
) - (p
- namebuf
),
1138 "%c[%d]", *letter
, i
);
1139 output_FNB ('F', e
);
1140 if ((generate_random () & 7) == 0)
1142 j
= generate_random () % e
[0].arr_len
;
1145 snprintf (p
, sizeof (namebuf
) - (p
- namebuf
),
1146 "%c[%d]", *letter
, j
);
1147 output_FNB ('F', e
);
1155 output_FNB ('B', e
);
1161 --------------------------------------------------------------------
1162 lookup2.c, by Bob Jenkins, December 1996, Public Domain.
1163 hash(), hash2(), hash3, and mix() are externally useful functions.
1164 Routines to test the hash are included if SELF_TEST is defined.
1165 You can use this free for any purpose. It has no warranty.
1166 --------------------------------------------------------------------
1170 --------------------------------------------------------------------
1171 mix -- mix 3 32-bit values reversibly.
1172 For every delta with one or two bit set, and the deltas of all three
1173 high bits or all three low bits, whether the original value of a,b,c
1174 is almost all zero or is uniformly distributed,
1175 * If mix() is run forward or backward, at least 32 bits in a,b,c
1176 have at least 1/4 probability of changing.
1177 * If mix() is run forward, every bit of c will change between 1/3 and
1178 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.)
1179 mix() was built out of 36 single-cycle latency instructions in a
1180 structure that could supported 2x parallelism, like so:
1182 a -= c; x = (c>>13);
1186 c -= b; x = (b>>13);
1188 Unfortunately, superscalar Pentiums and Sparcs can't take advantage
1189 of that parallelism. They've also turned some of those single-cycle
1190 latency instructions into multi-cycle latency instructions. Still,
1191 this is the fastest good hash I could find. There were about 2^^68
1192 to choose from. I only looked at a billion or so.
1193 --------------------------------------------------------------------
1195 /* same, but slower, works on systems that might have 8 byte hashval_t's */
1196 #define mix(a,b,c) \
1198 a -= b; a -= c; a ^= (c>>13); \
1199 b -= c; b -= a; b ^= (a<< 8); \
1200 c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \
1201 a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \
1202 b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \
1203 c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \
1204 a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \
1205 b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \
1206 c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \
1210 --------------------------------------------------------------------
1211 hash() -- hash a variable-length key into a 32-bit value
1212 k : the key (the unaligned variable-length array of bytes)
1213 len : the length of the key, counting by bytes
1214 level : can be any 4-byte value
1215 Returns a 32-bit value. Every bit of the key affects every bit of
1216 the return value. Every 1-bit and 2-bit delta achieves avalanche.
1217 About 36+6len instructions.
1219 The best hash table sizes are powers of 2. There is no need to do
1220 mod a prime (mod is sooo slow!). If you need less than 32 bits,
1221 use a bitmask. For example, if you need only 10 bits, do
1222 h = (h & hashmask(10));
1223 In which case, the hash table should have hashsize(10) elements.
1225 If you are hashing n strings (ub1 **)k, do it like this:
1226 for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
1228 By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this
1229 code any way you wish, private, educational, or commercial. It's free.
1231 See http://burtleburtle.net/bob/hash/evahash.html
1232 Use for hash table lookup, or anything where one collision in 2^32 is
1233 acceptable. Do NOT use for cryptographic purposes.
1234 --------------------------------------------------------------------
1238 iterative_hash (const void *k_in
/* the key */,
1239 register size_t length
/* the length of the key */,
1240 register hashval_t initval
/* the previous hash, or
1241 an arbitrary value */)
1243 register const unsigned char *k
= (const unsigned char *)k_in
;
1244 register hashval_t a
,b
,c
,len
;
1246 /* Set up the internal state */
1248 a
= b
= 0x9e3779b9; /* the golden ratio; an arbitrary value */
1249 c
= initval
; /* the previous hash value */
1251 /*---------------------------------------- handle most of the key */
1254 a
+= (k
[0] +((hashval_t
)k
[1]<<8) +((hashval_t
)k
[2]<<16) +((hashval_t
)k
[3]<<24));
1255 b
+= (k
[4] +((hashval_t
)k
[5]<<8) +((hashval_t
)k
[6]<<16) +((hashval_t
)k
[7]<<24));
1256 c
+= (k
[8] +((hashval_t
)k
[9]<<8) +((hashval_t
)k
[10]<<16)+((hashval_t
)k
[11]<<24));
1261 /*------------------------------------- handle the last 11 bytes */
1263 switch(len
) /* all the case statements fall through */
1265 case 11: c
+=((hashval_t
)k
[10]<<24);
1266 case 10: c
+=((hashval_t
)k
[9]<<16);
1267 case 9 : c
+=((hashval_t
)k
[8]<<8);
1268 /* the first byte of c is reserved for the length */
1269 case 8 : b
+=((hashval_t
)k
[7]<<24);
1270 case 7 : b
+=((hashval_t
)k
[6]<<16);
1271 case 6 : b
+=((hashval_t
)k
[5]<<8);
1273 case 4 : a
+=((hashval_t
)k
[3]<<24);
1274 case 3 : a
+=((hashval_t
)k
[2]<<16);
1275 case 2 : a
+=((hashval_t
)k
[1]<<8);
1277 /* case 0: nothing left to add */
1280 /*-------------------------------------------- report the result */
1285 e_hash (const void *a
)
1287 const struct entry
*e
= a
;
1291 if (e
[0].etype
!= ETYPE_STRUCT
&& e
[0].etype
!= ETYPE_UNION
)
1293 for (i
= 0; i
<= e
[0].len
; ++i
)
1296 ret
= iterative_hash (&e
[i
], offsetof (struct entry
, attrib
), ret
);
1297 attriblen
= e
[i
].attrib
? strlen (e
[i
].attrib
) : -1;
1298 ret
= iterative_hash (&attriblen
, sizeof (int), ret
);
1300 ret
= iterative_hash (e
[i
].attrib
, attriblen
, ret
);
1306 e_eq (const void *a
, const void *b
)
1308 const struct entry
*ea
= a
, *eb
= b
;
1310 if (ea
[0].etype
!= ETYPE_STRUCT
&& ea
[0].etype
!= ETYPE_UNION
)
1312 if (ea
[0].len
!= eb
[0].len
)
1314 for (i
= 0; i
<= ea
[0].len
; ++i
)
1316 if (ea
[i
].etype
!= eb
[i
].etype
1317 || ea
[i
].len
!= eb
[i
].len
1318 || ea
[i
].arr_len
!= eb
[i
].arr_len
1319 || ea
[i
].type
!= eb
[i
].type
)
1321 if ((ea
[i
].attrib
== NULL
) ^ (eb
[i
].attrib
== NULL
))
1323 if (ea
[i
].attrib
&& strcmp (ea
[i
].attrib
, eb
[i
].attrib
) != 0)
1330 e_exists (const struct entry
*e
)
1336 for (h
= hash_table
[hval
% HASH_SIZE
]; h
; h
= h
->next
)
1343 e_insert (struct entry
*e
)
1348 e
->next
= hash_table
[hval
% HASH_SIZE
];
1349 hash_table
[hval
% HASH_SIZE
] = e
;
1353 output (struct entry
*e
)
1358 const char *skip_cint
= "";
1360 if (e
[0].etype
!= ETYPE_STRUCT
&& e
[0].etype
!= ETYPE_UNION
)
1366 n
= (struct entry
*) malloc ((e
[0].len
+ 1) * sizeof (struct entry
));
1367 memcpy (n
, e
, (e
[0].len
+ 1) * sizeof (struct entry
));
1371 switchfiles (e
[0].len
);
1373 for (i
= 1; i
<= e
[0].len
; ++i
)
1374 if ((e
[i
].etype
== ETYPE_TYPE
|| e
[i
].etype
== ETYPE_ARRAY
)
1375 && (e
[i
].type
->type
== TYPE_CINT
|| e
[i
].type
->type
== TYPE_CUINT
))
1380 fprintf (outfile
, (generate_random () & 1)
1381 ? "TX%s(%d,%s %s,," : "TX%s(%d,%s,%s,", skip_cint
,
1382 idx
, e
[0].etype
== ETYPE_STRUCT
? "struct" : "union",
1384 else if (e
[0].etype
== ETYPE_STRUCT
)
1385 fprintf (outfile
, "T%s(%d,", skip_cint
, idx
);
1387 fprintf (outfile
, "U%s(%d,", skip_cint
, idx
);
1389 for (i
= 1; i
<= e
[0].len
; )
1390 i
+= subfield (e
+ i
, &c
);
1391 fputs (",", outfile
);
1393 for (i
= 1; i
<= e
[0].len
; )
1395 i
+= subvalues (e
+ i
, namebuf
, &c
);
1396 if (e
[0].etype
== ETYPE_UNION
)
1399 fputs (")\n", outfile
);
1400 if (output_one
&& idx
== limidx
)
1408 FEATURE_COMPLEX
= 2,
1409 FEATURE_ALIGNEDPACKED
= 4,
1410 FEATURE_ZEROARRAY
= 8,
1411 FEATURE_ZEROBITFLD
= 16,
1412 ALL_FEATURES
= FEATURE_COMPLEX
| FEATURE_VECTOR
| FEATURE_ZEROARRAY
1413 | FEATURE_ALIGNEDPACKED
| FEATURE_ZEROBITFLD
1417 singles (enum FEATURE features
)
1421 memset (e
, 0, sizeof (e
));
1422 e
[0].etype
= ETYPE_STRUCT
;
1424 e
[0].etype
= ETYPE_UNION
;
1427 i
< ((features
& FEATURE_ALIGNEDPACKED
) ? NATTRIBS2
: NATTRIBS1
);
1430 e
[0].attrib
= attributes
[i
];
1431 e
[0].etype
= ETYPE_STRUCT
;
1433 e
[0].etype
= ETYPE_UNION
;
1438 for (i
= 0; i
< NTYPES2
; ++i
)
1440 e
[0].etype
= ETYPE_STRUCT
;
1441 e
[1].etype
= ETYPE_TYPE
;
1442 e
[1].type
= &base_types
[i
];
1444 e
[0].etype
= ETYPE_UNION
;
1447 if (features
& FEATURE_COMPLEX
)
1448 for (i
= 0; i
< NCTYPES2
; ++i
)
1450 e
[0].etype
= ETYPE_STRUCT
;
1451 e
[1].etype
= ETYPE_TYPE
;
1452 e
[1].type
= &complex_types
[i
];
1454 e
[0].etype
= ETYPE_UNION
;
1457 if (features
& FEATURE_VECTOR
)
1458 for (i
= 0; i
< NVTYPES2
; ++i
)
1460 e
[0].etype
= ETYPE_STRUCT
;
1461 e
[1].etype
= ETYPE_TYPE
;
1462 e
[1].type
= &vector_types
[i
];
1464 e
[0].etype
= ETYPE_UNION
;
1470 choose_type (enum FEATURE features
, struct entry
*e
, int r
, int in_array
)
1474 i
= NTYPES2
- NTYPES1
;
1475 if (features
& FEATURE_COMPLEX
)
1477 if (features
& FEATURE_VECTOR
)
1484 if (features
& FEATURE_COMPLEX
)
1490 if (features
& FEATURE_COMPLEX
)
1496 if (r
< NTYPES2
- NTYPES1
)
1497 e
->type
= &base_types
[r
+ NTYPES1
];
1498 r
-= NTYPES2
- NTYPES1
;
1499 if (e
->type
== NULL
&& (features
& FEATURE_COMPLEX
))
1502 e
->type
= &complex_types
[r
];
1505 if (e
->type
== NULL
&& (features
& FEATURE_VECTOR
))
1508 e
->type
= &vector_types
[r
];
1511 if (e
->type
== NULL
&& !in_array
)
1514 e
->type
= &attrib_types
[r
];
1517 if (e
->type
== NULL
&& !in_array
&& (features
& FEATURE_COMPLEX
))
1520 e
->type
= &complex_attrib_types
[r
];
1523 if (e
->type
== NULL
&& in_array
)
1526 e
->type
= &attrib_array_types
[r
];
1529 if (e
->type
== NULL
&& in_array
&& (features
& FEATURE_COMPLEX
))
1532 e
->type
= &complex_attrib_array_types
[r
];
1535 if (e
->type
== NULL
)
1539 /* This is from gcc.c-torture/execute/builtin-bitops-1.c. */
1541 my_ffsll (unsigned long long x
)
1546 /* We've tested LLONG_MAX for 64 bits so this should be safe. */
1547 for (i
= 0; i
< 64; i
++)
1548 if (x
& (1ULL << i
))
1554 generate_fields (enum FEATURE features
, struct entry
*e
, struct entry
*parent
,
1557 int r
, i
, j
, ret
= 1, n
, incr
, sametype
;
1559 for (n
= 0; n
< len
; n
+= incr
)
1561 r
= generate_random ();
1562 /* 50% ETYPE_TYPE base_types NTYPES1
1563 12.5% ETYPE_TYPE other
1566 12.5% ETYPE_STRUCT|ETYPE_UNION|ETYPE_STRUCT_ARRAY|ETYPE_UNION_ARRAY */
1576 e
[n
].etype
= ETYPE_TYPE
;
1577 e
[n
].type
= &base_types
[r
% NTYPES1
];
1580 e
[n
].etype
= ETYPE_TYPE
;
1581 choose_type (features
, &e
[n
], r
, 0);
1584 e
[n
].etype
= ETYPE_ARRAY
;
1588 e
[n
].type
= &base_types
[r
% NTYPES1
];
1590 choose_type (features
, &e
[n
], r
, 1);
1591 r
= generate_random ();
1592 if ((features
& FEATURE_ZEROARRAY
) && (r
& 3) == 0)
1595 if (n
== len
- 1 && (r
& 4)
1596 && (parent
->etype
== ETYPE_STRUCT
1597 || parent
->etype
== ETYPE_STRUCT_ARRAY
))
1600 for (k
= 0; k
< n
; ++k
)
1601 if (e
[k
].etype
!= ETYPE_BITFLD
|| e
[k
].len
)
1608 else if ((r
& 3) != 3)
1609 e
[n
].arr_len
= (r
>> 2) & 7;
1611 e
[n
].arr_len
= (r
>> 2) & 31;
1624 incr
= 1 + (r
>> 3) % (len
- n
);
1629 incr
= 1 + (r
>> 3) % (len
- n
);
1632 for (j
= n
; j
< n
+ incr
; ++j
)
1636 e
[j
].etype
= ETYPE_BITFLD
;
1637 if (j
== n
|| !sametype
)
1640 r
= generate_random ();
1645 = &aligned_bitfld_types
[r
% n_aligned_bitfld_types
];
1648 = &bitfld_types
[r
% n_bitfld_types
];
1651 e
[j
].type
= e
[n
].type
;
1652 r
= generate_random ();
1655 switch (e
[j
].type
->bitfld
)
1657 case 'C': ma
= 8; break;
1658 case 'S': ma
= 16; break;
1659 case 'I': ma
= 32; break;
1661 case 'Q': ma
= 64; break;
1662 case 'B': ma
= 1; break;
1664 if (e
[j
].type
->type
== TYPE_UENUM
)
1665 mi
= my_ffsll (e
[j
].type
->maxval
+ 1) - 1;
1666 else if (e
[j
].type
->type
== TYPE_SENUM
)
1667 mi
= my_ffsll (e
[j
].type
->maxval
+ 1);
1674 else if (mi
> 16 || !short_enums
)
1685 if (sametype
&& (r
& 3) == 0 && ma
> 1)
1688 for (k
= n
; k
< j
; ++k
)
1691 e
[j
].len
= sum
? ma
- sum
: ma
;
1694 if (! (features
& FEATURE_ZEROBITFLD
) && mi
== 0)
1696 if (e
[j
].len
< mi
|| e
[j
].len
> ma
)
1697 e
[j
].len
= mi
+ (r
% (ma
+ 1 - mi
));
1699 if ((features
& FEATURE_ZEROBITFLD
) && (r
& 3) == 0
1710 e
[n
].etype
= ETYPE_STRUCT
;
1714 e
[n
].etype
= ETYPE_UNION
;
1718 e
[n
].etype
= ETYPE_STRUCT_ARRAY
;
1721 e
[n
].etype
= ETYPE_UNION_ARRAY
;
1725 e
[n
].len
= r
% (len
- n
);
1726 incr
= 1 + e
[n
].len
;
1727 generate_fields (features
, &e
[n
+ 1], &e
[n
], e
[n
].len
);
1728 if (e
[n
].etype
== ETYPE_STRUCT_ARRAY
1729 || e
[n
].etype
== ETYPE_UNION_ARRAY
)
1731 r
= generate_random ();
1732 if ((features
& FEATURE_ZEROARRAY
) && (r
& 3) == 0)
1735 if (n
+ incr
== len
&& (r
& 4)
1736 && (parent
->etype
== ETYPE_STRUCT
1737 || parent
->etype
== ETYPE_STRUCT_ARRAY
))
1740 for (k
= 0; k
< n
; ++k
)
1741 if (e
[k
].etype
!= ETYPE_BITFLD
|| e
[k
].len
)
1748 else if ((r
& 3) != 3)
1749 e
[n
].arr_len
= (r
>> 2) & 7;
1751 e
[n
].arr_len
= (r
>> 2) & 31;
1755 r
= generate_random ();
1759 i
= (features
& FEATURE_ALIGNEDPACKED
) ? NATTRIBS2
: NATTRIBS1
;
1760 e
[n
].attrib
= attributes
[r
% i
];
1761 if (! (features
& FEATURE_ALIGNEDPACKED
)
1762 && strcmp (e
[n
].attrib
, "atpa") == 0
1763 && ((e
[n
].type
>= &attrib_types
[0]
1764 && e
[n
].type
< &attrib_types
[NATYPES2
])
1765 || (e
[n
].type
>= &complex_attrib_types
[0]
1766 && e
[n
].type
< &complex_attrib_types
[NCATYPES2
])
1767 || (e
[n
].type
>= &attrib_array_types
[0]
1768 && e
[n
].type
< &attrib_array_types
[NAATYPES2
])
1769 || (e
[n
].type
>= &complex_attrib_array_types
[0]
1770 && e
[n
].type
< &complex_attrib_array_types
[NAATYPES2
])
1771 || (e
[n
].type
>= &aligned_bitfld_types
[0]
1772 && e
[n
].type
< &aligned_bitfld_types
[n_aligned_bitfld_types
])))
1779 generate_random_tests (enum FEATURE features
, int len
)
1781 struct entry e
[len
+ 1];
1783 if (len
> 'z' - 'a' + 1)
1785 memset (e
, 0, sizeof (e
));
1786 r
= generate_random ();
1788 e
[0].etype
= ETYPE_UNION
;
1790 e
[0].etype
= ETYPE_STRUCT
;
1796 if (features
& FEATURE_ALIGNEDPACKED
)
1800 e
[0].attrib
= attributes
[r
];
1802 generate_fields (features
, &e
[1], &e
[0], len
);
1806 struct { const char *name
; enum FEATURE f
; }
1809 { "complex", FEATURE_COMPLEX
},
1810 { "vector", FEATURE_VECTOR
},
1811 { "[0] :0", FEATURE_ZEROARRAY
| FEATURE_ZEROBITFLD
},
1812 { "complex vector [0]",
1813 FEATURE_COMPLEX
| FEATURE_VECTOR
| FEATURE_ZEROARRAY
},
1814 { "aligned packed complex vector [0] :0",
1815 FEATURE_COMPLEX
| FEATURE_VECTOR
| FEATURE_ZEROARRAY
1816 | FEATURE_ALIGNEDPACKED
| FEATURE_ZEROBITFLD
},
1820 main (int argc
, char **argv
)
1822 int i
, j
, count
, c
, n
= 3000;
1825 if (sizeof (int) != 4 || sizeof (long long) != 8)
1832 if (argv
[i
][0] == '-' && argv
[i
][2] == '\0')
1834 optarg
= argv
[i
+ 1];
1850 limidx
= atoi (optarg
);
1857 fprintf (stderr
, "unrecognized option %s\n", argv
[i
]);
1865 outfile
= fopen ("/dev/null", "w");
1866 if (outfile
== NULL
)
1868 fputs ("could not open /dev/null", stderr
);
1874 if (destdir
== NULL
&& !output_one
)
1877 fprintf (stderr
, "Usage:\n\
1878 %s [-e] [-s srcdir -d destdir] [-n count] [-i idx]\n\
1879 Either -s srcdir -d destdir or -i idx must be used\n", argv
[0]);
1883 if (srcdir
== NULL
&& !output_one
)
1886 for (i
= 0; i
< NTYPES2
; ++i
)
1887 if (base_types
[i
].bitfld
)
1888 bitfld_types
[n_bitfld_types
++] = base_types
[i
];
1889 for (i
= 0; i
< NATYPES2
; ++i
)
1890 if (attrib_types
[i
].bitfld
)
1891 aligned_bitfld_types
[n_aligned_bitfld_types
++] = attrib_types
[i
];
1892 for (i
= 0; i
< sizeof (features
) / sizeof (features
[0]); ++i
)
1901 for (j
= 1; j
<= 9; ++j
)
1902 while (idx
< startidx
+ j
* count
)
1903 generate_random_tests (features
[i
].f
, j
);
1904 while (idx
< startidx
+ count
* 10)
1905 generate_random_tests (features
[i
].f
, 10 + (generate_random () % 16));
1907 for (i
= 0; n
> 3000 && i
< sizeof (features
) / sizeof (features
[0]); ++i
)
1913 singles (features
[i
].f
);
1917 while (idx
< startidx
+ 1000)
1918 generate_random_tests (features
[i
].f
, 1);
1924 while (idx
< startidx
+ 100)
1925 generate_random_tests (features
[i
].f
, 1);
1928 for (j
= 2; j
<= 9; ++j
)
1929 while (idx
< startidx
+ (j
- 1) * count
)
1930 generate_random_tests (features
[i
].f
, j
);
1931 while (idx
< startidx
+ count
* 9)
1932 generate_random_tests (features
[i
].f
, 10 + (generate_random () % 16));
1937 generate_random_tests (ALL_FEATURES
, 1 + (generate_random () % 25));