1 /* Structure layout test generator.
2 Copyright (C) 2004, 2005, 2007 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 3, 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 COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
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 #if defined __MSVCRT__
40 #define COMPAT_PRLL "I64"
42 #define COMPAT_PRLL "ll"
45 typedef unsigned int hashval_t
;
67 unsigned long long int maxval
;
71 struct types base_types
[] = {
72 /* As we don't know whether char will be signed or not, just limit ourselves
73 to unsigned values less than maximum signed char value. */
74 { "char", TYPE_UINT
, 127, 'C' },
75 { "signed char", TYPE_INT
, 127, 'C' },
76 { "unsigned char", TYPE_UINT
, 255, 'C' },
77 { "short int", TYPE_INT
, 32767, 'S' },
78 { "unsigned short int", TYPE_UINT
, 65535, 'S' },
79 { "int", TYPE_INT
, 2147483647, 'I' },
80 { "unsigned int", TYPE_UINT
, 4294967295U, 'I' },
81 { "long int", TYPE_INT
, 9223372036854775807LL, 'L' },
82 { "unsigned long int", TYPE_UINT
, 18446744073709551615ULL, 'L' },
83 { "long long int", TYPE_INT
, 9223372036854775807LL, 'Q' },
84 { "unsigned long long int", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
85 { "bool", TYPE_UINT
, 1, 'B' },
86 { "void *", TYPE_PTR
, 0, 0 },
87 { "char *", TYPE_PTR
, 0, 0 },
88 { "int *", TYPE_PTR
, 0, 0 },
89 { "float", TYPE_FLOAT
, 0, 0 },
90 { "double", TYPE_FLOAT
, 0, 0 },
91 { "long double", TYPE_FLOAT
, 0, 0 },
92 #ifndef SKIP_DECIMAL_FLOAT
93 { "_Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
94 { "_Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
95 { "_Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
100 { "Tchar", TYPE_UINT
, 127, 'C' },
101 { "Tschar", TYPE_INT
, 127, 'C' },
102 { "Tuchar", TYPE_UINT
, 255, 'C' },
103 { "Tshort", TYPE_INT
, 32767, 'S' },
104 { "Tushort", TYPE_UINT
, 65535, 'S' },
105 { "Tint", TYPE_INT
, 2147483647, 'I' },
106 { "Tuint", TYPE_UINT
, 4294967295U, 'I' },
107 { "Tlong", TYPE_INT
, 9223372036854775807LL, 'L' },
108 { "Tulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
109 { "Tllong", TYPE_INT
, 9223372036854775807LL, 'Q' },
110 { "Tullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
111 { "Tbool", TYPE_UINT
, 1, 'B' },
112 { "size_t", TYPE_UINT
, 18446744073709551615ULL, 0 },
113 { "Tptr", TYPE_PTR
, 0, 0 },
114 { "Tcptr", TYPE_PTR
, 0, 0 },
115 { "Tiptr", TYPE_PTR
, 0, 0 },
116 { "Tfnptr", TYPE_FNPTR
, 0, 0 },
117 { "Tfloat", TYPE_FLOAT
, 0, 0 },
118 { "Tdouble", TYPE_FLOAT
, 0, 0 },
119 { "Tldouble", TYPE_FLOAT
, 0, 0 },
120 #ifndef SKIP_DECIMAL_FLOAT
121 { "TDecimal32", TYPE_DEC_FLOAT
, 0, 0 },
122 { "TDecimal64", TYPE_DEC_FLOAT
, 0, 0 },
123 { "TDecimal128", TYPE_DEC_FLOAT
, 0, 0 },
125 { "enum E0", TYPE_UENUM
, 0, ' ' },
126 { "enum E1", TYPE_UENUM
, 1, ' ' },
127 { "enum E2", TYPE_SENUM
, 3, ' ' },
128 { "enum E3", TYPE_SENUM
, 127, ' ' },
129 { "enum E4", TYPE_UENUM
, 255, ' ' },
130 { "enum E5", TYPE_SENUM
, 32767, ' ' },
131 { "enum E6", TYPE_UENUM
, 65535, ' ' },
132 { "enum E7", TYPE_SENUM
, 2147483647, ' ' },
133 { "enum E8", TYPE_UENUM
, 4294967295U, ' ' },
134 { "enum E9", TYPE_SENUM
, 1099511627775LL, ' ' },
135 { "TE0", TYPE_UENUM
, 0, ' ' },
136 { "TE1", TYPE_UENUM
, 1, ' ' },
137 { "TE2", TYPE_SENUM
, 3, ' ' },
138 { "TE3", TYPE_SENUM
, 127, ' ' },
139 { "TE4", TYPE_UENUM
, 255, ' ' },
140 { "TE5", TYPE_SENUM
, 32767, ' ' },
141 { "TE6", TYPE_UENUM
, 65535, ' ' },
142 { "TE7", TYPE_SENUM
, 2147483647, ' ' },
143 { "TE8", TYPE_UENUM
, 4294967295U, ' ' },
144 { "TE9", TYPE_SENUM
, 1099511627775LL, ' ' },
145 /* vector-defs.h typedefs */
146 { "qi", TYPE_INT
, 127, 0 },
147 { "hi", TYPE_INT
, 32767, 0 },
148 { "si", TYPE_INT
, 2147483647, 0 },
149 { "di", TYPE_INT
, 9223372036854775807LL, 0 },
150 { "sf", TYPE_FLOAT
, 0, 0 },
151 { "df", TYPE_FLOAT
, 0, 0 }
152 #define NTYPES2 (sizeof (base_types) / sizeof (base_types[0]))
154 struct types complex_types
[] = {
155 { "_Complex char", TYPE_CUINT
, 127, 0 },
156 { "_Complex signed char", TYPE_CINT
, 127, 0 },
157 { "_Complex unsigned char", TYPE_CUINT
, 255, 0 },
158 { "_Complex short int", TYPE_CINT
, 32767, 0 },
159 { "_Complex unsigned short int", TYPE_CUINT
, 65535, 0 },
160 { "_Complex int", TYPE_CINT
, 2147483647, 0 },
161 { "_Complex unsigned int", TYPE_CUINT
, 4294967295U, 0 },
162 { "_Complex long int", TYPE_CINT
, 9223372036854775807LL, 0 },
163 { "_Complex unsigned long int", TYPE_CUINT
, 18446744073709551615ULL, 0 },
164 { "_Complex long long int", TYPE_CINT
, 9223372036854775807LL, 0 },
165 { "_Complex unsigned long long int", TYPE_CUINT
, 18446744073709551615ULL, 0 },
166 { "_Complex float", TYPE_CFLOAT
, 0, 0 },
167 { "_Complex double", TYPE_CFLOAT
, 0, 0 },
168 { "_Complex long double", TYPE_CFLOAT
, 0, 0 },
169 { "Tcchar", TYPE_CUINT
, 127, 0 },
170 { "Tcschar", TYPE_CINT
, 127, 0 },
171 { "Tcuchar", TYPE_CUINT
, 255, 0 },
172 { "Tcshort", TYPE_CINT
, 32767, 0 },
173 { "Tcushort", TYPE_CUINT
, 65535, 0 },
174 { "Tcint", TYPE_CINT
, 2147483647, 0 },
175 { "Tcuint", TYPE_CUINT
, 4294967295U, 0 },
176 { "Tclong", TYPE_CINT
, 9223372036854775807LL, 0 },
177 { "Tculong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
178 { "Tcllong", TYPE_CINT
, 9223372036854775807LL, 0 },
179 { "Tcullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
180 { "Tcfloat", TYPE_CFLOAT
, 0, 0 },
181 { "Tcdouble", TYPE_CFLOAT
, 0, 0 },
182 { "Tcldouble", TYPE_CFLOAT
, 0, 0 }
183 #define NCTYPES2 (sizeof (complex_types) / sizeof (complex_types[0]))
185 struct types vector_types
[] = {
186 /* vector-defs.h typedefs */
187 { "v8qi", TYPE_OTHER
, 0, 0 },
188 { "v16qi", TYPE_OTHER
, 0, 0 },
189 { "v2hi", TYPE_OTHER
, 0, 0 },
190 { "v4hi", TYPE_OTHER
, 0, 0 },
191 { "v8hi", TYPE_OTHER
, 0, 0 },
192 { "v2si", TYPE_OTHER
, 0, 0 },
193 { "v4si", TYPE_OTHER
, 0, 0 },
194 { "v1di", TYPE_OTHER
, 0, 0 },
195 { "v2di", TYPE_OTHER
, 0, 0 },
196 { "v2sf", TYPE_OTHER
, 0, 0 },
197 { "v4sf", TYPE_OTHER
, 0, 0 },
198 { "v16sf", TYPE_OTHER
, 0, 0 },
199 { "v2df", TYPE_OTHER
, 0, 0 },
200 { "u8qi", TYPE_OTHER
, 0, 0 },
201 { "u16qi", TYPE_OTHER
, 0, 0 },
202 { "u2hi", TYPE_OTHER
, 0, 0 },
203 { "u4hi", TYPE_OTHER
, 0, 0 },
204 { "u8hi", TYPE_OTHER
, 0, 0 },
205 { "u2si", TYPE_OTHER
, 0, 0 },
206 { "u4si", TYPE_OTHER
, 0, 0 },
207 { "u1di", TYPE_OTHER
, 0, 0 },
208 { "u2di", TYPE_OTHER
, 0, 0 },
209 { "u2sf", TYPE_OTHER
, 0, 0 },
210 { "u4sf", TYPE_OTHER
, 0, 0 },
211 { "u16sf", TYPE_OTHER
, 0, 0 },
212 { "u2df", TYPE_OTHER
, 0, 0 },
213 { "__m64", TYPE_OTHER
, 0, 0 },
214 { "__m128", TYPE_OTHER
, 0, 0 }
215 #define NVTYPES2 (sizeof (vector_types) / sizeof (vector_types[0]))
217 struct types attrib_types
[] = {
218 { "Talchar", TYPE_UINT
, 127, 'C' },
219 { "Talschar", TYPE_INT
, 127, 'C' },
220 { "Taluchar", TYPE_UINT
, 255, 'C' },
221 { "Talshort", TYPE_INT
, 32767, 'S' },
222 { "Talushort", TYPE_UINT
, 65535, 'S' },
223 { "Talint", TYPE_INT
, 2147483647, 'I' },
224 { "Taluint", TYPE_UINT
, 4294967295U, 'I' },
225 { "Tallong", TYPE_INT
, 9223372036854775807LL, 'L' },
226 { "Talulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
227 { "Talllong", TYPE_INT
, 9223372036854775807LL, 'Q' },
228 { "Talullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
229 { "Talbool", TYPE_UINT
, 1, 'B' },
230 { "Talptr", TYPE_PTR
, 0, 0 },
231 { "Talcptr", TYPE_PTR
, 0, 0 },
232 { "Taliptr", TYPE_PTR
, 0, 0 },
233 { "Talfloat", TYPE_FLOAT
, 0, 0 },
234 { "Taldouble", TYPE_FLOAT
, 0, 0 },
235 { "Talldouble", TYPE_FLOAT
, 0, 0 },
236 #ifndef SKIP_DECIMAL_FLOAT
237 { "TalDecimal32", TYPE_DEC_FLOAT
, 0, 0 },
238 { "TalDecimal64", TYPE_DEC_FLOAT
, 0, 0 },
239 { "TalDecimal128", TYPE_DEC_FLOAT
, 0, 0 },
241 { "TalE0", TYPE_UENUM
, 0, ' ' },
242 { "TalE1", TYPE_UENUM
, 1, ' ' },
243 { "TalE2", TYPE_SENUM
, 3, ' ' },
244 { "TalE3", TYPE_SENUM
, 127, ' ' },
245 { "TalE4", TYPE_UENUM
, 255, ' ' },
246 { "TalE5", TYPE_SENUM
, 32767, ' ' },
247 { "TalE6", TYPE_UENUM
, 65535, ' ' },
248 { "TalE7", TYPE_SENUM
, 2147483647, ' ' },
249 { "TalE8", TYPE_UENUM
, 4294967295U, ' ' },
250 { "TalE9", TYPE_SENUM
, 1099511627775LL, ' ' },
251 { "Tal1char", TYPE_UINT
, 127, 'C' },
252 { "Tal1schar", TYPE_INT
, 127, 'C' },
253 { "Tal1uchar", TYPE_UINT
, 255, 'C' },
254 { "Tal1short", TYPE_INT
, 32767, 'S' },
255 { "Tal1ushort", TYPE_UINT
, 65535, 'S' },
256 { "Tal1int", TYPE_INT
, 2147483647, 'I' },
257 { "Tal1uint", TYPE_UINT
, 4294967295U, 'I' },
258 { "Tal1long", TYPE_INT
, 9223372036854775807LL, 'L' },
259 { "Tal1ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
260 { "Tal1llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
261 { "Tal1ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
262 { "Tal1bool", TYPE_UINT
, 1, 'B' },
263 { "Tal1ptr", TYPE_PTR
, 0, 0 },
264 { "Tal1cptr", TYPE_PTR
, 0, 0 },
265 { "Tal1iptr", TYPE_PTR
, 0, 0 },
266 { "Tal1float", TYPE_FLOAT
, 0, 0 },
267 { "Tal1double", TYPE_FLOAT
, 0, 0 },
268 { "Tal1ldouble", TYPE_FLOAT
, 0, 0 },
269 #ifndef SKIP_DECIMAL_FLOAT
270 { "Tal1Decimal32", TYPE_DEC_FLOAT
, 0, 0},
271 { "Tal1Decimal64", TYPE_DEC_FLOAT
, 0, 0},
272 { "Tal1Decimal128", TYPE_DEC_FLOAT
, 0, 0},
274 { "Tal1E0", TYPE_UENUM
, 0, ' ' },
275 { "Tal1E1", TYPE_UENUM
, 1, ' ' },
276 { "Tal1E2", TYPE_SENUM
, 3, ' ' },
277 { "Tal1E3", TYPE_SENUM
, 127, ' ' },
278 { "Tal1E4", TYPE_UENUM
, 255, ' ' },
279 { "Tal1E5", TYPE_SENUM
, 32767, ' ' },
280 { "Tal1E6", TYPE_UENUM
, 65535, ' ' },
281 { "Tal1E7", TYPE_SENUM
, 2147483647, ' ' },
282 { "Tal1E8", TYPE_UENUM
, 4294967295U, ' ' },
283 { "Tal1E9", TYPE_SENUM
, 1099511627775LL, ' ' },
284 { "Tal2char", TYPE_UINT
, 127, 'C' },
285 { "Tal2schar", TYPE_INT
, 127, 'C' },
286 { "Tal2uchar", TYPE_UINT
, 255, 'C' },
287 { "Tal2short", TYPE_INT
, 32767, 'S' },
288 { "Tal2ushort", TYPE_UINT
, 65535, 'S' },
289 { "Tal2int", TYPE_INT
, 2147483647, 'I' },
290 { "Tal2uint", TYPE_UINT
, 4294967295U, 'I' },
291 { "Tal2long", TYPE_INT
, 9223372036854775807LL, 'L' },
292 { "Tal2ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
293 { "Tal2llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
294 { "Tal2ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
295 { "Tal2bool", TYPE_UINT
, 1, 'B' },
296 { "Tal2ptr", TYPE_PTR
, 0, 0 },
297 { "Tal2cptr", TYPE_PTR
, 0, 0 },
298 { "Tal2iptr", TYPE_PTR
, 0, 0 },
299 { "Tal2float", TYPE_FLOAT
, 0, 0 },
300 { "Tal2double", TYPE_FLOAT
, 0, 0 },
301 { "Tal2ldouble", TYPE_FLOAT
, 0, 0 },
302 #ifndef SKIP_DECIMAL_FLOAT
303 { "Tal2Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
304 { "Tal2Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
305 { "Tal2Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
307 { "Tal2E0", TYPE_UENUM
, 0, ' ' },
308 { "Tal2E1", TYPE_UENUM
, 1, ' ' },
309 { "Tal2E2", TYPE_SENUM
, 3, ' ' },
310 { "Tal2E3", TYPE_SENUM
, 127, ' ' },
311 { "Tal2E4", TYPE_UENUM
, 255, ' ' },
312 { "Tal2E5", TYPE_SENUM
, 32767, ' ' },
313 { "Tal2E6", TYPE_UENUM
, 65535, ' ' },
314 { "Tal2E7", TYPE_SENUM
, 2147483647, ' ' },
315 { "Tal2E8", TYPE_UENUM
, 4294967295U, ' ' },
316 { "Tal2E9", TYPE_SENUM
, 1099511627775LL, ' ' },
317 { "Tal4char", TYPE_UINT
, 127, 'C' },
318 { "Tal4schar", TYPE_INT
, 127, 'C' },
319 { "Tal4uchar", TYPE_UINT
, 255, 'C' },
320 { "Tal4short", TYPE_INT
, 32767, 'S' },
321 { "Tal4ushort", TYPE_UINT
, 65535, 'S' },
322 { "Tal4int", TYPE_INT
, 2147483647, 'I' },
323 { "Tal4uint", TYPE_UINT
, 4294967295U, 'I' },
324 { "Tal4long", TYPE_INT
, 9223372036854775807LL, 'L' },
325 { "Tal4ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
326 { "Tal4llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
327 { "Tal4ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
328 { "Tal4bool", TYPE_UINT
, 1, 'B' },
329 { "Tal4ptr", TYPE_PTR
, 0, 0 },
330 { "Tal4cptr", TYPE_PTR
, 0, 0 },
331 { "Tal4iptr", TYPE_PTR
, 0, 0 },
332 { "Tal4float", TYPE_FLOAT
, 0, 0 },
333 { "Tal4double", TYPE_FLOAT
, 0, 0 },
334 { "Tal4ldouble", TYPE_FLOAT
, 0, 0 },
335 #ifndef SKIP_DECIMAL_FLOAT
336 { "Tal4Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
337 { "Tal4Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
338 { "Tal4Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
340 { "Tal4E0", TYPE_UENUM
, 0, ' ' },
341 { "Tal4E1", TYPE_UENUM
, 1, ' ' },
342 { "Tal4E2", TYPE_SENUM
, 3, ' ' },
343 { "Tal4E3", TYPE_SENUM
, 127, ' ' },
344 { "Tal4E4", TYPE_UENUM
, 255, ' ' },
345 { "Tal4E5", TYPE_SENUM
, 32767, ' ' },
346 { "Tal4E6", TYPE_UENUM
, 65535, ' ' },
347 { "Tal4E7", TYPE_SENUM
, 2147483647, ' ' },
348 { "Tal4E8", TYPE_UENUM
, 4294967295U, ' ' },
349 { "Tal4E9", TYPE_SENUM
, 1099511627775LL, ' ' },
350 { "Tal8char", TYPE_UINT
, 127, 'C' },
351 { "Tal8schar", TYPE_INT
, 127, 'C' },
352 { "Tal8uchar", TYPE_UINT
, 255, 'C' },
353 { "Tal8short", TYPE_INT
, 32767, 'S' },
354 { "Tal8ushort", TYPE_UINT
, 65535, 'S' },
355 { "Tal8int", TYPE_INT
, 2147483647, 'I' },
356 { "Tal8uint", TYPE_UINT
, 4294967295U, 'I' },
357 { "Tal8long", TYPE_INT
, 9223372036854775807LL, 'L' },
358 { "Tal8ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
359 { "Tal8llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
360 { "Tal8ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
361 { "Tal8bool", TYPE_UINT
, 1, 'B' },
362 { "Tal8ptr", TYPE_PTR
, 0, 0 },
363 { "Tal8cptr", TYPE_PTR
, 0, 0 },
364 { "Tal8iptr", TYPE_PTR
, 0, 0 },
365 { "Tal8float", TYPE_FLOAT
, 0, 0 },
366 { "Tal8double", TYPE_FLOAT
, 0, 0 },
367 { "Tal8ldouble", TYPE_FLOAT
, 0, 0 },
368 #ifndef SKIP_DECIMAL_FLOAT
369 { "Tal8Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
370 { "Tal8Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
371 { "Tal8Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
373 { "Tal8E0", TYPE_UENUM
, 0, ' ' },
374 { "Tal8E1", TYPE_UENUM
, 1, ' ' },
375 { "Tal8E2", TYPE_SENUM
, 3, ' ' },
376 { "Tal8E3", TYPE_SENUM
, 127, ' ' },
377 { "Tal8E4", TYPE_UENUM
, 255, ' ' },
378 { "Tal8E5", TYPE_SENUM
, 32767, ' ' },
379 { "Tal8E6", TYPE_UENUM
, 65535, ' ' },
380 { "Tal8E7", TYPE_SENUM
, 2147483647, ' ' },
381 { "Tal8E8", TYPE_UENUM
, 4294967295U, ' ' },
382 { "Tal8E9", TYPE_SENUM
, 1099511627775LL, ' ' },
383 { "Tal16char", TYPE_UINT
, 127, 'C' },
384 { "Tal16schar", TYPE_INT
, 127, 'C' },
385 { "Tal16uchar", TYPE_UINT
, 255, 'C' },
386 { "Tal16short", TYPE_INT
, 32767, 'S' },
387 { "Tal16ushort", TYPE_UINT
, 65535, 'S' },
388 { "Tal16int", TYPE_INT
, 2147483647, 'I' },
389 { "Tal16uint", TYPE_UINT
, 4294967295U, 'I' },
390 { "Tal16long", TYPE_INT
, 9223372036854775807LL, 'L' },
391 { "Tal16ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
392 { "Tal16llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
393 { "Tal16ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
394 { "Tal16bool", TYPE_UINT
, 1, 'B' },
395 { "Tal16ptr", TYPE_PTR
, 0, 0 },
396 { "Tal16cptr", TYPE_PTR
, 0, 0 },
397 { "Tal16iptr", TYPE_PTR
, 0, 0 },
398 { "Tal16float", TYPE_FLOAT
, 0, 0 },
399 { "Tal16double", TYPE_FLOAT
, 0, 0 },
400 { "Tal16ldouble", TYPE_FLOAT
, 0, 0 },
401 #ifndef SKIP_DECIMAL_FLOAT
402 { "Tal16Decimal32", TYPE_DEC_FLOAT
, 0, 0 },
403 { "Tal16Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
404 { "Tal16Decimal128", TYPE_DEC_FLOAT
, 0, 0 },
406 { "Tal16E0", TYPE_UENUM
, 0, ' ' },
407 { "Tal16E1", TYPE_UENUM
, 1, ' ' },
408 { "Tal16E2", TYPE_SENUM
, 3, ' ' },
409 { "Tal16E3", TYPE_SENUM
, 127, ' ' },
410 { "Tal16E4", TYPE_UENUM
, 255, ' ' },
411 { "Tal16E5", TYPE_SENUM
, 32767, ' ' },
412 { "Tal16E6", TYPE_UENUM
, 65535, ' ' },
413 { "Tal16E7", TYPE_SENUM
, 2147483647, ' ' },
414 { "Tal16E8", TYPE_UENUM
, 4294967295U, ' ' },
415 { "Tal16E9", TYPE_SENUM
, 1099511627775LL, ' ' }
416 #define NATYPES2 (sizeof (attrib_types) / sizeof (attrib_types[0]))
418 struct types complex_attrib_types
[] = {
419 { "Talcchar", TYPE_CUINT
, 127, 0 },
420 { "Talcschar", TYPE_CINT
, 127, 0 },
421 { "Talcuchar", TYPE_CUINT
, 255, 0 },
422 { "Talcshort", TYPE_CINT
, 32767, 0 },
423 { "Talcushort", TYPE_CUINT
, 65535, 0 },
424 { "Talcint", TYPE_CINT
, 2147483647, 0 },
425 { "Talcuint", TYPE_CUINT
, 4294967295U, 0 },
426 { "Talclong", TYPE_CINT
, 9223372036854775807LL, 0 },
427 { "Talculong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
428 { "Talcllong", TYPE_CINT
, 9223372036854775807LL, 0 },
429 { "Talcullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
430 { "Talcfloat", TYPE_CFLOAT
, 0, 0 },
431 { "Talcdouble", TYPE_CFLOAT
, 0, 0 },
432 { "Talcldouble", TYPE_CFLOAT
, 0, 0 },
433 { "Tal1cchar", TYPE_CUINT
, 127, 0 },
434 { "Tal1cschar", TYPE_CINT
, 127, 0 },
435 { "Tal1cuchar", TYPE_CUINT
, 255, 0 },
436 { "Tal1cshort", TYPE_CINT
, 32767, 0 },
437 { "Tal1cushort", TYPE_CUINT
, 65535, 0 },
438 { "Tal1cint", TYPE_CINT
, 2147483647, 0 },
439 { "Tal1cuint", TYPE_CUINT
, 4294967295U, 0 },
440 { "Tal1clong", TYPE_CINT
, 9223372036854775807LL, 0 },
441 { "Tal1culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
442 { "Tal1cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
443 { "Tal1cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
444 { "Tal1cfloat", TYPE_CFLOAT
, 0, 0 },
445 { "Tal1cdouble", TYPE_CFLOAT
, 0, 0 },
446 { "Tal1cldouble", TYPE_CFLOAT
, 0, 0 },
447 { "Tal2cchar", TYPE_CUINT
, 127, 0 },
448 { "Tal2cschar", TYPE_CINT
, 127, 0 },
449 { "Tal2cuchar", TYPE_CUINT
, 255, 0 },
450 { "Tal2cshort", TYPE_CINT
, 32767, 0 },
451 { "Tal2cushort", TYPE_CUINT
, 65535, 0 },
452 { "Tal2cint", TYPE_CINT
, 2147483647, 0 },
453 { "Tal2cuint", TYPE_CUINT
, 4294967295U, 0 },
454 { "Tal2clong", TYPE_CINT
, 9223372036854775807LL, 0 },
455 { "Tal2culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
456 { "Tal2cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
457 { "Tal2cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
458 { "Tal2cfloat", TYPE_CFLOAT
, 0, 0 },
459 { "Tal2cdouble", TYPE_CFLOAT
, 0, 0 },
460 { "Tal2cldouble", TYPE_CFLOAT
, 0, 0 },
461 { "Tal4cchar", TYPE_CUINT
, 127, 0 },
462 { "Tal4cschar", TYPE_CINT
, 127, 0 },
463 { "Tal4cuchar", TYPE_CUINT
, 255, 0 },
464 { "Tal4cshort", TYPE_CINT
, 32767, 0 },
465 { "Tal4cushort", TYPE_CUINT
, 65535, 0 },
466 { "Tal4cint", TYPE_CINT
, 2147483647, 0 },
467 { "Tal4cuint", TYPE_CUINT
, 4294967295U, 0 },
468 { "Tal4clong", TYPE_CINT
, 9223372036854775807LL, 0 },
469 { "Tal4culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
470 { "Tal4cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
471 { "Tal4cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
472 { "Tal4cfloat", TYPE_CFLOAT
, 0, 0 },
473 { "Tal4cdouble", TYPE_CFLOAT
, 0, 0 },
474 { "Tal4cldouble", TYPE_CFLOAT
, 0, 0 },
475 { "Tal8cchar", TYPE_CUINT
, 127, 0 },
476 { "Tal8cschar", TYPE_CINT
, 127, 0 },
477 { "Tal8cuchar", TYPE_CUINT
, 255, 0 },
478 { "Tal8cshort", TYPE_CINT
, 32767, 0 },
479 { "Tal8cushort", TYPE_CUINT
, 65535, 0 },
480 { "Tal8cint", TYPE_CINT
, 2147483647, 0 },
481 { "Tal8cuint", TYPE_CUINT
, 4294967295U, 0 },
482 { "Tal8clong", TYPE_CINT
, 9223372036854775807LL, 0 },
483 { "Tal8culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
484 { "Tal8cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
485 { "Tal8cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
486 { "Tal8cfloat", TYPE_CFLOAT
, 0, 0 },
487 { "Tal8cdouble", TYPE_CFLOAT
, 0, 0 },
488 { "Tal8cldouble", TYPE_CFLOAT
, 0, 0 },
489 { "Tal16cchar", TYPE_CUINT
, 127, 0 },
490 { "Tal16cschar", TYPE_CINT
, 127, 0 },
491 { "Tal16cuchar", TYPE_CUINT
, 255, 0 },
492 { "Tal16cshort", TYPE_CINT
, 32767, 0 },
493 { "Tal16cushort", TYPE_CUINT
, 65535, 0 },
494 { "Tal16cint", TYPE_CINT
, 2147483647, 0 },
495 { "Tal16cuint", TYPE_CUINT
, 4294967295U, 0 },
496 { "Tal16clong", TYPE_CINT
, 9223372036854775807LL, 0 },
497 { "Tal16culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
498 { "Tal16cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
499 { "Tal16cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
500 { "Tal16cfloat", TYPE_CFLOAT
, 0, 0 },
501 { "Tal16cdouble", TYPE_CFLOAT
, 0, 0 },
502 { "Tal16cldouble", TYPE_CFLOAT
, 0, 0 }
503 #define NCATYPES2 (sizeof (complex_attrib_types) / sizeof (complex_attrib_types[0]))
505 struct types attrib_array_types
[] = {
506 { "Talx1char", TYPE_UINT
, 127, 'C' },
507 { "Talx1schar", TYPE_INT
, 127, 'C' },
508 { "Talx1uchar", TYPE_UINT
, 255, 'C' },
509 { "Talx1short", TYPE_INT
, 32767, 'S' },
510 { "Talx1ushort", TYPE_UINT
, 65535, 'S' },
511 { "Talx1int", TYPE_INT
, 2147483647, 'I' },
512 { "Talx1uint", TYPE_UINT
, 4294967295U, 'I' },
513 { "Talx1long", TYPE_INT
, 9223372036854775807LL, 'L' },
514 { "Talx1ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
515 { "Talx1llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
516 { "Talx1ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
517 { "Talx1bool", TYPE_UINT
, 1, 'B' },
518 { "Talx1ptr", TYPE_PTR
, 0, 0 },
519 { "Talx1cptr", TYPE_PTR
, 0, 0 },
520 { "Talx1iptr", TYPE_PTR
, 0, 0 },
521 { "Talx1float", TYPE_FLOAT
, 0, 0 },
522 { "Talx1double", TYPE_FLOAT
, 0, 0 },
523 { "Talx1ldouble", TYPE_FLOAT
, 0, 0 },
524 #ifndef SKIP_DECIMAL_FLOAT
525 { "Talx1Decimal32", TYPE_DEC_FLOAT
, 0 ,0 },
526 { "Talx1Decimal64", TYPE_DEC_FLOAT
, 0 ,0 },
527 { "Talx1Decimal128", TYPE_DEC_FLOAT
, 0 ,0 },
529 { "Talx1E0", TYPE_UENUM
, 0, ' ' },
530 { "Talx1E1", TYPE_UENUM
, 1, ' ' },
531 { "Talx1E2", TYPE_SENUM
, 3, ' ' },
532 { "Talx1E3", TYPE_SENUM
, 127, ' ' },
533 { "Talx1E4", TYPE_UENUM
, 255, ' ' },
534 { "Talx1E5", TYPE_SENUM
, 32767, ' ' },
535 { "Talx1E6", TYPE_UENUM
, 65535, ' ' },
536 { "Talx1E7", TYPE_SENUM
, 2147483647, ' ' },
537 { "Talx1E8", TYPE_UENUM
, 4294967295U, ' ' },
538 { "Talx1E9", TYPE_SENUM
, 1099511627775LL, ' ' },
539 { "Talx2short", TYPE_INT
, 32767, 'S' },
540 { "Talx2ushort", TYPE_UINT
, 65535, 'S' },
541 { "Talx2int", TYPE_INT
, 2147483647, 'I' },
542 { "Talx2uint", TYPE_UINT
, 4294967295U, 'I' },
543 { "Talx2long", TYPE_INT
, 9223372036854775807LL, 'L' },
544 { "Talx2ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
545 { "Talx2llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
546 { "Talx2ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
547 { "Talx2ptr", TYPE_PTR
, 0, 0 },
548 { "Talx2cptr", TYPE_PTR
, 0, 0 },
549 { "Talx2iptr", TYPE_PTR
, 0, 0 },
550 { "Talx2float", TYPE_FLOAT
, 0, 0 },
551 { "Talx2double", TYPE_FLOAT
, 0, 0 },
552 { "Talx2ldouble", TYPE_FLOAT
, 0, 0 },
553 #ifndef SKIP_DECIMAL_FLOAT
554 { "Talx2Decimal32", TYPE_DEC_FLOAT
, 0 , 0 },
555 { "Talx2Decimal64", TYPE_DEC_FLOAT
, 0 , 0 },
556 { "Talx2Decimal128", TYPE_DEC_FLOAT
, 0 , 0 },
558 { "Talx2E0", TYPE_UENUM
, 0, ' ' },
559 { "Talx2E1", TYPE_UENUM
, 1, ' ' },
560 { "Talx2E2", TYPE_SENUM
, 3, ' ' },
561 { "Talx2E3", TYPE_SENUM
, 127, ' ' },
562 { "Talx2E4", TYPE_UENUM
, 255, ' ' },
563 { "Talx2E5", TYPE_SENUM
, 32767, ' ' },
564 { "Talx2E6", TYPE_UENUM
, 65535, ' ' },
565 { "Talx2E7", TYPE_SENUM
, 2147483647, ' ' },
566 { "Talx2E8", TYPE_UENUM
, 4294967295U, ' ' },
567 { "Talx2E9", TYPE_SENUM
, 1099511627775LL, ' ' },
568 { "Talx4int", TYPE_INT
, 2147483647, 'I' },
569 { "Talx4uint", TYPE_UINT
, 4294967295U, 'I' },
570 { "Talx4long", TYPE_INT
, 9223372036854775807LL, 'L' },
571 { "Talx4ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
572 { "Talx4llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
573 { "Talx4ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
574 { "Talx4ptr", TYPE_PTR
, 0, 0 },
575 { "Talx4cptr", TYPE_PTR
, 0, 0 },
576 { "Talx4iptr", TYPE_PTR
, 0, 0 },
577 { "Talx4float", TYPE_FLOAT
, 0, 0 },
578 { "Talx4double", TYPE_FLOAT
, 0, 0 },
579 { "Talx4ldouble", TYPE_FLOAT
, 0, 0 },
580 #ifndef SKIP_DECIMAL_FLOAT
581 { "Talx4Decimal32", TYPE_DEC_FLOAT
, 0 , 0 },
582 { "Talx4Decimal64", TYPE_DEC_FLOAT
, 0 , 0 },
583 { "Talx4Decimal128", TYPE_DEC_FLOAT
, 0 , 0 },
585 { "Talx4E0", TYPE_UENUM
, 0, ' ' },
586 { "Talx4E1", TYPE_UENUM
, 1, ' ' },
587 { "Talx4E2", TYPE_SENUM
, 3, ' ' },
588 { "Talx4E3", TYPE_SENUM
, 127, ' ' },
589 { "Talx4E4", TYPE_UENUM
, 255, ' ' },
590 { "Talx4E5", TYPE_SENUM
, 32767, ' ' },
591 { "Talx4E6", TYPE_UENUM
, 65535, ' ' },
592 { "Talx4E7", TYPE_SENUM
, 2147483647, ' ' },
593 { "Talx4E8", TYPE_UENUM
, 4294967295U, ' ' },
594 { "Talx4E9", TYPE_SENUM
, 1099511627775LL, ' ' },
595 { "Taly8long", TYPE_INT
, 9223372036854775807LL, 'L' },
596 { "Taly8ulong", TYPE_UINT
, 18446744073709551615ULL, 'L' },
597 { "Talx8llong", TYPE_INT
, 9223372036854775807LL, 'Q' },
598 { "Talx8ullong", TYPE_UINT
, 18446744073709551615ULL, 'Q' },
599 { "Taly8ptr", TYPE_PTR
, 0, 0 },
600 { "Taly8cptr", TYPE_PTR
, 0, 0 },
601 { "Taly8iptr", TYPE_PTR
, 0, 0 },
602 { "Talx8double", TYPE_FLOAT
, 0, 0 },
603 { "Talx8ldouble", TYPE_FLOAT
, 0, 0 },
604 #ifndef SKIP_DECIMAL_FLOAT
605 { "Talx8Decimal64", TYPE_DEC_FLOAT
, 0, 0 },
606 { "Talx8Decimal128", TYPE_DEC_FLOAT
, 0, 0 }
608 #define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0]))
610 struct types complex_attrib_array_types
[] = {
611 { "Talx1cchar", TYPE_CUINT
, 127, 0 },
612 { "Talx1cschar", TYPE_CINT
, 127, 0 },
613 { "Talx1cuchar", TYPE_CUINT
, 255, 0 },
614 { "Talx1cshort", TYPE_CINT
, 32767, 0 },
615 { "Talx1cushort", TYPE_CUINT
, 65535, 0 },
616 { "Talx1cint", TYPE_CINT
, 2147483647, 0 },
617 { "Talx1cuint", TYPE_CUINT
, 4294967295U, 0 },
618 { "Talx1clong", TYPE_CINT
, 9223372036854775807LL, 0 },
619 { "Talx1culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
620 { "Talx1cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
621 { "Talx1cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
622 { "Talx1cfloat", TYPE_CFLOAT
, 0, 0 },
623 { "Talx1cdouble", TYPE_CFLOAT
, 0, 0 },
624 { "Talx1cldouble", TYPE_CFLOAT
, 0, 0 },
625 { "Talx2cchar", TYPE_CUINT
, 127, 0 },
626 { "Talx2cschar", TYPE_CINT
, 127, 0 },
627 { "Talx2cuchar", TYPE_CUINT
, 255, 0 },
628 { "Talx2cshort", TYPE_CINT
, 32767, 0 },
629 { "Talx2cushort", TYPE_CUINT
, 65535, 0 },
630 { "Talx2cint", TYPE_CINT
, 2147483647, 0 },
631 { "Talx2cuint", TYPE_CUINT
, 4294967295U, 0 },
632 { "Talx2clong", TYPE_CINT
, 9223372036854775807LL, 0 },
633 { "Talx2culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
634 { "Talx2cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
635 { "Talx2cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
636 { "Talx2cfloat", TYPE_CFLOAT
, 0, 0 },
637 { "Talx2cdouble", TYPE_CFLOAT
, 0, 0 },
638 { "Talx2cldouble", TYPE_CFLOAT
, 0, 0 },
639 { "Talx4cshort", TYPE_CINT
, 32767, 0 },
640 { "Talx4cushort", TYPE_CUINT
, 65535, 0 },
641 { "Talx4cint", TYPE_CINT
, 2147483647, 0 },
642 { "Talx4cuint", TYPE_CUINT
, 4294967295U, 0 },
643 { "Talx4clong", TYPE_CINT
, 9223372036854775807LL, 0 },
644 { "Talx4culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
645 { "Talx4cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
646 { "Talx4cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
647 { "Talx4cfloat", TYPE_CFLOAT
, 0, 0 },
648 { "Talx4cdouble", TYPE_CFLOAT
, 0, 0 },
649 { "Talx4cldouble", TYPE_CFLOAT
, 0, 0 },
650 { "Talx8cint", TYPE_CINT
, 2147483647, 0 },
651 { "Talx8cuint", TYPE_CUINT
, 4294967295U, 0 },
652 { "Talx8clong", TYPE_CINT
, 9223372036854775807LL, 0 },
653 { "Talx8culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
654 { "Talx8cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
655 { "Talx8cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
656 { "Talx8cfloat", TYPE_CFLOAT
, 0, 0 },
657 { "Talx8cdouble", TYPE_CFLOAT
, 0, 0 },
658 { "Talx8cldouble", TYPE_CFLOAT
, 0, 0 },
659 { "Taly16clong", TYPE_CINT
, 9223372036854775807LL, 0 },
660 { "Taly16culong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
661 { "Talx16cllong", TYPE_CINT
, 9223372036854775807LL, 0 },
662 { "Talx16cullong", TYPE_CUINT
, 18446744073709551615ULL, 0 },
663 { "Talx16cdouble", TYPE_CFLOAT
, 0, 0 },
664 { "Talx16cldouble", TYPE_CFLOAT
, 0, 0 }
665 #define NCAATYPES2 (sizeof (complex_attrib_array_types) / sizeof (complex_attrib_array_types[0]))
668 struct types bitfld_types
[NTYPES2
];
670 struct types aligned_bitfld_types
[NATYPES2
];
671 int n_aligned_bitfld_types
;
673 const char *attributes
[] = {
694 #define NATTRIBS2 (sizeof (attributes) / sizeof (attributes[0]))
711 enum ETYPE etype
: 8;
716 unsigned char arr_len
;
719 /* Used to chain together entries in the hash table. */
723 /* A prime number giving the number of slots in the hash table. */
724 #define HASH_SIZE 32749
725 static struct entry
*hash_table
[HASH_SIZE
];
727 static int idx
, limidx
, output_one
, short_enums
;
728 static const char *destdir
;
729 static const char *srcdir
;
733 switchfiles (int fields
)
736 static char *destbuf
, *destptr
;
747 size_t len
= strlen (destdir
);
748 destbuf
= malloc (len
+ 20);
751 memcpy (destbuf
, destdir
, len
);
752 if (!len
|| destbuf
[len
- 1] != '/')
753 destbuf
[len
++] = '/';
754 destptr
= destbuf
+ len
;
756 sprintf (destptr
, "t%03d_main.c", filecnt
);
757 outfile
= fopen (destbuf
, "w");
761 fputs ("failed to create test files\n", stderr
);
765 /* { dg-options \"-I%s\" } */\n\
766 /* { dg-options \"-I%s -fno-common\" { target hppa*-*-hpux* *-*-darwin* } } */\n\
767 /* { dg-options \"-I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
768 #include \"struct-layout-1.h\"\n\
770 #define TX(n, type, attrs, fields, ops) extern void test##n (void);\n\
771 #include \"t%03d_test.h\"\n\
776 #define TX(n, type, attrs, fields, ops) test##n ();\n\
777 #include \"t%03d_test.h\"\n\
785 }\n", srcdir
, srcdir
, srcdir
, filecnt
, filecnt
);
787 sprintf (destptr
, "t%03d_x.c", filecnt
);
788 outfile
= fopen (destbuf
, "w");
792 /* { dg-options \"-w -I%s\" } */\n\
793 /* { dg-options \"-w -I%s -fno-common\" { target hppa*-*-hpux* *-*-darwin* } } */\n\
794 /* { dg-options \"-w -I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
795 #include \"struct-layout-1_x1.h\"\n\
796 #include \"t%03d_test.h\"\n\
797 #include \"struct-layout-1_x2.h\"\n\
798 #include \"t%03d_test.h\"\n", srcdir
, srcdir
, srcdir
, filecnt
, filecnt
);
800 sprintf (destptr
, "t%03d_y.c", filecnt
);
801 outfile
= fopen (destbuf
, "w");
805 /* { dg-options \"-w -I%s\" } */\n\
806 /* { dg-options \"-w -I%s -fno-common\" { target hppa*-*-hpux* *-*-darwin* } } */\n\
807 /* { dg-options \"-w -I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
808 #include \"struct-layout-1_y1.h\"\n\
809 #include \"t%03d_test.h\"\n\
810 #include \"struct-layout-1_y2.h\"\n\
811 #include \"t%03d_test.h\"\n", srcdir
, srcdir
, srcdir
, filecnt
, filecnt
);
813 sprintf (destptr
, "t%03d_test.h", filecnt
);
814 outfile
= fopen (destbuf
, "w");
819 else if (fields
<= 4)
821 else if (fields
<= 6)
827 unsigned long long int
830 unsigned long long int ret
;
831 ret
= generate_random () & 0xffffff;
832 ret
|= (generate_random () & 0xffffffLL
) << 24;
833 ret
|= ((unsigned long long int) generate_random ()) << 48;
838 subfield (struct entry
*e
, char *letter
)
847 case ETYPE_STRUCT_ARRAY
:
848 case ETYPE_UNION_ARRAY
:
849 type
= e
[0].attrib
? 1 + (generate_random () & 3) : 0;
850 if (e
[0].etype
== ETYPE_STRUCT
|| e
[0].etype
== ETYPE_STRUCT_ARRAY
)
854 if (e
[0].etype
== ETYPE_STRUCT_ARRAY
|| e
[0].etype
== ETYPE_UNION_ARRAY
)
856 if (e
[0].arr_len
== 255)
857 snprintf (buf
, 20, "%c[]", *letter
);
859 snprintf (buf
, 20, "%c[%d]", *letter
, e
[0].arr_len
);
860 /* If this is an array type, do not put aligned attributes on
861 elements. Aligning elements to a value greater than their
862 size will result in a compiler error. */
864 && ((strncmp (e
[0].attrib
, "atal", 4) == 0)
865 || strncmp (e
[0].attrib
, "atpaal", 6) == 0))
879 fprintf (outfile
, "%s{", p
);
882 fprintf (outfile
, "%s %s{", e
[0].attrib
, p
);
885 fprintf (outfile
, "%s %s{", p
, e
[0].attrib
);
889 for (i
= 1; i
<= e
[0].len
; )
890 i
+= subfield (e
+ i
, letter
);
897 fprintf (outfile
, "}%s;", buf
);
900 fprintf (outfile
, "}%s %s;", e
[0].attrib
, buf
);
903 fprintf (outfile
, "}%s %s;", buf
, e
[0].attrib
);
909 if (e
[0].etype
== ETYPE_ARRAY
)
911 if (e
[0].arr_len
== 255)
912 snprintf (buf
, 20, "%c[]", *letter
);
914 snprintf (buf
, 20, "%c[%d]", *letter
, e
[0].arr_len
);
924 /* If this is an array type, do not put aligned attributes on
925 elements. Aligning elements to a value greater than their
926 size will result in a compiler error. */
927 if (e
[0].etype
== ETYPE_ARRAY
928 && ((strncmp (e
[0].attrib
, "atal", 4) == 0)
929 || strncmp (e
[0].attrib
, "atpaal", 6) == 0))
932 type
= generate_random () % 3;
936 fprintf (outfile
, "%s %s %s;", e
[0].attrib
, e
[0].type
->name
,
940 fprintf (outfile
, "%s %s %s;", e
[0].type
->name
, e
[0].attrib
,
944 fprintf (outfile
, "%s %s %s;", e
[0].type
->name
, buf
,
950 fprintf (outfile
, "%s %s;", e
[0].type
->name
, buf
);
956 switch (generate_random () % 3)
959 fprintf (outfile
, "%s %s:0;", e
[0].attrib
, e
[0].type
->name
);
962 fprintf (outfile
, "%s %s:0;", e
[0].type
->name
, e
[0].attrib
);
965 fprintf (outfile
, "%s:0 %s;", e
[0].type
->name
, e
[0].attrib
);
969 fprintf (outfile
, "%s:0;", e
[0].type
->name
);
973 switch (e
[0].type
->bitfld
)
980 snprintf (buf
, 20, "B%cN(%d)", e
[0].type
->bitfld
, e
[0].len
);
984 snprintf (buf
, 20, "%d", e
[0].len
);
990 switch (generate_random () % 3)
993 fprintf (outfile
, "%s %s %c:%s;", e
[0].attrib
, e
[0].type
->name
,
997 fprintf (outfile
, "%s %s %c:%s;", e
[0].type
->name
, e
[0].attrib
,
1001 fprintf (outfile
, "%s %c:%s %s;", e
[0].type
->name
, *letter
,
1006 fprintf (outfile
, "%s %c:%s;", e
[0].type
->name
, *letter
, buf
);
1017 output_FNB (char mode
, struct entry
*e
)
1019 unsigned long long int l1
, l2
, m
;
1021 #ifndef SKIP_DECIMAL_FLOAT
1023 char DEC_SUFFIX
[3][3]={"DF","DD","DL"};
1028 if (e
->type
->type
== TYPE_OTHER
)
1032 fprintf (outfile
, "N(%d,%s)", idx
, namebuf
);
1035 fprintf (outfile
, "%c(%d,%s,", mode
, idx
, namebuf
);
1038 switch (e
->type
->type
)
1041 signs
= generate_random () & 3;
1042 m
= e
->type
->maxval
;
1044 m
&= e
->len
> 1 ? (1ULL << (e
->len
- 1)) - 1 : 1;
1047 fprintf (outfile
, "%s%" COMPAT_PRLL
"u%s,%s%" COMPAT_PRLL
"u%s",
1048 (signs
& 1) ? "-" : "", l1
, l1
> 2147483647 ? "LL" : "",
1049 (signs
& 2) ? "-" : "", l2
, l2
> 2147483647 ? "LL" : "");
1052 m
= e
->type
->maxval
;
1054 m
&= (1ULL << e
->len
) - 1;
1057 fprintf (outfile
, "%" COMPAT_PRLL
"uU%s,%" COMPAT_PRLL
"uU%s",
1058 l1
, l1
> 4294967295U ? "LL" : "",
1059 l2
, l2
> 4294967295U ? "LL" : "");
1064 signs
= generate_random () & 3;
1065 fprintf (outfile
, "%s%f,%s%f", (signs
& 1) ? "-" : "",
1066 ((double) l1
) / 64, (signs
& 2) ? "-" : "", ((double) l2
) / 64);
1068 #ifndef SKIP_DECIMAL_FLOAT
1069 case TYPE_DEC_FLOAT
:
1072 signs
= generate_random () & 3;
1074 /* Get the suffix of Decimal Floting Points per
1075 e->type->name. Distinguish these three DFP types by
1077 if (strstr(e
->type
->name
, "Decimal32")) suffix
=0;
1078 else if (strstr(e
->type
->name
, "Decimal64")) suffix
=1;
1079 else if (strstr(e
->type
->name
, "Decimal128")) suffix
=2;
1083 /* Formatted input/output specifiers for DFP types have not been
1084 implemented in GLIBC. %f here used in fprintf is just to
1085 dump the numbers to outfile. */
1086 fprintf (outfile
, "%s%f%s,%s%f%s",
1087 (signs
& 1) ? "-" : "", ((double) l1
) / 64, DEC_SUFFIX
[suffix
],
1088 (signs
& 2) ? "-" : "", ((double) l2
) / 64, DEC_SUFFIX
[suffix
]);
1092 signs
= generate_random () & 3;
1093 l1
&= e
->type
->maxval
;
1094 l2
&= e
->type
->maxval
;
1096 "CINT(%s%" COMPAT_PRLL
"u%s,%s%" COMPAT_PRLL
"u%s),",
1097 (signs
& 1) ? "-" : "", l1
, l1
> 2147483647 ? "LL" : "",
1098 (signs
& 2) ? "-" : "", l2
, l2
> 2147483647 ? "LL" : "");
1099 signs
= generate_random () & 3;
1102 l1
&= e
->type
->maxval
;
1103 l2
&= e
->type
->maxval
;
1105 "CINT(%s%" COMPAT_PRLL
"u%s,%s%" COMPAT_PRLL
"u%s)",
1106 (signs
& 1) ? "-" : "", l1
, l1
> 2147483647 ? "LL" : "",
1107 (signs
& 2) ? "-" : "", l2
, l2
> 2147483647 ? "LL" : "");
1110 l1
&= e
->type
->maxval
;
1111 l2
&= e
->type
->maxval
;
1113 "CINT(%" COMPAT_PRLL
"uU%s,%" COMPAT_PRLL
"uU%s),",
1114 l1
, l1
> 4294967295U ? "LL" : "",
1115 l2
, l2
> 4294967295U ? "LL" : "");
1118 l1
&= e
->type
->maxval
;
1119 l2
&= e
->type
->maxval
;
1121 "CINT(%" COMPAT_PRLL
"uU%s,%" COMPAT_PRLL
"uU%s)",
1122 l1
, l1
> 4294967295U ? "LL" : "",
1123 l2
, l2
> 4294967295U ? "LL" : "");
1128 signs
= generate_random () & 3;
1129 fprintf (outfile
, "CDBL(%s%f,%s%f),",
1130 (signs
& 1) ? "-" : "", ((double) l1
) / 64,
1131 (signs
& 2) ? "-" : "", ((double) l2
) / 64);
1136 signs
= generate_random () & 3;
1137 fprintf (outfile
, "CDBL(%s%f,%s%f)",
1138 (signs
& 1) ? "-" : "", ((double) l1
) / 64,
1139 (signs
& 2) ? "-" : "", ((double) l2
) / 64);
1142 if (e
->type
->maxval
== 0)
1143 fputs ("e0_0,e0_0", outfile
);
1144 else if (e
->type
->maxval
== 1)
1145 fprintf (outfile
, "e1_%" COMPAT_PRLL
"d,e1_%" COMPAT_PRLL
"d",
1149 p
= strchr (e
->type
->name
, '\0');
1150 while (--p
>= e
->type
->name
&& *p
>= '0' && *p
<= '9');
1155 l1
+= e
->type
->maxval
- 6;
1157 l2
+= e
->type
->maxval
- 6;
1158 fprintf (outfile
, "e%s_%" COMPAT_PRLL
"d,e%s_%" COMPAT_PRLL
"d",
1163 p
= strchr (e
->type
->name
, '\0');
1164 while (--p
>= e
->type
->name
&& *p
>= '0' && *p
<= '9');
1168 fprintf (outfile
, "e%s_%s%" COMPAT_PRLL
"d,e%s_%s%" COMPAT_PRLL
"d",
1169 p
, l1
< 3 ? "m" : "",
1170 l1
== 3 ? 0LL : e
->type
->maxval
- (l1
& 3),
1171 p
, l2
< 3 ? "m" : "",
1172 l2
== 3 ? 0LL : e
->type
->maxval
- (l2
& 3));
1178 "(%s)&intarray[%" COMPAT_PRLL
"d], (%s)&intarray[%" COMPAT_PRLL
"d]",
1179 e
->type
->name
, l1
, e
->type
->name
, l2
);
1184 fprintf (outfile
, "fn%" COMPAT_PRLL
"d,fn%" COMPAT_PRLL
"d", l1
, l2
);
1189 fputs (")", outfile
);
1193 subvalues (struct entry
*e
, char *p
, char *letter
)
1197 if (p
>= namebuf
+ sizeof (namebuf
) - 32)
1204 case ETYPE_STRUCT_ARRAY
:
1205 case ETYPE_UNION_ARRAY
:
1206 if (e
[0].arr_len
== 0 || e
[0].arr_len
== 255)
1208 *letter
+= 1 + e
[0].len
;
1209 return 1 + e
[0].len
;
1211 i
= generate_random () % e
[0].arr_len
;
1212 snprintf (p
, sizeof (namebuf
) - (p
- namebuf
) - 1,
1213 "%c[%d]", *letter
, i
);
1214 q
= strchr (p
, '\0');
1220 for (i
= 1; i
<= e
[0].len
; )
1222 i
+= subvalues (e
+ i
, q
, letter
);
1223 if (e
[0].etype
== ETYPE_UNION
|| e
[0].etype
== ETYPE_UNION_ARRAY
)
1225 *letter
+= e
[0].len
- i
+ 1;
1229 return 1 + e
[0].len
;
1232 output_FNB ('F', e
);
1235 if (e
[0].arr_len
== 0 || e
[0].arr_len
== 255)
1240 i
= generate_random () % e
[0].arr_len
;
1241 snprintf (p
, sizeof (namebuf
) - (p
- namebuf
),
1242 "%c[%d]", *letter
, i
);
1243 output_FNB ('F', e
);
1244 if ((generate_random () & 7) == 0)
1246 j
= generate_random () % e
[0].arr_len
;
1249 snprintf (p
, sizeof (namebuf
) - (p
- namebuf
),
1250 "%c[%d]", *letter
, j
);
1251 output_FNB ('F', e
);
1259 output_FNB ('B', e
);
1265 --------------------------------------------------------------------
1266 lookup2.c, by Bob Jenkins, December 1996, Public Domain.
1267 hash(), hash2(), hash3, and mix() are externally useful functions.
1268 Routines to test the hash are included if SELF_TEST is defined.
1269 You can use this free for any purpose. It has no warranty.
1270 --------------------------------------------------------------------
1274 --------------------------------------------------------------------
1275 mix -- mix 3 32-bit values reversibly.
1276 For every delta with one or two bit set, and the deltas of all three
1277 high bits or all three low bits, whether the original value of a,b,c
1278 is almost all zero or is uniformly distributed,
1279 * If mix() is run forward or backward, at least 32 bits in a,b,c
1280 have at least 1/4 probability of changing.
1281 * If mix() is run forward, every bit of c will change between 1/3 and
1282 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.)
1283 mix() was built out of 36 single-cycle latency instructions in a
1284 structure that could supported 2x parallelism, like so:
1286 a -= c; x = (c>>13);
1290 c -= b; x = (b>>13);
1292 Unfortunately, superscalar Pentiums and Sparcs can't take advantage
1293 of that parallelism. They've also turned some of those single-cycle
1294 latency instructions into multi-cycle latency instructions. Still,
1295 this is the fastest good hash I could find. There were about 2^^68
1296 to choose from. I only looked at a billion or so.
1297 --------------------------------------------------------------------
1299 /* same, but slower, works on systems that might have 8 byte hashval_t's */
1300 #define mix(a,b,c) \
1302 a -= b; a -= c; a ^= (c>>13); \
1303 b -= c; b -= a; b ^= (a<< 8); \
1304 c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \
1305 a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \
1306 b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \
1307 c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \
1308 a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \
1309 b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \
1310 c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \
1314 --------------------------------------------------------------------
1315 hash() -- hash a variable-length key into a 32-bit value
1316 k : the key (the unaligned variable-length array of bytes)
1317 len : the length of the key, counting by bytes
1318 level : can be any 4-byte value
1319 Returns a 32-bit value. Every bit of the key affects every bit of
1320 the return value. Every 1-bit and 2-bit delta achieves avalanche.
1321 About 36+6len instructions.
1323 The best hash table sizes are powers of 2. There is no need to do
1324 mod a prime (mod is sooo slow!). If you need less than 32 bits,
1325 use a bitmask. For example, if you need only 10 bits, do
1326 h = (h & hashmask(10));
1327 In which case, the hash table should have hashsize(10) elements.
1329 If you are hashing n strings (ub1 **)k, do it like this:
1330 for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
1332 By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this
1333 code any way you wish, private, educational, or commercial. It's free.
1335 See http://burtleburtle.net/bob/hash/evahash.html
1336 Use for hash table lookup, or anything where one collision in 2^32 is
1337 acceptable. Do NOT use for cryptographic purposes.
1338 --------------------------------------------------------------------
1342 iterative_hash (const void *k_in
/* the key */,
1343 register size_t length
/* the length of the key */,
1344 register hashval_t initval
/* the previous hash, or
1345 an arbitrary value */)
1347 register const unsigned char *k
= (const unsigned char *)k_in
;
1348 register hashval_t a
,b
,c
,len
;
1350 /* Set up the internal state */
1352 a
= b
= 0x9e3779b9; /* the golden ratio; an arbitrary value */
1353 c
= initval
; /* the previous hash value */
1355 /*---------------------------------------- handle most of the key */
1358 a
+= (k
[0] +((hashval_t
)k
[1]<<8) +((hashval_t
)k
[2]<<16) +((hashval_t
)k
[3]<<24));
1359 b
+= (k
[4] +((hashval_t
)k
[5]<<8) +((hashval_t
)k
[6]<<16) +((hashval_t
)k
[7]<<24));
1360 c
+= (k
[8] +((hashval_t
)k
[9]<<8) +((hashval_t
)k
[10]<<16)+((hashval_t
)k
[11]<<24));
1365 /*------------------------------------- handle the last 11 bytes */
1367 switch(len
) /* all the case statements fall through */
1369 case 11: c
+=((hashval_t
)k
[10]<<24);
1370 case 10: c
+=((hashval_t
)k
[9]<<16);
1371 case 9 : c
+=((hashval_t
)k
[8]<<8);
1372 /* the first byte of c is reserved for the length */
1373 case 8 : b
+=((hashval_t
)k
[7]<<24);
1374 case 7 : b
+=((hashval_t
)k
[6]<<16);
1375 case 6 : b
+=((hashval_t
)k
[5]<<8);
1377 case 4 : a
+=((hashval_t
)k
[3]<<24);
1378 case 3 : a
+=((hashval_t
)k
[2]<<16);
1379 case 2 : a
+=((hashval_t
)k
[1]<<8);
1381 /* case 0: nothing left to add */
1384 /*-------------------------------------------- report the result */
1389 e_hash (const void *a
)
1391 const struct entry
*e
= a
;
1395 if (e
[0].etype
!= ETYPE_STRUCT
&& e
[0].etype
!= ETYPE_UNION
)
1397 for (i
= 0; i
<= e
[0].len
; ++i
)
1400 ret
= iterative_hash (&e
[i
], offsetof (struct entry
, attrib
), ret
);
1401 attriblen
= e
[i
].attrib
? strlen (e
[i
].attrib
) : -1;
1402 ret
= iterative_hash (&attriblen
, sizeof (int), ret
);
1404 ret
= iterative_hash (e
[i
].attrib
, attriblen
, ret
);
1410 e_eq (const void *a
, const void *b
)
1412 const struct entry
*ea
= a
, *eb
= b
;
1414 if (ea
[0].etype
!= ETYPE_STRUCT
&& ea
[0].etype
!= ETYPE_UNION
)
1416 if (ea
[0].len
!= eb
[0].len
)
1418 for (i
= 0; i
<= ea
[0].len
; ++i
)
1420 if (ea
[i
].etype
!= eb
[i
].etype
1421 || ea
[i
].len
!= eb
[i
].len
1422 || ea
[i
].arr_len
!= eb
[i
].arr_len
1423 || ea
[i
].type
!= eb
[i
].type
)
1425 if ((ea
[i
].attrib
== NULL
) ^ (eb
[i
].attrib
== NULL
))
1427 if (ea
[i
].attrib
&& strcmp (ea
[i
].attrib
, eb
[i
].attrib
) != 0)
1434 e_exists (const struct entry
*e
)
1440 for (h
= hash_table
[hval
% HASH_SIZE
]; h
; h
= h
->next
)
1447 e_insert (struct entry
*e
)
1452 e
->next
= hash_table
[hval
% HASH_SIZE
];
1453 hash_table
[hval
% HASH_SIZE
] = e
;
1457 output (struct entry
*e
)
1462 const char *skip_cint
= "";
1464 if (e
[0].etype
!= ETYPE_STRUCT
&& e
[0].etype
!= ETYPE_UNION
)
1470 n
= (struct entry
*) malloc ((e
[0].len
+ 1) * sizeof (struct entry
));
1471 memcpy (n
, e
, (e
[0].len
+ 1) * sizeof (struct entry
));
1475 switchfiles (e
[0].len
);
1477 for (i
= 1; i
<= e
[0].len
; ++i
)
1478 if ((e
[i
].etype
== ETYPE_TYPE
|| e
[i
].etype
== ETYPE_ARRAY
)
1479 && (e
[i
].type
->type
== TYPE_CINT
|| e
[i
].type
->type
== TYPE_CUINT
))
1484 fprintf (outfile
, (generate_random () & 1)
1485 ? "TX%s(%d,%s %s,," : "TX%s(%d,%s,%s,", skip_cint
,
1486 idx
, e
[0].etype
== ETYPE_STRUCT
? "struct" : "union",
1488 else if (e
[0].etype
== ETYPE_STRUCT
)
1489 fprintf (outfile
, "T%s(%d,", skip_cint
, idx
);
1491 fprintf (outfile
, "U%s(%d,", skip_cint
, idx
);
1493 for (i
= 1; i
<= e
[0].len
; )
1494 i
+= subfield (e
+ i
, &c
);
1495 fputs (",", outfile
);
1497 for (i
= 1; i
<= e
[0].len
; )
1499 i
+= subvalues (e
+ i
, namebuf
, &c
);
1500 if (e
[0].etype
== ETYPE_UNION
)
1503 fputs (")\n", outfile
);
1504 if (output_one
&& idx
== limidx
)
1512 FEATURE_COMPLEX
= 2,
1513 FEATURE_ALIGNEDPACKED
= 4,
1514 FEATURE_ZEROARRAY
= 8,
1515 FEATURE_ZEROBITFLD
= 16,
1516 ALL_FEATURES
= FEATURE_COMPLEX
| FEATURE_VECTOR
| FEATURE_ZEROARRAY
1517 | FEATURE_ALIGNEDPACKED
| FEATURE_ZEROBITFLD
1521 singles (enum FEATURE features
)
1525 memset (e
, 0, sizeof (e
));
1526 e
[0].etype
= ETYPE_STRUCT
;
1528 e
[0].etype
= ETYPE_UNION
;
1531 i
< ((features
& FEATURE_ALIGNEDPACKED
) ? NATTRIBS2
: NATTRIBS1
);
1534 e
[0].attrib
= attributes
[i
];
1535 e
[0].etype
= ETYPE_STRUCT
;
1537 e
[0].etype
= ETYPE_UNION
;
1542 for (i
= 0; i
< NTYPES2
; ++i
)
1544 e
[0].etype
= ETYPE_STRUCT
;
1545 e
[1].etype
= ETYPE_TYPE
;
1546 e
[1].type
= &base_types
[i
];
1548 e
[0].etype
= ETYPE_UNION
;
1551 if (features
& FEATURE_COMPLEX
)
1552 for (i
= 0; i
< NCTYPES2
; ++i
)
1554 e
[0].etype
= ETYPE_STRUCT
;
1555 e
[1].etype
= ETYPE_TYPE
;
1556 e
[1].type
= &complex_types
[i
];
1558 e
[0].etype
= ETYPE_UNION
;
1561 if (features
& FEATURE_VECTOR
)
1562 for (i
= 0; i
< NVTYPES2
; ++i
)
1564 e
[0].etype
= ETYPE_STRUCT
;
1565 e
[1].etype
= ETYPE_TYPE
;
1566 e
[1].type
= &vector_types
[i
];
1568 e
[0].etype
= ETYPE_UNION
;
1574 choose_type (enum FEATURE features
, struct entry
*e
, int r
, int in_array
)
1578 i
= NTYPES2
- NTYPES1
;
1579 if (features
& FEATURE_COMPLEX
)
1581 if (features
& FEATURE_VECTOR
)
1588 if (features
& FEATURE_COMPLEX
)
1594 if (features
& FEATURE_COMPLEX
)
1600 if (r
< NTYPES2
- NTYPES1
)
1601 e
->type
= &base_types
[r
+ NTYPES1
];
1602 r
-= NTYPES2
- NTYPES1
;
1603 if (e
->type
== NULL
&& (features
& FEATURE_COMPLEX
))
1606 e
->type
= &complex_types
[r
];
1609 if (e
->type
== NULL
&& (features
& FEATURE_VECTOR
))
1612 e
->type
= &vector_types
[r
];
1615 if (e
->type
== NULL
&& !in_array
)
1618 e
->type
= &attrib_types
[r
];
1621 if (e
->type
== NULL
&& !in_array
&& (features
& FEATURE_COMPLEX
))
1624 e
->type
= &complex_attrib_types
[r
];
1627 if (e
->type
== NULL
&& in_array
)
1630 e
->type
= &attrib_array_types
[r
];
1633 if (e
->type
== NULL
&& in_array
&& (features
& FEATURE_COMPLEX
))
1636 e
->type
= &complex_attrib_array_types
[r
];
1639 if (e
->type
== NULL
)
1643 /* This is from gcc.c-torture/execute/builtin-bitops-1.c. */
1645 my_ffsll (unsigned long long x
)
1650 /* We've tested LLONG_MAX for 64 bits so this should be safe. */
1651 for (i
= 0; i
< 64; i
++)
1652 if (x
& (1ULL << i
))
1658 generate_fields (enum FEATURE features
, struct entry
*e
, struct entry
*parent
,
1661 int r
, i
, j
, ret
= 1, n
, incr
, sametype
;
1663 for (n
= 0; n
< len
; n
+= incr
)
1665 r
= generate_random ();
1666 /* 50% ETYPE_TYPE base_types NTYPES1
1667 12.5% ETYPE_TYPE other
1670 12.5% ETYPE_STRUCT|ETYPE_UNION|ETYPE_STRUCT_ARRAY|ETYPE_UNION_ARRAY */
1680 e
[n
].etype
= ETYPE_TYPE
;
1681 e
[n
].type
= &base_types
[r
% NTYPES1
];
1684 e
[n
].etype
= ETYPE_TYPE
;
1685 choose_type (features
, &e
[n
], r
, 0);
1688 e
[n
].etype
= ETYPE_ARRAY
;
1692 e
[n
].type
= &base_types
[r
% NTYPES1
];
1694 choose_type (features
, &e
[n
], r
, 1);
1695 r
= generate_random ();
1696 if ((features
& FEATURE_ZEROARRAY
) && (r
& 3) == 0)
1699 if (n
== len
- 1 && (r
& 4)
1700 && (parent
->etype
== ETYPE_STRUCT
1701 || parent
->etype
== ETYPE_STRUCT_ARRAY
))
1704 for (k
= 0; k
< n
; ++k
)
1705 if (e
[k
].etype
!= ETYPE_BITFLD
|| e
[k
].len
)
1712 else if ((r
& 3) != 3)
1713 e
[n
].arr_len
= (r
>> 2) & 7;
1715 e
[n
].arr_len
= (r
>> 2) & 31;
1728 incr
= 1 + (r
>> 3) % (len
- n
);
1733 incr
= 1 + (r
>> 3) % (len
- n
);
1736 for (j
= n
; j
< n
+ incr
; ++j
)
1740 e
[j
].etype
= ETYPE_BITFLD
;
1741 if (j
== n
|| !sametype
)
1744 r
= generate_random ();
1749 = &aligned_bitfld_types
[r
% n_aligned_bitfld_types
];
1752 = &bitfld_types
[r
% n_bitfld_types
];
1755 e
[j
].type
= e
[n
].type
;
1756 r
= generate_random ();
1759 switch (e
[j
].type
->bitfld
)
1761 case 'C': ma
= 8; break;
1762 case 'S': ma
= 16; break;
1763 case 'I': ma
= 32; break;
1765 case 'Q': ma
= 64; break;
1766 case 'B': ma
= 1; break;
1768 if (e
[j
].type
->type
== TYPE_UENUM
)
1769 mi
= my_ffsll (e
[j
].type
->maxval
+ 1) - 1;
1770 else if (e
[j
].type
->type
== TYPE_SENUM
)
1771 mi
= my_ffsll (e
[j
].type
->maxval
+ 1);
1778 else if (mi
> 16 || !short_enums
)
1789 if (sametype
&& (r
& 3) == 0 && ma
> 1)
1792 for (k
= n
; k
< j
; ++k
)
1795 e
[j
].len
= sum
? ma
- sum
: ma
;
1798 if (! (features
& FEATURE_ZEROBITFLD
) && mi
== 0)
1800 if (e
[j
].len
< mi
|| e
[j
].len
> ma
)
1801 e
[j
].len
= mi
+ (r
% (ma
+ 1 - mi
));
1803 if ((features
& FEATURE_ZEROBITFLD
) && (r
& 3) == 0
1814 e
[n
].etype
= ETYPE_STRUCT
;
1818 e
[n
].etype
= ETYPE_UNION
;
1822 e
[n
].etype
= ETYPE_STRUCT_ARRAY
;
1825 e
[n
].etype
= ETYPE_UNION_ARRAY
;
1829 e
[n
].len
= r
% (len
- n
);
1830 incr
= 1 + e
[n
].len
;
1831 generate_fields (features
, &e
[n
+ 1], &e
[n
], e
[n
].len
);
1832 if (e
[n
].etype
== ETYPE_STRUCT_ARRAY
1833 || e
[n
].etype
== ETYPE_UNION_ARRAY
)
1835 r
= generate_random ();
1836 if ((features
& FEATURE_ZEROARRAY
) && (r
& 3) == 0)
1839 if (n
+ incr
== len
&& (r
& 4)
1840 && (parent
->etype
== ETYPE_STRUCT
1841 || parent
->etype
== ETYPE_STRUCT_ARRAY
))
1844 for (k
= 0; k
< n
; ++k
)
1845 if (e
[k
].etype
!= ETYPE_BITFLD
|| e
[k
].len
)
1852 else if ((r
& 3) != 3)
1853 e
[n
].arr_len
= (r
>> 2) & 7;
1855 e
[n
].arr_len
= (r
>> 2) & 31;
1859 r
= generate_random ();
1863 i
= (features
& FEATURE_ALIGNEDPACKED
) ? NATTRIBS2
: NATTRIBS1
;
1864 e
[n
].attrib
= attributes
[r
% i
];
1865 if (! (features
& FEATURE_ALIGNEDPACKED
)
1866 && strcmp (e
[n
].attrib
, "atpa") == 0
1867 && ((e
[n
].type
>= &attrib_types
[0]
1868 && e
[n
].type
< &attrib_types
[NATYPES2
])
1869 || (e
[n
].type
>= &complex_attrib_types
[0]
1870 && e
[n
].type
< &complex_attrib_types
[NCATYPES2
])
1871 || (e
[n
].type
>= &attrib_array_types
[0]
1872 && e
[n
].type
< &attrib_array_types
[NAATYPES2
])
1873 || (e
[n
].type
>= &complex_attrib_array_types
[0]
1874 && e
[n
].type
< &complex_attrib_array_types
[NAATYPES2
])
1875 || (e
[n
].type
>= &aligned_bitfld_types
[0]
1876 && e
[n
].type
< &aligned_bitfld_types
[n_aligned_bitfld_types
])))
1883 generate_random_tests (enum FEATURE features
, int len
)
1885 struct entry e
[len
+ 1];
1887 if (len
> 'z' - 'a' + 1)
1889 memset (e
, 0, sizeof (e
));
1890 r
= generate_random ();
1892 e
[0].etype
= ETYPE_UNION
;
1894 e
[0].etype
= ETYPE_STRUCT
;
1900 if (features
& FEATURE_ALIGNEDPACKED
)
1904 e
[0].attrib
= attributes
[r
];
1906 generate_fields (features
, &e
[1], &e
[0], len
);
1910 struct { const char *name
; enum FEATURE f
; }
1913 { "complex", FEATURE_COMPLEX
},
1914 { "vector", FEATURE_VECTOR
},
1915 { "[0] :0", FEATURE_ZEROARRAY
| FEATURE_ZEROBITFLD
},
1916 { "complex vector [0]",
1917 FEATURE_COMPLEX
| FEATURE_VECTOR
| FEATURE_ZEROARRAY
},
1918 { "aligned packed complex vector [0] :0",
1919 FEATURE_COMPLEX
| FEATURE_VECTOR
| FEATURE_ZEROARRAY
1920 | FEATURE_ALIGNEDPACKED
| FEATURE_ZEROBITFLD
},
1924 main (int argc
, char **argv
)
1926 int i
, j
, count
, c
, n
= 3000;
1929 if (sizeof (int) != 4 || sizeof (long long) != 8)
1936 if (argv
[i
][0] == '-' && argv
[i
][2] == '\0')
1938 optarg
= argv
[i
+ 1];
1954 limidx
= atoi (optarg
);
1961 fprintf (stderr
, "unrecognized option %s\n", argv
[i
]);
1969 outfile
= fopen ("/dev/null", "w");
1970 if (outfile
== NULL
)
1972 fputs ("could not open /dev/null", stderr
);
1978 if (destdir
== NULL
&& !output_one
)
1981 fprintf (stderr
, "Usage:\n\
1982 %s [-e] [-s srcdir -d destdir] [-n count] [-i idx]\n\
1983 Either -s srcdir -d destdir or -i idx must be used\n", argv
[0]);
1987 if (srcdir
== NULL
&& !output_one
)
1990 for (i
= 0; i
< NTYPES2
; ++i
)
1991 if (base_types
[i
].bitfld
)
1992 bitfld_types
[n_bitfld_types
++] = base_types
[i
];
1993 for (i
= 0; i
< NATYPES2
; ++i
)
1994 if (attrib_types
[i
].bitfld
)
1995 aligned_bitfld_types
[n_aligned_bitfld_types
++] = attrib_types
[i
];
1996 for (i
= 0; i
< sizeof (features
) / sizeof (features
[0]); ++i
)
2005 for (j
= 1; j
<= 9; ++j
)
2006 while (idx
< startidx
+ j
* count
)
2007 generate_random_tests (features
[i
].f
, j
);
2008 while (idx
< startidx
+ count
* 10)
2009 generate_random_tests (features
[i
].f
, 10 + (generate_random () % 16));
2011 for (i
= 0; n
> 3000 && i
< sizeof (features
) / sizeof (features
[0]); ++i
)
2017 singles (features
[i
].f
);
2021 while (idx
< startidx
+ 1000)
2022 generate_random_tests (features
[i
].f
, 1);
2028 while (idx
< startidx
+ 100)
2029 generate_random_tests (features
[i
].f
, 1);
2032 for (j
= 2; j
<= 9; ++j
)
2033 while (idx
< startidx
+ (j
- 1) * count
)
2034 generate_random_tests (features
[i
].f
, j
);
2035 while (idx
< startidx
+ count
* 9)
2036 generate_random_tests (features
[i
].f
, 10 + (generate_random () % 16));
2041 generate_random_tests (ALL_FEATURES
, 1 + (generate_random () % 25));