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
;
61 unsigned long long int maxval
;
65 struct types base_types
[] = {
66 /* As we don't know whether char will be signed or not, just limit ourselves
67 to unsigned values less than maximum signed char value. */
68 { "char", TYPE_UINT
, 127, 'C' },
69 { "signed char", TYPE_INT
, 127, 'C' },
70 { "unsigned char", TYPE_UINT
, 255, 'C' },
71 { "short int", TYPE_INT
, 32767, 'S' },
72 { "unsigned short int", TYPE_UINT
, 65535, 'S' },
73 { "int", TYPE_INT
, 2147483647, 'I' },
74 { "unsigned int", TYPE_UINT
, 4294967295U, 'I' },
75 { "long int", TYPE_INT
, 9223372036854775807LL, 'L' },
76 { "unsigned long int", TYPE_UINT
, 18446744073709551615ULL, 'L' },
77 { "long long int", TYPE_INT
, 9223372036854775807LL, 'Q' },
78 { "unsigned long long int", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
79 { "bool", TYPE_UINT
, 1, 'B' },
80 { "void *", TYPE_PTR
, 0, 0 },
81 { "char *", TYPE_PTR
, 0, 0 },
82 { "int *", TYPE_PTR
, 0, 0 },
83 { "float", TYPE_FLOAT
, 0, 0 },
84 { "double", TYPE_FLOAT
, 0, 0 },
85 { "long double", TYPE_FLOAT
, 0, 0 },
86 #ifndef SKIP_DECIMAL_FLOAT
87 { "_Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
88 { "_Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
89 { "_Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
94 { "Tchar", TYPE_UINT
, 127, 'C' },
95 { "Tschar", TYPE_INT
, 127, 'C' },
96 { "Tuchar", TYPE_UINT
, 255, 'C' },
97 { "Tshort", TYPE_INT
, 32767, 'S' },
98 { "Tushort", TYPE_UINT
, 65535, 'S' },
99 { "Tint", TYPE_INT
, 2147483647, 'I' },
100 { "Tuint", TYPE_UINT
, 4294967295U, 'I' },
101 { "Tlong", TYPE_INT
, 9223372036854775807LL, 'L' },
102 { "Tulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
103 { "Tllong", TYPE_INT
, 9223372036854775807LL, 'Q' },
104 { "Tullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
105 { "Tbool", TYPE_UINT
, 1, 'B' },
106 { "size_t", TYPE_UINT
, 18446744073709551615ULL, 0 },
107 { "Tptr", TYPE_PTR
, 0, 0 },
108 { "Tcptr", TYPE_PTR
, 0, 0 },
109 { "Tiptr", TYPE_PTR
, 0, 0 },
110 { "Tfnptr", TYPE_FNPTR
, 0, 0 },
111 { "Tfloat", TYPE_FLOAT
, 0, 0 },
112 { "Tdouble", TYPE_FLOAT
, 0, 0 },
113 { "Tldouble", TYPE_FLOAT
, 0, 0 },
114 #ifndef SKIP_DECIMAL_FLOAT
115 { "TDecimal32", TYPE_DEC_FLOAT
, 0, 0 },
116 { "TDecimal64", TYPE_DEC_FLOAT
, 0, 0 },
117 { "TDecimal128", TYPE_DEC_FLOAT
, 0, 0 },
119 { "enum E0", TYPE_UENUM
, 0, ' ' },
120 { "enum E1", TYPE_UENUM
, 1, ' ' },
121 { "enum E2", TYPE_SENUM
, 3, ' ' },
122 { "enum E3", TYPE_SENUM
, 127, ' ' },
123 { "enum E4", TYPE_UENUM
, 255, ' ' },
124 { "enum E5", TYPE_SENUM
, 32767, ' ' },
125 { "enum E6", TYPE_UENUM
, 65535, ' ' },
126 { "enum E7", TYPE_SENUM
, 2147483647, ' ' },
127 { "enum E8", TYPE_UENUM
, 4294967295U, ' ' },
128 { "enum E9", TYPE_SENUM
, 1099511627775LL, ' ' },
129 { "TE0", TYPE_UENUM
, 0, ' ' },
130 { "TE1", TYPE_UENUM
, 1, ' ' },
131 { "TE2", TYPE_SENUM
, 3, ' ' },
132 { "TE3", TYPE_SENUM
, 127, ' ' },
133 { "TE4", TYPE_UENUM
, 255, ' ' },
134 { "TE5", TYPE_SENUM
, 32767, ' ' },
135 { "TE6", TYPE_UENUM
, 65535, ' ' },
136 { "TE7", TYPE_SENUM
, 2147483647, ' ' },
137 { "TE8", TYPE_UENUM
, 4294967295U, ' ' },
138 { "TE9", TYPE_SENUM
, 1099511627775LL, ' ' },
139 /* vector-defs.h typedefs */
140 { "qi", TYPE_INT
, 127, 0 },
141 { "hi", TYPE_INT
, 32767, 0 },
142 { "si", TYPE_INT
, 2147483647, 0 },
143 { "di", TYPE_INT
, 9223372036854775807LL, 0 },
144 { "sf", TYPE_FLOAT
, 0, 0 },
145 { "df", TYPE_FLOAT
, 0, 0 }
146 #define NTYPES2 (sizeof (base_types) / sizeof (base_types[0]))
148 struct types complex_types
[] = {
149 { "_Complex char", TYPE_CUINT
, 127, 0 },
150 { "_Complex signed char", TYPE_CINT
, 127, 0 },
151 { "_Complex unsigned char", TYPE_CUINT
, 255, 0 },
152 { "_Complex short int", TYPE_CINT
, 32767, 0 },
153 { "_Complex unsigned short int", TYPE_CUINT
, 65535, 0 },
154 { "_Complex int", TYPE_CINT
, 2147483647, 0 },
155 { "_Complex unsigned int", TYPE_CUINT
, 4294967295U, 0 },
156 { "_Complex long int", TYPE_CINT
, 9223372036854775807LL, 0 },
157 { "_Complex unsigned long int", TYPE_CUINT
, 18446744073709551615ULL, 0 },
158 { "_Complex long long int", TYPE_CINT
, 9223372036854775807LL, 0 },
159 { "_Complex unsigned long long int", TYPE_CUINT
, 18446744073709551615ULL, 0 },
160 { "_Complex float", TYPE_CFLOAT
, 0, 0 },
161 { "_Complex double", TYPE_CFLOAT
, 0, 0 },
162 { "_Complex long double", TYPE_CFLOAT
, 0, 0 },
163 { "Tcchar", TYPE_CUINT
, 127, 0 },
164 { "Tcschar", TYPE_CINT
, 127, 0 },
165 { "Tcuchar", TYPE_CUINT
, 255, 0 },
166 { "Tcshort", TYPE_CINT
, 32767, 0 },
167 { "Tcushort", TYPE_CUINT
, 65535, 0 },
168 { "Tcint", TYPE_CINT
, 2147483647, 0 },
169 { "Tcuint", TYPE_CUINT
, 4294967295U, 0 },
170 { "Tclong", TYPE_CINT
, 9223372036854775807LL, 0 },
171 { "Tculong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
172 { "Tcllong", TYPE_CINT
, 9223372036854775807LL, 0 },
173 { "Tcullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
174 { "Tcfloat", TYPE_CFLOAT
, 0, 0 },
175 { "Tcdouble", TYPE_CFLOAT
, 0, 0 },
176 { "Tcldouble", TYPE_CFLOAT
, 0, 0 }
177 #define NCTYPES2 (sizeof (complex_types) / sizeof (complex_types[0]))
179 struct types vector_types
[] = {
180 /* vector-defs.h typedefs */
181 { "v8qi", TYPE_OTHER
, 0, 0 },
182 { "v16qi", TYPE_OTHER
, 0, 0 },
183 { "v2hi", TYPE_OTHER
, 0, 0 },
184 { "v4hi", TYPE_OTHER
, 0, 0 },
185 { "v8hi", TYPE_OTHER
, 0, 0 },
186 { "v2si", TYPE_OTHER
, 0, 0 },
187 { "v4si", TYPE_OTHER
, 0, 0 },
188 { "v1di", TYPE_OTHER
, 0, 0 },
189 { "v2di", TYPE_OTHER
, 0, 0 },
190 { "v2sf", TYPE_OTHER
, 0, 0 },
191 { "v4sf", TYPE_OTHER
, 0, 0 },
192 { "v16sf", TYPE_OTHER
, 0, 0 },
193 { "v2df", TYPE_OTHER
, 0, 0 },
194 { "u8qi", TYPE_OTHER
, 0, 0 },
195 { "u16qi", TYPE_OTHER
, 0, 0 },
196 { "u2hi", TYPE_OTHER
, 0, 0 },
197 { "u4hi", TYPE_OTHER
, 0, 0 },
198 { "u8hi", TYPE_OTHER
, 0, 0 },
199 { "u2si", TYPE_OTHER
, 0, 0 },
200 { "u4si", TYPE_OTHER
, 0, 0 },
201 { "u1di", TYPE_OTHER
, 0, 0 },
202 { "u2di", TYPE_OTHER
, 0, 0 },
203 { "u2sf", TYPE_OTHER
, 0, 0 },
204 { "u4sf", TYPE_OTHER
, 0, 0 },
205 { "u16sf", TYPE_OTHER
, 0, 0 },
206 { "u2df", TYPE_OTHER
, 0, 0 },
207 { "__m64", TYPE_OTHER
, 0, 0 },
208 { "__m128", TYPE_OTHER
, 0, 0 }
209 #define NVTYPES2 (sizeof (vector_types) / sizeof (vector_types[0]))
211 struct types attrib_types
[] = {
212 { "Talchar", TYPE_UINT
, 127, 'C' },
213 { "Talschar", TYPE_INT
, 127, 'C' },
214 { "Taluchar", TYPE_UINT
, 255, 'C' },
215 { "Talshort", TYPE_INT
, 32767, 'S' },
216 { "Talushort", TYPE_UINT
, 65535, 'S' },
217 { "Talint", TYPE_INT
, 2147483647, 'I' },
218 { "Taluint", TYPE_UINT
, 4294967295U, 'I' },
219 { "Tallong", TYPE_INT
, 9223372036854775807LL, 'L' },
220 { "Talulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
221 { "Talllong", TYPE_INT
, 9223372036854775807LL, 'Q' },
222 { "Talullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
223 { "Talbool", TYPE_UINT
, 1, 'B' },
224 { "Talptr", TYPE_PTR
, 0, 0 },
225 { "Talcptr", TYPE_PTR
, 0, 0 },
226 { "Taliptr", TYPE_PTR
, 0, 0 },
227 { "Talfloat", TYPE_FLOAT
, 0, 0 },
228 { "Taldouble", TYPE_FLOAT
, 0, 0 },
229 { "Talldouble", TYPE_FLOAT
, 0, 0 },
230 #ifndef SKIP_DECIMAL_FLOAT
231 { "TalDecimal32", TYPE_DEC_FLOAT
, 0, 0 },
232 { "TalDecimal64", TYPE_DEC_FLOAT
, 0, 0 },
233 { "TalDecimal128", TYPE_DEC_FLOAT
, 0, 0 },
235 { "TalE0", TYPE_UENUM
, 0, ' ' },
236 { "TalE1", TYPE_UENUM
, 1, ' ' },
237 { "TalE2", TYPE_SENUM
, 3, ' ' },
238 { "TalE3", TYPE_SENUM
, 127, ' ' },
239 { "TalE4", TYPE_UENUM
, 255, ' ' },
240 { "TalE5", TYPE_SENUM
, 32767, ' ' },
241 { "TalE6", TYPE_UENUM
, 65535, ' ' },
242 { "TalE7", TYPE_SENUM
, 2147483647, ' ' },
243 { "TalE8", TYPE_UENUM
, 4294967295U, ' ' },
244 { "TalE9", TYPE_SENUM
, 1099511627775LL, ' ' },
245 { "Tal1char", TYPE_UINT
, 127, 'C' },
246 { "Tal1schar", TYPE_INT
, 127, 'C' },
247 { "Tal1uchar", TYPE_UINT
, 255, 'C' },
248 { "Tal1short", TYPE_INT
, 32767, 'S' },
249 { "Tal1ushort", TYPE_UINT
, 65535, 'S' },
250 { "Tal1int", TYPE_INT
, 2147483647, 'I' },
251 { "Tal1uint", TYPE_UINT
, 4294967295U, 'I' },
252 { "Tal1long", TYPE_INT
, 9223372036854775807LL, 'L' },
253 { "Tal1ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
254 { "Tal1llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
255 { "Tal1ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
256 { "Tal1bool", TYPE_UINT
, 1, 'B' },
257 { "Tal1ptr", TYPE_PTR
, 0, 0 },
258 { "Tal1cptr", TYPE_PTR
, 0, 0 },
259 { "Tal1iptr", TYPE_PTR
, 0, 0 },
260 { "Tal1float", TYPE_FLOAT
, 0, 0 },
261 { "Tal1double", TYPE_FLOAT
, 0, 0 },
262 { "Tal1ldouble", TYPE_FLOAT
, 0, 0 },
263 #ifndef SKIP_DECIMAL_FLOAT
264 { "Tal1Decimal32", TYPE_DEC_FLOAT
, 0, 0},
265 { "Tal1Decimal64", TYPE_DEC_FLOAT
, 0, 0},
266 { "Tal1Decimal128", TYPE_DEC_FLOAT
, 0, 0},
268 { "Tal1E0", TYPE_UENUM
, 0, ' ' },
269 { "Tal1E1", TYPE_UENUM
, 1, ' ' },
270 { "Tal1E2", TYPE_SENUM
, 3, ' ' },
271 { "Tal1E3", TYPE_SENUM
, 127, ' ' },
272 { "Tal1E4", TYPE_UENUM
, 255, ' ' },
273 { "Tal1E5", TYPE_SENUM
, 32767, ' ' },
274 { "Tal1E6", TYPE_UENUM
, 65535, ' ' },
275 { "Tal1E7", TYPE_SENUM
, 2147483647, ' ' },
276 { "Tal1E8", TYPE_UENUM
, 4294967295U, ' ' },
277 { "Tal1E9", TYPE_SENUM
, 1099511627775LL, ' ' },
278 { "Tal2char", TYPE_UINT
, 127, 'C' },
279 { "Tal2schar", TYPE_INT
, 127, 'C' },
280 { "Tal2uchar", TYPE_UINT
, 255, 'C' },
281 { "Tal2short", TYPE_INT
, 32767, 'S' },
282 { "Tal2ushort", TYPE_UINT
, 65535, 'S' },
283 { "Tal2int", TYPE_INT
, 2147483647, 'I' },
284 { "Tal2uint", TYPE_UINT
, 4294967295U, 'I' },
285 { "Tal2long", TYPE_INT
, 9223372036854775807LL, 'L' },
286 { "Tal2ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
287 { "Tal2llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
288 { "Tal2ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
289 { "Tal2bool", TYPE_UINT
, 1, 'B' },
290 { "Tal2ptr", TYPE_PTR
, 0, 0 },
291 { "Tal2cptr", TYPE_PTR
, 0, 0 },
292 { "Tal2iptr", TYPE_PTR
, 0, 0 },
293 { "Tal2float", TYPE_FLOAT
, 0, 0 },
294 { "Tal2double", TYPE_FLOAT
, 0, 0 },
295 { "Tal2ldouble", TYPE_FLOAT
, 0, 0 },
296 #ifndef SKIP_DECIMAL_FLOAT
297 { "Tal2Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
298 { "Tal2Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
299 { "Tal2Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
301 { "Tal2E0", TYPE_UENUM
, 0, ' ' },
302 { "Tal2E1", TYPE_UENUM
, 1, ' ' },
303 { "Tal2E2", TYPE_SENUM
, 3, ' ' },
304 { "Tal2E3", TYPE_SENUM
, 127, ' ' },
305 { "Tal2E4", TYPE_UENUM
, 255, ' ' },
306 { "Tal2E5", TYPE_SENUM
, 32767, ' ' },
307 { "Tal2E6", TYPE_UENUM
, 65535, ' ' },
308 { "Tal2E7", TYPE_SENUM
, 2147483647, ' ' },
309 { "Tal2E8", TYPE_UENUM
, 4294967295U, ' ' },
310 { "Tal2E9", TYPE_SENUM
, 1099511627775LL, ' ' },
311 { "Tal4char", TYPE_UINT
, 127, 'C' },
312 { "Tal4schar", TYPE_INT
, 127, 'C' },
313 { "Tal4uchar", TYPE_UINT
, 255, 'C' },
314 { "Tal4short", TYPE_INT
, 32767, 'S' },
315 { "Tal4ushort", TYPE_UINT
, 65535, 'S' },
316 { "Tal4int", TYPE_INT
, 2147483647, 'I' },
317 { "Tal4uint", TYPE_UINT
, 4294967295U, 'I' },
318 { "Tal4long", TYPE_INT
, 9223372036854775807LL, 'L' },
319 { "Tal4ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
320 { "Tal4llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
321 { "Tal4ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
322 { "Tal4bool", TYPE_UINT
, 1, 'B' },
323 { "Tal4ptr", TYPE_PTR
, 0, 0 },
324 { "Tal4cptr", TYPE_PTR
, 0, 0 },
325 { "Tal4iptr", TYPE_PTR
, 0, 0 },
326 { "Tal4float", TYPE_FLOAT
, 0, 0 },
327 { "Tal4double", TYPE_FLOAT
, 0, 0 },
328 { "Tal4ldouble", TYPE_FLOAT
, 0, 0 },
329 #ifndef SKIP_DECIMAL_FLOAT
330 { "Tal4Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
331 { "Tal4Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
332 { "Tal4Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
334 { "Tal4E0", TYPE_UENUM
, 0, ' ' },
335 { "Tal4E1", TYPE_UENUM
, 1, ' ' },
336 { "Tal4E2", TYPE_SENUM
, 3, ' ' },
337 { "Tal4E3", TYPE_SENUM
, 127, ' ' },
338 { "Tal4E4", TYPE_UENUM
, 255, ' ' },
339 { "Tal4E5", TYPE_SENUM
, 32767, ' ' },
340 { "Tal4E6", TYPE_UENUM
, 65535, ' ' },
341 { "Tal4E7", TYPE_SENUM
, 2147483647, ' ' },
342 { "Tal4E8", TYPE_UENUM
, 4294967295U, ' ' },
343 { "Tal4E9", TYPE_SENUM
, 1099511627775LL, ' ' },
344 { "Tal8char", TYPE_UINT
, 127, 'C' },
345 { "Tal8schar", TYPE_INT
, 127, 'C' },
346 { "Tal8uchar", TYPE_UINT
, 255, 'C' },
347 { "Tal8short", TYPE_INT
, 32767, 'S' },
348 { "Tal8ushort", TYPE_UINT
, 65535, 'S' },
349 { "Tal8int", TYPE_INT
, 2147483647, 'I' },
350 { "Tal8uint", TYPE_UINT
, 4294967295U, 'I' },
351 { "Tal8long", TYPE_INT
, 9223372036854775807LL, 'L' },
352 { "Tal8ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
353 { "Tal8llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
354 { "Tal8ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
355 { "Tal8bool", TYPE_UINT
, 1, 'B' },
356 { "Tal8ptr", TYPE_PTR
, 0, 0 },
357 { "Tal8cptr", TYPE_PTR
, 0, 0 },
358 { "Tal8iptr", TYPE_PTR
, 0, 0 },
359 { "Tal8float", TYPE_FLOAT
, 0, 0 },
360 { "Tal8double", TYPE_FLOAT
, 0, 0 },
361 { "Tal8ldouble", TYPE_FLOAT
, 0, 0 },
362 #ifndef SKIP_DECIMAL_FLOAT
363 { "Tal8Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
364 { "Tal8Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
365 { "Tal8Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
367 { "Tal8E0", TYPE_UENUM
, 0, ' ' },
368 { "Tal8E1", TYPE_UENUM
, 1, ' ' },
369 { "Tal8E2", TYPE_SENUM
, 3, ' ' },
370 { "Tal8E3", TYPE_SENUM
, 127, ' ' },
371 { "Tal8E4", TYPE_UENUM
, 255, ' ' },
372 { "Tal8E5", TYPE_SENUM
, 32767, ' ' },
373 { "Tal8E6", TYPE_UENUM
, 65535, ' ' },
374 { "Tal8E7", TYPE_SENUM
, 2147483647, ' ' },
375 { "Tal8E8", TYPE_UENUM
, 4294967295U, ' ' },
376 { "Tal8E9", TYPE_SENUM
, 1099511627775LL, ' ' },
377 { "Tal16char", TYPE_UINT
, 127, 'C' },
378 { "Tal16schar", TYPE_INT
, 127, 'C' },
379 { "Tal16uchar", TYPE_UINT
, 255, 'C' },
380 { "Tal16short", TYPE_INT
, 32767, 'S' },
381 { "Tal16ushort", TYPE_UINT
, 65535, 'S' },
382 { "Tal16int", TYPE_INT
, 2147483647, 'I' },
383 { "Tal16uint", TYPE_UINT
, 4294967295U, 'I' },
384 { "Tal16long", TYPE_INT
, 9223372036854775807LL, 'L' },
385 { "Tal16ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
386 { "Tal16llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
387 { "Tal16ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
388 { "Tal16bool", TYPE_UINT
, 1, 'B' },
389 { "Tal16ptr", TYPE_PTR
, 0, 0 },
390 { "Tal16cptr", TYPE_PTR
, 0, 0 },
391 { "Tal16iptr", TYPE_PTR
, 0, 0 },
392 { "Tal16float", TYPE_FLOAT
, 0, 0 },
393 { "Tal16double", TYPE_FLOAT
, 0, 0 },
394 { "Tal16ldouble", TYPE_FLOAT
, 0, 0 },
395 #ifndef SKIP_DECIMAL_FLOAT
396 { "Tal16Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
397 { "Tal16Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
398 { "Tal16Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
400 { "Tal16E0", TYPE_UENUM
, 0, ' ' },
401 { "Tal16E1", TYPE_UENUM
, 1, ' ' },
402 { "Tal16E2", TYPE_SENUM
, 3, ' ' },
403 { "Tal16E3", TYPE_SENUM
, 127, ' ' },
404 { "Tal16E4", TYPE_UENUM
, 255, ' ' },
405 { "Tal16E5", TYPE_SENUM
, 32767, ' ' },
406 { "Tal16E6", TYPE_UENUM
, 65535, ' ' },
407 { "Tal16E7", TYPE_SENUM
, 2147483647, ' ' },
408 { "Tal16E8", TYPE_UENUM
, 4294967295U, ' ' },
409 { "Tal16E9", TYPE_SENUM
, 1099511627775LL, ' ' }
410 #define NATYPES2 (sizeof (attrib_types) / sizeof (attrib_types[0]))
412 struct types complex_attrib_types
[] = {
413 { "Talcchar", TYPE_CUINT
, 127, 0 },
414 { "Talcschar", TYPE_CINT
, 127, 0 },
415 { "Talcuchar", TYPE_CUINT
, 255, 0 },
416 { "Talcshort", TYPE_CINT
, 32767, 0 },
417 { "Talcushort", TYPE_CUINT
, 65535, 0 },
418 { "Talcint", TYPE_CINT
, 2147483647, 0 },
419 { "Talcuint", TYPE_CUINT
, 4294967295U, 0 },
420 { "Talclong", TYPE_CINT
, 9223372036854775807LL, 0 },
421 { "Talculong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
422 { "Talcllong", TYPE_CINT
, 9223372036854775807LL, 0 },
423 { "Talcullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
424 { "Talcfloat", TYPE_CFLOAT
, 0, 0 },
425 { "Talcdouble", TYPE_CFLOAT
, 0, 0 },
426 { "Talcldouble", TYPE_CFLOAT
, 0, 0 },
427 { "Tal1cchar", TYPE_CUINT
, 127, 0 },
428 { "Tal1cschar", TYPE_CINT
, 127, 0 },
429 { "Tal1cuchar", TYPE_CUINT
, 255, 0 },
430 { "Tal1cshort", TYPE_CINT
, 32767, 0 },
431 { "Tal1cushort", TYPE_CUINT
, 65535, 0 },
432 { "Tal1cint", TYPE_CINT
, 2147483647, 0 },
433 { "Tal1cuint", TYPE_CUINT
, 4294967295U, 0 },
434 { "Tal1clong", TYPE_CINT
, 9223372036854775807LL, 0 },
435 { "Tal1culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
436 { "Tal1cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
437 { "Tal1cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
438 { "Tal1cfloat", TYPE_CFLOAT
, 0, 0 },
439 { "Tal1cdouble", TYPE_CFLOAT
, 0, 0 },
440 { "Tal1cldouble", TYPE_CFLOAT
, 0, 0 },
441 { "Tal2cchar", TYPE_CUINT
, 127, 0 },
442 { "Tal2cschar", TYPE_CINT
, 127, 0 },
443 { "Tal2cuchar", TYPE_CUINT
, 255, 0 },
444 { "Tal2cshort", TYPE_CINT
, 32767, 0 },
445 { "Tal2cushort", TYPE_CUINT
, 65535, 0 },
446 { "Tal2cint", TYPE_CINT
, 2147483647, 0 },
447 { "Tal2cuint", TYPE_CUINT
, 4294967295U, 0 },
448 { "Tal2clong", TYPE_CINT
, 9223372036854775807LL, 0 },
449 { "Tal2culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
450 { "Tal2cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
451 { "Tal2cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
452 { "Tal2cfloat", TYPE_CFLOAT
, 0, 0 },
453 { "Tal2cdouble", TYPE_CFLOAT
, 0, 0 },
454 { "Tal2cldouble", TYPE_CFLOAT
, 0, 0 },
455 { "Tal4cchar", TYPE_CUINT
, 127, 0 },
456 { "Tal4cschar", TYPE_CINT
, 127, 0 },
457 { "Tal4cuchar", TYPE_CUINT
, 255, 0 },
458 { "Tal4cshort", TYPE_CINT
, 32767, 0 },
459 { "Tal4cushort", TYPE_CUINT
, 65535, 0 },
460 { "Tal4cint", TYPE_CINT
, 2147483647, 0 },
461 { "Tal4cuint", TYPE_CUINT
, 4294967295U, 0 },
462 { "Tal4clong", TYPE_CINT
, 9223372036854775807LL, 0 },
463 { "Tal4culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
464 { "Tal4cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
465 { "Tal4cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
466 { "Tal4cfloat", TYPE_CFLOAT
, 0, 0 },
467 { "Tal4cdouble", TYPE_CFLOAT
, 0, 0 },
468 { "Tal4cldouble", TYPE_CFLOAT
, 0, 0 },
469 { "Tal8cchar", TYPE_CUINT
, 127, 0 },
470 { "Tal8cschar", TYPE_CINT
, 127, 0 },
471 { "Tal8cuchar", TYPE_CUINT
, 255, 0 },
472 { "Tal8cshort", TYPE_CINT
, 32767, 0 },
473 { "Tal8cushort", TYPE_CUINT
, 65535, 0 },
474 { "Tal8cint", TYPE_CINT
, 2147483647, 0 },
475 { "Tal8cuint", TYPE_CUINT
, 4294967295U, 0 },
476 { "Tal8clong", TYPE_CINT
, 9223372036854775807LL, 0 },
477 { "Tal8culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
478 { "Tal8cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
479 { "Tal8cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
480 { "Tal8cfloat", TYPE_CFLOAT
, 0, 0 },
481 { "Tal8cdouble", TYPE_CFLOAT
, 0, 0 },
482 { "Tal8cldouble", TYPE_CFLOAT
, 0, 0 },
483 { "Tal16cchar", TYPE_CUINT
, 127, 0 },
484 { "Tal16cschar", TYPE_CINT
, 127, 0 },
485 { "Tal16cuchar", TYPE_CUINT
, 255, 0 },
486 { "Tal16cshort", TYPE_CINT
, 32767, 0 },
487 { "Tal16cushort", TYPE_CUINT
, 65535, 0 },
488 { "Tal16cint", TYPE_CINT
, 2147483647, 0 },
489 { "Tal16cuint", TYPE_CUINT
, 4294967295U, 0 },
490 { "Tal16clong", TYPE_CINT
, 9223372036854775807LL, 0 },
491 { "Tal16culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
492 { "Tal16cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
493 { "Tal16cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
494 { "Tal16cfloat", TYPE_CFLOAT
, 0, 0 },
495 { "Tal16cdouble", TYPE_CFLOAT
, 0, 0 },
496 { "Tal16cldouble", TYPE_CFLOAT
, 0, 0 }
497 #define NCATYPES2 (sizeof (complex_attrib_types) / sizeof (complex_attrib_types[0]))
499 struct types attrib_array_types
[] = {
500 { "Talx1char", TYPE_UINT
, 127, 'C' },
501 { "Talx1schar", TYPE_INT
, 127, 'C' },
502 { "Talx1uchar", TYPE_UINT
, 255, 'C' },
503 { "Talx1short", TYPE_INT
, 32767, 'S' },
504 { "Talx1ushort", TYPE_UINT
, 65535, 'S' },
505 { "Talx1int", TYPE_INT
, 2147483647, 'I' },
506 { "Talx1uint", TYPE_UINT
, 4294967295U, 'I' },
507 { "Talx1long", TYPE_INT
, 9223372036854775807LL, 'L' },
508 { "Talx1ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
509 { "Talx1llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
510 { "Talx1ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
511 { "Talx1bool", TYPE_UINT
, 1, 'B' },
512 { "Talx1ptr", TYPE_PTR
, 0, 0 },
513 { "Talx1cptr", TYPE_PTR
, 0, 0 },
514 { "Talx1iptr", TYPE_PTR
, 0, 0 },
515 { "Talx1float", TYPE_FLOAT
, 0, 0 },
516 { "Talx1double", TYPE_FLOAT
, 0, 0 },
517 { "Talx1ldouble", TYPE_FLOAT
, 0, 0 },
518 #ifndef SKIP_DECIMAL_FLOAT
519 { "Talx1Decimal32", TYPE_DEC_FLOAT
, 0 ,0 },
520 { "Talx1Decimal64", TYPE_DEC_FLOAT
, 0 ,0 },
521 { "Talx1Decimal128", TYPE_DEC_FLOAT
, 0 ,0 },
523 { "Talx1E0", TYPE_UENUM
, 0, ' ' },
524 { "Talx1E1", TYPE_UENUM
, 1, ' ' },
525 { "Talx1E2", TYPE_SENUM
, 3, ' ' },
526 { "Talx1E3", TYPE_SENUM
, 127, ' ' },
527 { "Talx1E4", TYPE_UENUM
, 255, ' ' },
528 { "Talx1E5", TYPE_SENUM
, 32767, ' ' },
529 { "Talx1E6", TYPE_UENUM
, 65535, ' ' },
530 { "Talx1E7", TYPE_SENUM
, 2147483647, ' ' },
531 { "Talx1E8", TYPE_UENUM
, 4294967295U, ' ' },
532 { "Talx1E9", TYPE_SENUM
, 1099511627775LL, ' ' },
533 { "Talx2short", TYPE_INT
, 32767, 'S' },
534 { "Talx2ushort", TYPE_UINT
, 65535, 'S' },
535 { "Talx2int", TYPE_INT
, 2147483647, 'I' },
536 { "Talx2uint", TYPE_UINT
, 4294967295U, 'I' },
537 { "Talx2long", TYPE_INT
, 9223372036854775807LL, 'L' },
538 { "Talx2ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
539 { "Talx2llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
540 { "Talx2ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
541 { "Talx2ptr", TYPE_PTR
, 0, 0 },
542 { "Talx2cptr", TYPE_PTR
, 0, 0 },
543 { "Talx2iptr", TYPE_PTR
, 0, 0 },
544 { "Talx2float", TYPE_FLOAT
, 0, 0 },
545 { "Talx2double", TYPE_FLOAT
, 0, 0 },
546 { "Talx2ldouble", TYPE_FLOAT
, 0, 0 },
547 #ifndef SKIP_DECIMAL_FLOAT
548 { "Talx2Decimal32", TYPE_DEC_FLOAT
, 0 , 0 },
549 { "Talx2Decimal64", TYPE_DEC_FLOAT
, 0 , 0 },
550 { "Talx2Decimal128", TYPE_DEC_FLOAT
, 0 , 0 },
552 { "Talx2E0", TYPE_UENUM
, 0, ' ' },
553 { "Talx2E1", TYPE_UENUM
, 1, ' ' },
554 { "Talx2E2", TYPE_SENUM
, 3, ' ' },
555 { "Talx2E3", TYPE_SENUM
, 127, ' ' },
556 { "Talx2E4", TYPE_UENUM
, 255, ' ' },
557 { "Talx2E5", TYPE_SENUM
, 32767, ' ' },
558 { "Talx2E6", TYPE_UENUM
, 65535, ' ' },
559 { "Talx2E7", TYPE_SENUM
, 2147483647, ' ' },
560 { "Talx2E8", TYPE_UENUM
, 4294967295U, ' ' },
561 { "Talx2E9", TYPE_SENUM
, 1099511627775LL, ' ' },
562 { "Talx4int", TYPE_INT
, 2147483647, 'I' },
563 { "Talx4uint", TYPE_UINT
, 4294967295U, 'I' },
564 { "Talx4long", TYPE_INT
, 9223372036854775807LL, 'L' },
565 { "Talx4ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
566 { "Talx4llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
567 { "Talx4ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
568 { "Talx4ptr", TYPE_PTR
, 0, 0 },
569 { "Talx4cptr", TYPE_PTR
, 0, 0 },
570 { "Talx4iptr", TYPE_PTR
, 0, 0 },
571 { "Talx4float", TYPE_FLOAT
, 0, 0 },
572 { "Talx4double", TYPE_FLOAT
, 0, 0 },
573 { "Talx4ldouble", TYPE_FLOAT
, 0, 0 },
574 #ifndef SKIP_DECIMAL_FLOAT
575 { "Talx4Decimal32", TYPE_DEC_FLOAT
, 0 , 0 },
576 { "Talx4Decimal64", TYPE_DEC_FLOAT
, 0 , 0 },
577 { "Talx4Decimal128", TYPE_DEC_FLOAT
, 0 , 0 },
579 { "Talx4E0", TYPE_UENUM
, 0, ' ' },
580 { "Talx4E1", TYPE_UENUM
, 1, ' ' },
581 { "Talx4E2", TYPE_SENUM
, 3, ' ' },
582 { "Talx4E3", TYPE_SENUM
, 127, ' ' },
583 { "Talx4E4", TYPE_UENUM
, 255, ' ' },
584 { "Talx4E5", TYPE_SENUM
, 32767, ' ' },
585 { "Talx4E6", TYPE_UENUM
, 65535, ' ' },
586 { "Talx4E7", TYPE_SENUM
, 2147483647, ' ' },
587 { "Talx4E8", TYPE_UENUM
, 4294967295U, ' ' },
588 { "Talx4E9", TYPE_SENUM
, 1099511627775LL, ' ' },
589 { "Taly8long", TYPE_INT
, 9223372036854775807LL, 'L' },
590 { "Taly8ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
591 { "Talx8llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
592 { "Talx8ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
593 { "Taly8ptr", TYPE_PTR
, 0, 0 },
594 { "Taly8cptr", TYPE_PTR
, 0, 0 },
595 { "Taly8iptr", TYPE_PTR
, 0, 0 },
596 { "Talx8double", TYPE_FLOAT
, 0, 0 },
597 { "Talx8ldouble", TYPE_FLOAT
, 0, 0 },
598 #ifndef SKIP_DECIMAL_FLOAT
599 { "Talx8Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
600 { "Talx8Decimal128", TYPE_DEC_FLOAT
, 0, 0 }
602 #define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0]))
604 struct types complex_attrib_array_types
[] = {
605 { "Talx1cchar", TYPE_CUINT
, 127, 0 },
606 { "Talx1cschar", TYPE_CINT
, 127, 0 },
607 { "Talx1cuchar", TYPE_CUINT
, 255, 0 },
608 { "Talx1cshort", TYPE_CINT
, 32767, 0 },
609 { "Talx1cushort", TYPE_CUINT
, 65535, 0 },
610 { "Talx1cint", TYPE_CINT
, 2147483647, 0 },
611 { "Talx1cuint", TYPE_CUINT
, 4294967295U, 0 },
612 { "Talx1clong", TYPE_CINT
, 9223372036854775807LL, 0 },
613 { "Talx1culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
614 { "Talx1cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
615 { "Talx1cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
616 { "Talx1cfloat", TYPE_CFLOAT
, 0, 0 },
617 { "Talx1cdouble", TYPE_CFLOAT
, 0, 0 },
618 { "Talx1cldouble", TYPE_CFLOAT
, 0, 0 },
619 { "Talx2cchar", TYPE_CUINT
, 127, 0 },
620 { "Talx2cschar", TYPE_CINT
, 127, 0 },
621 { "Talx2cuchar", TYPE_CUINT
, 255, 0 },
622 { "Talx2cshort", TYPE_CINT
, 32767, 0 },
623 { "Talx2cushort", TYPE_CUINT
, 65535, 0 },
624 { "Talx2cint", TYPE_CINT
, 2147483647, 0 },
625 { "Talx2cuint", TYPE_CUINT
, 4294967295U, 0 },
626 { "Talx2clong", TYPE_CINT
, 9223372036854775807LL, 0 },
627 { "Talx2culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
628 { "Talx2cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
629 { "Talx2cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
630 { "Talx2cfloat", TYPE_CFLOAT
, 0, 0 },
631 { "Talx2cdouble", TYPE_CFLOAT
, 0, 0 },
632 { "Talx2cldouble", TYPE_CFLOAT
, 0, 0 },
633 { "Talx4cshort", TYPE_CINT
, 32767, 0 },
634 { "Talx4cushort", TYPE_CUINT
, 65535, 0 },
635 { "Talx4cint", TYPE_CINT
, 2147483647, 0 },
636 { "Talx4cuint", TYPE_CUINT
, 4294967295U, 0 },
637 { "Talx4clong", TYPE_CINT
, 9223372036854775807LL, 0 },
638 { "Talx4culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
639 { "Talx4cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
640 { "Talx4cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
641 { "Talx4cfloat", TYPE_CFLOAT
, 0, 0 },
642 { "Talx4cdouble", TYPE_CFLOAT
, 0, 0 },
643 { "Talx4cldouble", TYPE_CFLOAT
, 0, 0 },
644 { "Talx8cint", TYPE_CINT
, 2147483647, 0 },
645 { "Talx8cuint", TYPE_CUINT
, 4294967295U, 0 },
646 { "Talx8clong", TYPE_CINT
, 9223372036854775807LL, 0 },
647 { "Talx8culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
648 { "Talx8cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
649 { "Talx8cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
650 { "Talx8cfloat", TYPE_CFLOAT
, 0, 0 },
651 { "Talx8cdouble", TYPE_CFLOAT
, 0, 0 },
652 { "Talx8cldouble", TYPE_CFLOAT
, 0, 0 },
653 { "Taly16clong", TYPE_CINT
, 9223372036854775807LL, 0 },
654 { "Taly16culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
655 { "Talx16cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
656 { "Talx16cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
657 { "Talx16cdouble", TYPE_CFLOAT
, 0, 0 },
658 { "Talx16cldouble", TYPE_CFLOAT
, 0, 0 }
659 #define NCAATYPES2 (sizeof (complex_attrib_array_types) / sizeof (complex_attrib_array_types[0]))
662 struct types bitfld_types
[NTYPES2
];
664 struct types aligned_bitfld_types
[NATYPES2
];
665 int n_aligned_bitfld_types
;
667 const char *attributes
[] = {
688 #define NATTRIBS2 (sizeof (attributes) / sizeof (attributes[0]))
705 enum ETYPE etype
: 8;
710 unsigned char arr_len
;
713 /* Used to chain together entries in the hash table. */
717 /* A prime number giving the number of slots in the hash table. */
718 #define HASH_SIZE 32749
719 static struct entry
*hash_table
[HASH_SIZE
];
721 static int idx
, limidx
, output_one
, short_enums
;
722 static const char *destdir
;
723 static const char *srcdir
;
727 switchfiles (int fields
)
730 static char *destbuf
, *destptr
;
741 size_t len
= strlen (destdir
);
742 destbuf
= malloc (len
+ 20);
745 memcpy (destbuf
, destdir
, len
);
746 if (!len
|| destbuf
[len
- 1] != '/')
747 destbuf
[len
++] = '/';
748 destptr
= destbuf
+ len
;
750 sprintf (destptr
, "t%03d_main.c", filecnt
);
751 outfile
= fopen (destbuf
, "w");
755 fputs ("failed to create test files\n", stderr
);
759 /* { dg-options \"-I%s\" } */\n\
760 /* { dg-options \"-I%s -fno-common\" { target hppa*-*-hpux* } } */\n\
761 /* { dg-options \"-I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
762 #include \"struct-layout-1.h\"\n\
764 #define TX(n, type, attrs, fields, ops) extern void test##n (void);\n\
765 #include \"t%03d_test.h\"\n\
770 #define TX(n, type, attrs, fields, ops) test##n ();\n\
771 #include \"t%03d_test.h\"\n\
779 }\n", srcdir
, srcdir
, srcdir
, filecnt
, filecnt
);
781 sprintf (destptr
, "t%03d_x.c", filecnt
);
782 outfile
= fopen (destbuf
, "w");
786 /* { dg-options \"-w -I%s\" } */\n\
787 /* { dg-options \"-w -I%s -fno-common\" { target hppa*-*-hpux* } } */\n\
788 /* { dg-options \"-w -I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
789 #include \"struct-layout-1_x1.h\"\n\
790 #include \"t%03d_test.h\"\n\
791 #include \"struct-layout-1_x2.h\"\n\
792 #include \"t%03d_test.h\"\n", srcdir
, srcdir
, srcdir
, filecnt
, filecnt
);
794 sprintf (destptr
, "t%03d_y.c", filecnt
);
795 outfile
= fopen (destbuf
, "w");
799 /* { dg-options \"-w -I%s\" } */\n\
800 /* { dg-options \"-w -I%s -fno-common\" { target hppa*-*-hpux* } } */\n\
801 /* { dg-options \"-w -I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
802 #include \"struct-layout-1_y1.h\"\n\
803 #include \"t%03d_test.h\"\n\
804 #include \"struct-layout-1_y2.h\"\n\
805 #include \"t%03d_test.h\"\n", srcdir
, srcdir
, srcdir
, filecnt
, filecnt
);
807 sprintf (destptr
, "t%03d_test.h", filecnt
);
808 outfile
= fopen (destbuf
, "w");
813 else if (fields
<= 4)
815 else if (fields
<= 6)
821 unsigned long long int
824 unsigned long long int ret
;
825 ret
= generate_random () & 0xffffff;
826 ret
|= (generate_random () & 0xffffffLL
) << 24;
827 ret
|= ((unsigned long long int) generate_random ()) << 48;
832 subfield (struct entry
*e
, char *letter
)
841 case ETYPE_STRUCT_ARRAY
:
842 case ETYPE_UNION_ARRAY
:
843 type
= e
[0].attrib
? 1 + (generate_random () & 3) : 0;
844 if (e
[0].etype
== ETYPE_STRUCT
|| e
[0].etype
== ETYPE_STRUCT_ARRAY
)
848 if (e
[0].etype
== ETYPE_STRUCT_ARRAY
|| e
[0].etype
== ETYPE_UNION_ARRAY
)
850 if (e
[0].arr_len
== 255)
851 snprintf (buf
, 20, "%c[]", *letter
);
853 snprintf (buf
, 20, "%c[%d]", *letter
, e
[0].arr_len
);
854 /* If this is an array type, do not put aligned attributes on
855 elements. Aligning elements to a value greater than their
856 size will result in a compiler error. */
858 && ((strncmp (e
[0].attrib
, "atal", 4) == 0)
859 || strncmp (e
[0].attrib
, "atpaal", 6) == 0))
873 fprintf (outfile
, "%s{", p
);
876 fprintf (outfile
, "%s %s{", e
[0].attrib
, p
);
879 fprintf (outfile
, "%s %s{", p
, e
[0].attrib
);
883 for (i
= 1; i
<= e
[0].len
; )
884 i
+= subfield (e
+ i
, letter
);
891 fprintf (outfile
, "}%s;", buf
);
894 fprintf (outfile
, "}%s %s;", e
[0].attrib
, buf
);
897 fprintf (outfile
, "}%s %s;", buf
, e
[0].attrib
);
903 if (e
[0].etype
== ETYPE_ARRAY
)
905 if (e
[0].arr_len
== 255)
906 snprintf (buf
, 20, "%c[]", *letter
);
908 snprintf (buf
, 20, "%c[%d]", *letter
, e
[0].arr_len
);
918 /* If this is an array type, do not put aligned attributes on
919 elements. Aligning elements to a value greater than their
920 size will result in a compiler error. */
921 if (e
[0].etype
== ETYPE_ARRAY
922 && ((strncmp (e
[0].attrib
, "atal", 4) == 0)
923 || strncmp (e
[0].attrib
, "atpaal", 6) == 0))
926 type
= generate_random () % 3;
930 fprintf (outfile
, "%s %s %s;", e
[0].attrib
, e
[0].type
->name
,
934 fprintf (outfile
, "%s %s %s;", e
[0].type
->name
, e
[0].attrib
,
938 fprintf (outfile
, "%s %s %s;", e
[0].type
->name
, buf
,
944 fprintf (outfile
, "%s %s;", e
[0].type
->name
, buf
);
950 switch (generate_random () % 3)
953 fprintf (outfile
, "%s %s:0;", e
[0].attrib
, e
[0].type
->name
);
956 fprintf (outfile
, "%s %s:0;", e
[0].type
->name
, e
[0].attrib
);
959 fprintf (outfile
, "%s:0 %s;", e
[0].type
->name
, e
[0].attrib
);
963 fprintf (outfile
, "%s:0;", e
[0].type
->name
);
967 switch (e
[0].type
->bitfld
)
974 snprintf (buf
, 20, "B%cN(%d)", e
[0].type
->bitfld
, e
[0].len
);
978 snprintf (buf
, 20, "%d", e
[0].len
);
984 switch (generate_random () % 3)
987 fprintf (outfile
, "%s %s %c:%s;", e
[0].attrib
, e
[0].type
->name
,
991 fprintf (outfile
, "%s %s %c:%s;", e
[0].type
->name
, e
[0].attrib
,
995 fprintf (outfile
, "%s %c:%s %s;", e
[0].type
->name
, *letter
,
1000 fprintf (outfile
, "%s %c:%s;", e
[0].type
->name
, *letter
, buf
);
1011 output_FNB (char mode
, struct entry
*e
)
1013 unsigned long long int l1
, l2
, m
;
1015 #ifndef SKIP_DECIMAL_FLOAT
1017 char DEC_SUFFIX
[3][3]={"DF","DD","DL"};
1022 if (e
->type
->type
== TYPE_OTHER
)
1026 fprintf (outfile
, "N(%d,%s)", idx
, namebuf
);
1029 fprintf (outfile
, "%c(%d,%s,", mode
, idx
, namebuf
);
1032 switch (e
->type
->type
)
1035 signs
= generate_random () & 3;
1036 m
= e
->type
->maxval
;
1038 m
&= e
->len
> 1 ? (1ULL << (e
->len
- 1)) - 1 : 1;
1041 fprintf (outfile
, "%s%llu%s,%s%llu%s",
1042 (signs
& 1) ? "-" : "", l1
, l1
> 2147483647 ? "LL" : "",
1043 (signs
& 2) ? "-" : "", l2
, l2
> 2147483647 ? "LL" : "");
1046 m
= e
->type
->maxval
;
1048 m
&= (1ULL << e
->len
) - 1;
1051 fprintf (outfile
, "%lluU%s,%lluU%s", l1
, l1
> 4294967295U ? "LL" : "",
1052 l2
, l2
> 4294967295U ? "LL" : "");
1057 signs
= generate_random () & 3;
1058 fprintf (outfile
, "%s%f,%s%f", (signs
& 1) ? "-" : "",
1059 ((double) l1
) / 64, (signs
& 2) ? "-" : "", ((double) l2
) / 64);
1061 #ifndef SKIP_DECIMAL_FLOAT
1062 case TYPE_DEC_FLOAT
:
1065 signs
= generate_random () & 3;
1067 /* Get the suffix of Decimal Floting Points per
1068 e->type->name. Distinguish these three DFP types by
1070 if (strstr(e
->type
->name
, "Decimal32")) suffix
=0;
1071 else if (strstr(e
->type
->name
, "Decimal64")) suffix
=1;
1072 else if (strstr(e
->type
->name
, "Decimal128")) suffix
=2;
1076 /* Formatted input/output specifiers for DFP types have not been
1077 implemented in GLIBC. %f here used in fprintf is just to
1078 dump the numbers to outfile. */
1079 fprintf (outfile
, "%s%f%s,%s%f%s",
1080 (signs
& 1) ? "-" : "", ((double) l1
) / 64, DEC_SUFFIX
[suffix
],
1081 (signs
& 2) ? "-" : "", ((double) l2
) / 64, DEC_SUFFIX
[suffix
]);
1085 signs
= generate_random () & 3;
1086 l1
&= e
->type
->maxval
;
1087 l2
&= e
->type
->maxval
;
1088 fprintf (outfile
, "CINT(%s%llu%s,%s%llu%s),",
1089 (signs
& 1) ? "-" : "", l1
, l1
> 2147483647 ? "LL" : "",
1090 (signs
& 2) ? "-" : "", l2
, l2
> 2147483647 ? "LL" : "");
1091 signs
= generate_random () & 3;
1094 l1
&= e
->type
->maxval
;
1095 l2
&= e
->type
->maxval
;
1096 fprintf (outfile
, "CINT(%s%llu%s,%s%llu%s)",
1097 (signs
& 1) ? "-" : "", l1
, l1
> 2147483647 ? "LL" : "",
1098 (signs
& 2) ? "-" : "", l2
, l2
> 2147483647 ? "LL" : "");
1101 l1
&= e
->type
->maxval
;
1102 l2
&= e
->type
->maxval
;
1103 fprintf (outfile
, "CINT(%lluU%s,%lluU%s),",
1104 l1
, l1
> 4294967295U ? "LL" : "",
1105 l2
, l2
> 4294967295U ? "LL" : "");
1108 l1
&= e
->type
->maxval
;
1109 l2
&= e
->type
->maxval
;
1110 fprintf (outfile
, "CINT(%lluU%s,%lluU%s)",
1111 l1
, l1
> 4294967295U ? "LL" : "",
1112 l2
, l2
> 4294967295U ? "LL" : "");
1117 signs
= generate_random () & 3;
1118 fprintf (outfile
, "CDBL(%s%f,%s%f),",
1119 (signs
& 1) ? "-" : "", ((double) l1
) / 64,
1120 (signs
& 2) ? "-" : "", ((double) l2
) / 64);
1125 signs
= generate_random () & 3;
1126 fprintf (outfile
, "CDBL(%s%f,%s%f)",
1127 (signs
& 1) ? "-" : "", ((double) l1
) / 64,
1128 (signs
& 2) ? "-" : "", ((double) l2
) / 64);
1131 if (e
->type
->maxval
== 0)
1132 fputs ("e0_0,e0_0", outfile
);
1133 else if (e
->type
->maxval
== 1)
1134 fprintf (outfile
, "e1_%lld,e1_%lld", l1
& 1, l2
& 1);
1137 p
= strchr (e
->type
->name
, '\0');
1138 while (--p
>= e
->type
->name
&& *p
>= '0' && *p
<= '9');
1143 l1
+= e
->type
->maxval
- 6;
1145 l2
+= e
->type
->maxval
- 6;
1146 fprintf (outfile
, "e%s_%lld,e%s_%lld", p
, l1
, p
, l2
);
1150 p
= strchr (e
->type
->name
, '\0');
1151 while (--p
>= e
->type
->name
&& *p
>= '0' && *p
<= '9');
1155 fprintf (outfile
, "e%s_%s%lld,e%s_%s%lld",
1156 p
, l1
< 3 ? "m" : "",
1157 l1
== 3 ? 0LL : e
->type
->maxval
- (l1
& 3),
1158 p
, l2
< 3 ? "m" : "",
1159 l2
== 3 ? 0LL : e
->type
->maxval
- (l2
& 3));
1164 fprintf (outfile
, "(%s)&intarray[%lld],(%s)&intarray[%lld]",
1165 e
->type
->name
, l1
, e
->type
->name
, l2
);
1170 fprintf (outfile
, "fn%lld,fn%lld", l1
, l2
);
1175 fputs (")", outfile
);
1179 subvalues (struct entry
*e
, char *p
, char *letter
)
1183 if (p
>= namebuf
+ sizeof (namebuf
) - 32)
1190 case ETYPE_STRUCT_ARRAY
:
1191 case ETYPE_UNION_ARRAY
:
1192 if (e
[0].arr_len
== 0 || e
[0].arr_len
== 255)
1194 *letter
+= 1 + e
[0].len
;
1195 return 1 + e
[0].len
;
1197 i
= generate_random () % e
[0].arr_len
;
1198 snprintf (p
, sizeof (namebuf
) - (p
- namebuf
) - 1,
1199 "%c[%d]", *letter
, i
);
1200 q
= strchr (p
, '\0');
1206 for (i
= 1; i
<= e
[0].len
; )
1208 i
+= subvalues (e
+ i
, q
, letter
);
1209 if (e
[0].etype
== ETYPE_UNION
|| e
[0].etype
== ETYPE_UNION_ARRAY
)
1211 *letter
+= e
[0].len
- i
+ 1;
1215 return 1 + e
[0].len
;
1218 output_FNB ('F', e
);
1221 if (e
[0].arr_len
== 0 || e
[0].arr_len
== 255)
1226 i
= generate_random () % e
[0].arr_len
;
1227 snprintf (p
, sizeof (namebuf
) - (p
- namebuf
),
1228 "%c[%d]", *letter
, i
);
1229 output_FNB ('F', e
);
1230 if ((generate_random () & 7) == 0)
1232 j
= generate_random () % e
[0].arr_len
;
1235 snprintf (p
, sizeof (namebuf
) - (p
- namebuf
),
1236 "%c[%d]", *letter
, j
);
1237 output_FNB ('F', e
);
1245 output_FNB ('B', e
);
1251 --------------------------------------------------------------------
1252 lookup2.c, by Bob Jenkins, December 1996, Public Domain.
1253 hash(), hash2(), hash3, and mix() are externally useful functions.
1254 Routines to test the hash are included if SELF_TEST is defined.
1255 You can use this free for any purpose. It has no warranty.
1256 --------------------------------------------------------------------
1260 --------------------------------------------------------------------
1261 mix -- mix 3 32-bit values reversibly.
1262 For every delta with one or two bit set, and the deltas of all three
1263 high bits or all three low bits, whether the original value of a,b,c
1264 is almost all zero or is uniformly distributed,
1265 * If mix() is run forward or backward, at least 32 bits in a,b,c
1266 have at least 1/4 probability of changing.
1267 * If mix() is run forward, every bit of c will change between 1/3 and
1268 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.)
1269 mix() was built out of 36 single-cycle latency instructions in a
1270 structure that could supported 2x parallelism, like so:
1272 a -= c; x = (c>>13);
1276 c -= b; x = (b>>13);
1278 Unfortunately, superscalar Pentiums and Sparcs can't take advantage
1279 of that parallelism. They've also turned some of those single-cycle
1280 latency instructions into multi-cycle latency instructions. Still,
1281 this is the fastest good hash I could find. There were about 2^^68
1282 to choose from. I only looked at a billion or so.
1283 --------------------------------------------------------------------
1285 /* same, but slower, works on systems that might have 8 byte hashval_t's */
1286 #define mix(a,b,c) \
1288 a -= b; a -= c; a ^= (c>>13); \
1289 b -= c; b -= a; b ^= (a<< 8); \
1290 c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \
1291 a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \
1292 b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \
1293 c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \
1294 a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \
1295 b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \
1296 c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \
1300 --------------------------------------------------------------------
1301 hash() -- hash a variable-length key into a 32-bit value
1302 k : the key (the unaligned variable-length array of bytes)
1303 len : the length of the key, counting by bytes
1304 level : can be any 4-byte value
1305 Returns a 32-bit value. Every bit of the key affects every bit of
1306 the return value. Every 1-bit and 2-bit delta achieves avalanche.
1307 About 36+6len instructions.
1309 The best hash table sizes are powers of 2. There is no need to do
1310 mod a prime (mod is sooo slow!). If you need less than 32 bits,
1311 use a bitmask. For example, if you need only 10 bits, do
1312 h = (h & hashmask(10));
1313 In which case, the hash table should have hashsize(10) elements.
1315 If you are hashing n strings (ub1 **)k, do it like this:
1316 for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
1318 By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this
1319 code any way you wish, private, educational, or commercial. It's free.
1321 See http://burtleburtle.net/bob/hash/evahash.html
1322 Use for hash table lookup, or anything where one collision in 2^32 is
1323 acceptable. Do NOT use for cryptographic purposes.
1324 --------------------------------------------------------------------
1328 iterative_hash (const void *k_in
/* the key */,
1329 register size_t length
/* the length of the key */,
1330 register hashval_t initval
/* the previous hash, or
1331 an arbitrary value */)
1333 register const unsigned char *k
= (const unsigned char *)k_in
;
1334 register hashval_t a
,b
,c
,len
;
1336 /* Set up the internal state */
1338 a
= b
= 0x9e3779b9; /* the golden ratio; an arbitrary value */
1339 c
= initval
; /* the previous hash value */
1341 /*---------------------------------------- handle most of the key */
1344 a
+= (k
[0] +((hashval_t
)k
[1]<<8) +((hashval_t
)k
[2]<<16) +((hashval_t
)k
[3]<<24));
1345 b
+= (k
[4] +((hashval_t
)k
[5]<<8) +((hashval_t
)k
[6]<<16) +((hashval_t
)k
[7]<<24));
1346 c
+= (k
[8] +((hashval_t
)k
[9]<<8) +((hashval_t
)k
[10]<<16)+((hashval_t
)k
[11]<<24));
1351 /*------------------------------------- handle the last 11 bytes */
1353 switch(len
) /* all the case statements fall through */
1355 case 11: c
+=((hashval_t
)k
[10]<<24);
1356 case 10: c
+=((hashval_t
)k
[9]<<16);
1357 case 9 : c
+=((hashval_t
)k
[8]<<8);
1358 /* the first byte of c is reserved for the length */
1359 case 8 : b
+=((hashval_t
)k
[7]<<24);
1360 case 7 : b
+=((hashval_t
)k
[6]<<16);
1361 case 6 : b
+=((hashval_t
)k
[5]<<8);
1363 case 4 : a
+=((hashval_t
)k
[3]<<24);
1364 case 3 : a
+=((hashval_t
)k
[2]<<16);
1365 case 2 : a
+=((hashval_t
)k
[1]<<8);
1367 /* case 0: nothing left to add */
1370 /*-------------------------------------------- report the result */
1375 e_hash (const void *a
)
1377 const struct entry
*e
= a
;
1381 if (e
[0].etype
!= ETYPE_STRUCT
&& e
[0].etype
!= ETYPE_UNION
)
1383 for (i
= 0; i
<= e
[0].len
; ++i
)
1386 ret
= iterative_hash (&e
[i
], offsetof (struct entry
, attrib
), ret
);
1387 attriblen
= e
[i
].attrib
? strlen (e
[i
].attrib
) : -1;
1388 ret
= iterative_hash (&attriblen
, sizeof (int), ret
);
1390 ret
= iterative_hash (e
[i
].attrib
, attriblen
, ret
);
1396 e_eq (const void *a
, const void *b
)
1398 const struct entry
*ea
= a
, *eb
= b
;
1400 if (ea
[0].etype
!= ETYPE_STRUCT
&& ea
[0].etype
!= ETYPE_UNION
)
1402 if (ea
[0].len
!= eb
[0].len
)
1404 for (i
= 0; i
<= ea
[0].len
; ++i
)
1406 if (ea
[i
].etype
!= eb
[i
].etype
1407 || ea
[i
].len
!= eb
[i
].len
1408 || ea
[i
].arr_len
!= eb
[i
].arr_len
1409 || ea
[i
].type
!= eb
[i
].type
)
1411 if ((ea
[i
].attrib
== NULL
) ^ (eb
[i
].attrib
== NULL
))
1413 if (ea
[i
].attrib
&& strcmp (ea
[i
].attrib
, eb
[i
].attrib
) != 0)
1420 e_exists (const struct entry
*e
)
1426 for (h
= hash_table
[hval
% HASH_SIZE
]; h
; h
= h
->next
)
1433 e_insert (struct entry
*e
)
1438 e
->next
= hash_table
[hval
% HASH_SIZE
];
1439 hash_table
[hval
% HASH_SIZE
] = e
;
1443 output (struct entry
*e
)
1448 const char *skip_cint
= "";
1450 if (e
[0].etype
!= ETYPE_STRUCT
&& e
[0].etype
!= ETYPE_UNION
)
1456 n
= (struct entry
*) malloc ((e
[0].len
+ 1) * sizeof (struct entry
));
1457 memcpy (n
, e
, (e
[0].len
+ 1) * sizeof (struct entry
));
1461 switchfiles (e
[0].len
);
1463 for (i
= 1; i
<= e
[0].len
; ++i
)
1464 if ((e
[i
].etype
== ETYPE_TYPE
|| e
[i
].etype
== ETYPE_ARRAY
)
1465 && (e
[i
].type
->type
== TYPE_CINT
|| e
[i
].type
->type
== TYPE_CUINT
))
1470 fprintf (outfile
, (generate_random () & 1)
1471 ? "TX%s(%d,%s %s,," : "TX%s(%d,%s,%s,", skip_cint
,
1472 idx
, e
[0].etype
== ETYPE_STRUCT
? "struct" : "union",
1474 else if (e
[0].etype
== ETYPE_STRUCT
)
1475 fprintf (outfile
, "T%s(%d,", skip_cint
, idx
);
1477 fprintf (outfile
, "U%s(%d,", skip_cint
, idx
);
1479 for (i
= 1; i
<= e
[0].len
; )
1480 i
+= subfield (e
+ i
, &c
);
1481 fputs (",", outfile
);
1483 for (i
= 1; i
<= e
[0].len
; )
1485 i
+= subvalues (e
+ i
, namebuf
, &c
);
1486 if (e
[0].etype
== ETYPE_UNION
)
1489 fputs (")\n", outfile
);
1490 if (output_one
&& idx
== limidx
)
1498 FEATURE_COMPLEX
= 2,
1499 FEATURE_ALIGNEDPACKED
= 4,
1500 FEATURE_ZEROARRAY
= 8,
1501 FEATURE_ZEROBITFLD
= 16,
1502 ALL_FEATURES
= FEATURE_COMPLEX
| FEATURE_VECTOR
| FEATURE_ZEROARRAY
1503 | FEATURE_ALIGNEDPACKED
| FEATURE_ZEROBITFLD
1507 singles (enum FEATURE features
)
1511 memset (e
, 0, sizeof (e
));
1512 e
[0].etype
= ETYPE_STRUCT
;
1514 e
[0].etype
= ETYPE_UNION
;
1517 i
< ((features
& FEATURE_ALIGNEDPACKED
) ? NATTRIBS2
: NATTRIBS1
);
1520 e
[0].attrib
= attributes
[i
];
1521 e
[0].etype
= ETYPE_STRUCT
;
1523 e
[0].etype
= ETYPE_UNION
;
1528 for (i
= 0; i
< NTYPES2
; ++i
)
1530 e
[0].etype
= ETYPE_STRUCT
;
1531 e
[1].etype
= ETYPE_TYPE
;
1532 e
[1].type
= &base_types
[i
];
1534 e
[0].etype
= ETYPE_UNION
;
1537 if (features
& FEATURE_COMPLEX
)
1538 for (i
= 0; i
< NCTYPES2
; ++i
)
1540 e
[0].etype
= ETYPE_STRUCT
;
1541 e
[1].etype
= ETYPE_TYPE
;
1542 e
[1].type
= &complex_types
[i
];
1544 e
[0].etype
= ETYPE_UNION
;
1547 if (features
& FEATURE_VECTOR
)
1548 for (i
= 0; i
< NVTYPES2
; ++i
)
1550 e
[0].etype
= ETYPE_STRUCT
;
1551 e
[1].etype
= ETYPE_TYPE
;
1552 e
[1].type
= &vector_types
[i
];
1554 e
[0].etype
= ETYPE_UNION
;
1560 choose_type (enum FEATURE features
, struct entry
*e
, int r
, int in_array
)
1564 i
= NTYPES2
- NTYPES1
;
1565 if (features
& FEATURE_COMPLEX
)
1567 if (features
& FEATURE_VECTOR
)
1574 if (features
& FEATURE_COMPLEX
)
1580 if (features
& FEATURE_COMPLEX
)
1586 if (r
< NTYPES2
- NTYPES1
)
1587 e
->type
= &base_types
[r
+ NTYPES1
];
1588 r
-= NTYPES2
- NTYPES1
;
1589 if (e
->type
== NULL
&& (features
& FEATURE_COMPLEX
))
1592 e
->type
= &complex_types
[r
];
1595 if (e
->type
== NULL
&& (features
& FEATURE_VECTOR
))
1598 e
->type
= &vector_types
[r
];
1601 if (e
->type
== NULL
&& !in_array
)
1604 e
->type
= &attrib_types
[r
];
1607 if (e
->type
== NULL
&& !in_array
&& (features
& FEATURE_COMPLEX
))
1610 e
->type
= &complex_attrib_types
[r
];
1613 if (e
->type
== NULL
&& in_array
)
1616 e
->type
= &attrib_array_types
[r
];
1619 if (e
->type
== NULL
&& in_array
&& (features
& FEATURE_COMPLEX
))
1622 e
->type
= &complex_attrib_array_types
[r
];
1625 if (e
->type
== NULL
)
1629 /* This is from gcc.c-torture/execute/builtin-bitops-1.c. */
1631 my_ffsll (unsigned long long x
)
1636 /* We've tested LLONG_MAX for 64 bits so this should be safe. */
1637 for (i
= 0; i
< 64; i
++)
1638 if (x
& (1ULL << i
))
1644 generate_fields (enum FEATURE features
, struct entry
*e
, struct entry
*parent
,
1647 int r
, i
, j
, ret
= 1, n
, incr
, sametype
;
1649 for (n
= 0; n
< len
; n
+= incr
)
1651 r
= generate_random ();
1652 /* 50% ETYPE_TYPE base_types NTYPES1
1653 12.5% ETYPE_TYPE other
1656 12.5% ETYPE_STRUCT|ETYPE_UNION|ETYPE_STRUCT_ARRAY|ETYPE_UNION_ARRAY */
1666 e
[n
].etype
= ETYPE_TYPE
;
1667 e
[n
].type
= &base_types
[r
% NTYPES1
];
1670 e
[n
].etype
= ETYPE_TYPE
;
1671 choose_type (features
, &e
[n
], r
, 0);
1674 e
[n
].etype
= ETYPE_ARRAY
;
1678 e
[n
].type
= &base_types
[r
% NTYPES1
];
1680 choose_type (features
, &e
[n
], r
, 1);
1681 r
= generate_random ();
1682 if ((features
& FEATURE_ZEROARRAY
) && (r
& 3) == 0)
1685 if (n
== len
- 1 && (r
& 4)
1686 && (parent
->etype
== ETYPE_STRUCT
1687 || parent
->etype
== ETYPE_STRUCT_ARRAY
))
1690 for (k
= 0; k
< n
; ++k
)
1691 if (e
[k
].etype
!= ETYPE_BITFLD
|| e
[k
].len
)
1698 else if ((r
& 3) != 3)
1699 e
[n
].arr_len
= (r
>> 2) & 7;
1701 e
[n
].arr_len
= (r
>> 2) & 31;
1714 incr
= 1 + (r
>> 3) % (len
- n
);
1719 incr
= 1 + (r
>> 3) % (len
- n
);
1722 for (j
= n
; j
< n
+ incr
; ++j
)
1726 e
[j
].etype
= ETYPE_BITFLD
;
1727 if (j
== n
|| !sametype
)
1730 r
= generate_random ();
1735 = &aligned_bitfld_types
[r
% n_aligned_bitfld_types
];
1738 = &bitfld_types
[r
% n_bitfld_types
];
1741 e
[j
].type
= e
[n
].type
;
1742 r
= generate_random ();
1745 switch (e
[j
].type
->bitfld
)
1747 case 'C': ma
= 8; break;
1748 case 'S': ma
= 16; break;
1749 case 'I': ma
= 32; break;
1751 case 'Q': ma
= 64; break;
1752 case 'B': ma
= 1; break;
1754 if (e
[j
].type
->type
== TYPE_UENUM
)
1755 mi
= my_ffsll (e
[j
].type
->maxval
+ 1) - 1;
1756 else if (e
[j
].type
->type
== TYPE_SENUM
)
1757 mi
= my_ffsll (e
[j
].type
->maxval
+ 1);
1764 else if (mi
> 16 || !short_enums
)
1775 if (sametype
&& (r
& 3) == 0 && ma
> 1)
1778 for (k
= n
; k
< j
; ++k
)
1781 e
[j
].len
= sum
? ma
- sum
: ma
;
1784 if (! (features
& FEATURE_ZEROBITFLD
) && mi
== 0)
1786 if (e
[j
].len
< mi
|| e
[j
].len
> ma
)
1787 e
[j
].len
= mi
+ (r
% (ma
+ 1 - mi
));
1789 if ((features
& FEATURE_ZEROBITFLD
) && (r
& 3) == 0
1800 e
[n
].etype
= ETYPE_STRUCT
;
1804 e
[n
].etype
= ETYPE_UNION
;
1808 e
[n
].etype
= ETYPE_STRUCT_ARRAY
;
1811 e
[n
].etype
= ETYPE_UNION_ARRAY
;
1815 e
[n
].len
= r
% (len
- n
);
1816 incr
= 1 + e
[n
].len
;
1817 generate_fields (features
, &e
[n
+ 1], &e
[n
], e
[n
].len
);
1818 if (e
[n
].etype
== ETYPE_STRUCT_ARRAY
1819 || e
[n
].etype
== ETYPE_UNION_ARRAY
)
1821 r
= generate_random ();
1822 if ((features
& FEATURE_ZEROARRAY
) && (r
& 3) == 0)
1825 if (n
+ incr
== len
&& (r
& 4)
1826 && (parent
->etype
== ETYPE_STRUCT
1827 || parent
->etype
== ETYPE_STRUCT_ARRAY
))
1830 for (k
= 0; k
< n
; ++k
)
1831 if (e
[k
].etype
!= ETYPE_BITFLD
|| e
[k
].len
)
1838 else if ((r
& 3) != 3)
1839 e
[n
].arr_len
= (r
>> 2) & 7;
1841 e
[n
].arr_len
= (r
>> 2) & 31;
1845 r
= generate_random ();
1849 i
= (features
& FEATURE_ALIGNEDPACKED
) ? NATTRIBS2
: NATTRIBS1
;
1850 e
[n
].attrib
= attributes
[r
% i
];
1851 if (! (features
& FEATURE_ALIGNEDPACKED
)
1852 && strcmp (e
[n
].attrib
, "atpa") == 0
1853 && ((e
[n
].type
>= &attrib_types
[0]
1854 && e
[n
].type
< &attrib_types
[NATYPES2
])
1855 || (e
[n
].type
>= &complex_attrib_types
[0]
1856 && e
[n
].type
< &complex_attrib_types
[NCATYPES2
])
1857 || (e
[n
].type
>= &attrib_array_types
[0]
1858 && e
[n
].type
< &attrib_array_types
[NAATYPES2
])
1859 || (e
[n
].type
>= &complex_attrib_array_types
[0]
1860 && e
[n
].type
< &complex_attrib_array_types
[NAATYPES2
])
1861 || (e
[n
].type
>= &aligned_bitfld_types
[0]
1862 && e
[n
].type
< &aligned_bitfld_types
[n_aligned_bitfld_types
])))
1869 generate_random_tests (enum FEATURE features
, int len
)
1871 struct entry e
[len
+ 1];
1873 if (len
> 'z' - 'a' + 1)
1875 memset (e
, 0, sizeof (e
));
1876 r
= generate_random ();
1878 e
[0].etype
= ETYPE_UNION
;
1880 e
[0].etype
= ETYPE_STRUCT
;
1886 if (features
& FEATURE_ALIGNEDPACKED
)
1890 e
[0].attrib
= attributes
[r
];
1892 generate_fields (features
, &e
[1], &e
[0], len
);
1896 struct { const char *name
; enum FEATURE f
; }
1899 { "complex", FEATURE_COMPLEX
},
1900 { "vector", FEATURE_VECTOR
},
1901 { "[0] :0", FEATURE_ZEROARRAY
| FEATURE_ZEROBITFLD
},
1902 { "complex vector [0]",
1903 FEATURE_COMPLEX
| FEATURE_VECTOR
| FEATURE_ZEROARRAY
},
1904 { "aligned packed complex vector [0] :0",
1905 FEATURE_COMPLEX
| FEATURE_VECTOR
| FEATURE_ZEROARRAY
1906 | FEATURE_ALIGNEDPACKED
| FEATURE_ZEROBITFLD
},
1910 main (int argc
, char **argv
)
1912 int i
, j
, count
, c
, n
= 3000;
1915 if (sizeof (int) != 4 || sizeof (long long) != 8)
1922 if (argv
[i
][0] == '-' && argv
[i
][2] == '\0')
1924 optarg
= argv
[i
+ 1];
1940 limidx
= atoi (optarg
);
1947 fprintf (stderr
, "unrecognized option %s\n", argv
[i
]);
1955 outfile
= fopen ("/dev/null", "w");
1956 if (outfile
== NULL
)
1958 fputs ("could not open /dev/null", stderr
);
1964 if (destdir
== NULL
&& !output_one
)
1967 fprintf (stderr
, "Usage:\n\
1968 %s [-e] [-s srcdir -d destdir] [-n count] [-i idx]\n\
1969 Either -s srcdir -d destdir or -i idx must be used\n", argv
[0]);
1973 if (srcdir
== NULL
&& !output_one
)
1976 for (i
= 0; i
< NTYPES2
; ++i
)
1977 if (base_types
[i
].bitfld
)
1978 bitfld_types
[n_bitfld_types
++] = base_types
[i
];
1979 for (i
= 0; i
< NATYPES2
; ++i
)
1980 if (attrib_types
[i
].bitfld
)
1981 aligned_bitfld_types
[n_aligned_bitfld_types
++] = attrib_types
[i
];
1982 for (i
= 0; i
< sizeof (features
) / sizeof (features
[0]); ++i
)
1991 for (j
= 1; j
<= 9; ++j
)
1992 while (idx
< startidx
+ j
* count
)
1993 generate_random_tests (features
[i
].f
, j
);
1994 while (idx
< startidx
+ count
* 10)
1995 generate_random_tests (features
[i
].f
, 10 + (generate_random () % 16));
1997 for (i
= 0; n
> 3000 && i
< sizeof (features
) / sizeof (features
[0]); ++i
)
2003 singles (features
[i
].f
);
2007 while (idx
< startidx
+ 1000)
2008 generate_random_tests (features
[i
].f
, 1);
2014 while (idx
< startidx
+ 100)
2015 generate_random_tests (features
[i
].f
, 1);
2018 for (j
= 2; j
<= 9; ++j
)
2019 while (idx
< startidx
+ (j
- 1) * count
)
2020 generate_random_tests (features
[i
].f
, j
);
2021 while (idx
< startidx
+ count
* 9)
2022 generate_random_tests (features
[i
].f
, 10 + (generate_random () % 16));
2027 generate_random_tests (ALL_FEATURES
, 1 + (generate_random () % 25));