OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [compat/] [struct-layout-1_generate.c] - Blame information for rev 823

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Structure layout test generator.
2
   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
3
   Contributed by Jakub Jelinek <jakub@redhat.com>.
4
 
5
This file is part of GCC.
6
 
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
10
version.
11
 
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
15
for more details.
16
 
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/>.  */
20
 
21
 
22
/* Compile with gcc -o struct-layout-1_generate{,.c} generate_random{,_r}.c */
23
 
24
/* N.B. -- This program cannot use libiberty as that will not work
25
   when testing an installed compiler.  */
26
#include <limits.h>
27
#include <stdio.h>
28
#include <stdlib.h>
29
#include <string.h>
30
#include <stddef.h>
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"
34
 
35
#if LLONG_MAX != 9223372036854775807LL && __LONG_LONG_MAX__ != 9223372036854775807LL
36
# error Need 64-bit long long
37
#endif
38
 
39
typedef unsigned int hashval_t;
40
 
41
enum TYPE
42
{
43
  TYPE_INT,
44
  TYPE_UINT,
45
  TYPE_CINT,
46
  TYPE_CUINT,
47
  TYPE_FLOAT,
48
  TYPE_CFLOAT,
49
  TYPE_DEC_FLOAT,
50
  TYPE_SENUM,
51
  TYPE_UENUM,
52
  TYPE_PTR,
53
  TYPE_FNPTR,
54
  TYPE_OTHER
55
};
56
 
57
struct types
58
{
59
  const char *name;
60
  enum TYPE type;
61
  unsigned long long int maxval;
62
  char bitfld;
63
};
64
 
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 },
90
#define NTYPES1 21
91
#else
92
#define NTYPES1 18
93
#endif
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 },
118
#endif
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]))
147
};
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]))
178
};
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]))
210
};
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 },
234
#endif
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},
267
#endif
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 },
300
#endif
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 },
333
#endif
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 },
366
#endif
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 },
399
#endif
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]))
411
};
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]))
498
};
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 },
522
#endif
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 },
551
#endif
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 },
578
#endif
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 }
601
#endif
602
#define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0]))
603
};
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]))
660
};
661
 
662
struct types bitfld_types[NTYPES2];
663
int n_bitfld_types;
664
struct types aligned_bitfld_types[NATYPES2];
665
int n_aligned_bitfld_types;
666
 
667
const char *attributes[] = {
668
"atal",
669
"atpa",
670
"atal1",
671
"atal2",
672
"atal4",
673
"atal8",
674
"atal16",
675
#define NATTRIBS1 7
676
"atalpa",
677
"atpaal",
678
"atal1pa",
679
"atal2pa",
680
"atal4pa",
681
"atal8pa",
682
"atal16pa",
683
"atpaal1",
684
"atpaal2",
685
"atpaal4",
686
"atpaal8",
687
"atpaal16"
688
#define NATTRIBS2 (sizeof (attributes) / sizeof (attributes[0]))
689
};
690
 
691
enum ETYPE
692
{
693
  ETYPE_TYPE,
694
  ETYPE_ARRAY,
695
  ETYPE_BITFLD,
696
  ETYPE_STRUCT,
697
  ETYPE_UNION,
698
  ETYPE_STRUCT_ARRAY,
699
  ETYPE_UNION_ARRAY
700
};
701
 
702
struct entry
703
{
704
#ifdef __GNUC__
705
  enum ETYPE etype : 8;
706
#else
707
  unsigned char etype;
708
#endif
709
  unsigned short len;
710
  unsigned char arr_len;
711
  struct types *type;
712
  const char *attrib;
713
  /* Used to chain together entries in the hash table.  */
714
  struct entry *next;
715
};
716
 
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];
720
 
721
static int idx, limidx, output_one, short_enums;
722
static const char *destdir;
723
static const char *srcdir;
724
FILE *outfile;
725
 
726
void
727
switchfiles (int fields)
728
{
729
  static int filecnt;
730
  static char *destbuf, *destptr;
731
  ++filecnt;
732
  if (outfile)
733
    fclose (outfile);
734
  if (output_one)
735
    {
736
      outfile = stdout;
737
      return;
738
    }
739
  if (destbuf == NULL)
740
    {
741
      size_t len = strlen (destdir);
742
      destbuf = malloc (len + 20);
743
      if (!destbuf)
744
        abort ();
745
      memcpy (destbuf, destdir, len);
746
      if (!len || destbuf[len - 1] != '/')
747
        destbuf[len++] = '/';
748
      destptr = destbuf + len;
749
    }
750
  sprintf (destptr, "t%03d_main.c", filecnt);
751
  outfile = fopen (destbuf, "w");
752
  if (outfile == NULL)
753
    {
754
    fail:
755
      fputs ("failed to create test files\n", stderr);
756
      exit (1);
757
    }
758
  fprintf (outfile, "\
759
/* { dg-options \"-I%s\" } */\n\
760
/* { dg-options \"-I%s -fno-common\" { target hppa*-*-hpux* *-*-darwin* } } */\n\
761
/* { dg-options \"-I%s -mno-base-addresses\" { target mmix-*-* } } */\n\
762
#include \"struct-layout-1.h\"\n\
763
\n\
764
#define TX(n, type, attrs, fields, ops) extern void test##n (void);\n\
765
#include \"t%03d_test.h\"\n\
766
#undef TX\n\
767
\n\
768
int main (void)\n\
769
{\n\
770
#define TX(n, type, attrs, fields, ops)   test##n ();\n\
771
#include \"t%03d_test.h\"\n\
772
#undef TX\n\
773
  if (fails)\n\
774
    {\n\
775
      fflush (stdout);\n\
776
      abort ();\n\
777
    }\n\
778
  exit (0);\n\
779
}\n", srcdir, srcdir, srcdir, filecnt, filecnt);
780
  fclose (outfile);
781
  sprintf (destptr, "t%03d_x.c", filecnt);
782
  outfile = fopen (destbuf, "w");
783
  if (outfile == NULL)
784
    goto fail;
785
  fprintf (outfile, "\
786
/* { dg-options \"-w -I%s\" } */\n\
787
/* { dg-options \"-w -I%s -fno-common\" { target hppa*-*-hpux* *-*-darwin* } } */\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);
793
  fclose (outfile);
794
  sprintf (destptr, "t%03d_y.c", filecnt);
795
  outfile = fopen (destbuf, "w");
796
  if (outfile == NULL)
797
    goto fail;
798
  fprintf (outfile, "\
799
/* { dg-options \"-w -I%s\" } */\n\
800
/* { dg-options \"-w -I%s -fno-common\" { target hppa*-*-hpux* *-*-darwin* } } */\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);
806
  fclose (outfile);
807
  sprintf (destptr, "t%03d_test.h", filecnt);
808
  outfile = fopen (destbuf, "w");
809
  if (outfile == NULL)
810
    goto fail;
811
  if (fields <= 2)
812
    limidx = idx + 300;
813
  else if (fields <= 4)
814
    limidx = idx + 200;
815
  else if (fields <= 6)
816
    limidx = idx + 100;
817
  else
818
    limidx = idx + 50;
819
}
820
 
821
unsigned long long int
822
getrandll (void)
823
{
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;
828
  return ret;
829
}
830
 
831
int
832
subfield (struct entry *e, char *letter)
833
{
834
  int i, type;
835
  char buf[20];
836
  const char *p;
837
  switch (e[0].etype)
838
    {
839
    case ETYPE_STRUCT:
840
    case ETYPE_UNION:
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)
845
        p = "struct";
846
      else
847
        p = "union";
848
      if (e[0].etype == ETYPE_STRUCT_ARRAY || e[0].etype == ETYPE_UNION_ARRAY)
849
        {
850
          if (e[0].arr_len == 255)
851
            snprintf (buf, 20, "%c[]", *letter);
852
          else
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.  */
857
          if (type == 1
858
              && ((strncmp (e[0].attrib, "atal", 4) == 0)
859
                   || strncmp (e[0].attrib, "atpaal", 6) == 0))
860
            type = 2;
861
        }
862
      else
863
        {
864
          buf[0] = *letter;
865
          buf[1] = '\0';
866
        }
867
      ++*letter;
868
      switch (type)
869
        {
870
        case 0:
871
        case 3:
872
        case 4:
873
          fprintf (outfile, "%s{", p);
874
          break;
875
        case 1:
876
          fprintf (outfile, "%s %s{", e[0].attrib, p);
877
          break;
878
        case 2:
879
          fprintf (outfile, "%s %s{", p, e[0].attrib);
880
          break;
881
        }
882
 
883
      for (i = 1; i <= e[0].len; )
884
        i += subfield (e + i, letter);
885
 
886
      switch (type)
887
        {
888
        case 0:
889
        case 1:
890
        case 2:
891
          fprintf (outfile, "}%s;", buf);
892
          break;
893
        case 3:
894
          fprintf (outfile, "}%s %s;", e[0].attrib, buf);
895
          break;
896
        case 4:
897
          fprintf (outfile, "}%s %s;", buf, e[0].attrib);
898
          break;
899
        }
900
      return 1 + e[0].len;
901
    case ETYPE_TYPE:
902
    case ETYPE_ARRAY:
903
      if (e[0].etype == ETYPE_ARRAY)
904
        {
905
          if (e[0].arr_len == 255)
906
            snprintf (buf, 20, "%c[]", *letter);
907
          else
908
            snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len);
909
        }
910
      else
911
        {
912
          buf[0] = *letter;
913
          buf[1] = '\0';
914
        }
915
      ++*letter;
916
      if (e[0].attrib)
917
        {
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))
924
            type = 2;
925
          else
926
            type = generate_random () % 3;
927
          switch (type)
928
            {
929
            case 0:
930
              fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name,
931
                       buf);
932
              break;
933
            case 1:
934
              fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib,
935
                       buf);
936
              break;
937
            case 2:
938
              fprintf (outfile, "%s %s %s;", e[0].type->name, buf,
939
                       e[0].attrib);
940
              break;
941
            }
942
        }
943
      else
944
        fprintf (outfile, "%s %s;", e[0].type->name, buf);
945
      return 1;
946
    case ETYPE_BITFLD:
947
      if (e[0].len == 0)
948
        {
949
          if (e[0].attrib)
950
            switch (generate_random () % 3)
951
              {
952
              case 0:
953
                fprintf (outfile, "%s %s:0;", e[0].attrib, e[0].type->name);
954
                break;
955
              case 1:
956
                fprintf (outfile, "%s %s:0;", e[0].type->name, e[0].attrib);
957
                break;
958
              case 2:
959
                fprintf (outfile, "%s:0 %s;", e[0].type->name, e[0].attrib);
960
                break;
961
              }
962
          else
963
            fprintf (outfile, "%s:0;", e[0].type->name);
964
          ++*letter;
965
          return 1;
966
        }
967
      switch (e[0].type->bitfld)
968
        {
969
        case 'C':
970
        case 'S':
971
        case 'I':
972
        case 'L':
973
        case 'Q':
974
          snprintf (buf, 20, "B%cN(%d)", e[0].type->bitfld, e[0].len);
975
          break;
976
        case 'B':
977
        case ' ':
978
          snprintf (buf, 20, "%d", e[0].len);
979
          break;
980
        default:
981
          abort ();
982
        }
983
      if (e[0].attrib)
984
        switch (generate_random () % 3)
985
          {
986
          case 0:
987
            fprintf (outfile, "%s %s %c:%s;", e[0].attrib, e[0].type->name,
988
                     *letter, buf);
989
            break;
990
          case 1:
991
            fprintf (outfile, "%s %s %c:%s;", e[0].type->name, e[0].attrib,
992
                     *letter, buf);
993
            break;
994
          case 2:
995
            fprintf (outfile, "%s %c:%s %s;", e[0].type->name, *letter,
996
                     buf, e[0].attrib);
997
            break;
998
          }
999
      else
1000
        fprintf (outfile, "%s %c:%s;", e[0].type->name, *letter, buf);
1001
      ++*letter;
1002
      return 1;
1003
    default:
1004
      abort ();
1005
  }
1006
}
1007
 
1008
char namebuf[1024];
1009
 
1010
void
1011
output_FNB (char mode, struct entry *e)
1012
{
1013
  unsigned long long int l1, l2, m;
1014
  int signs = 0;
1015
#ifndef SKIP_DECIMAL_FLOAT
1016
  int suffix = 0;
1017
  char DEC_SUFFIX[3][3]={"DF","DD","DL"};
1018
#endif
1019
 
1020
  const char *p, *q;
1021
 
1022
  if (e->type->type == TYPE_OTHER)
1023
    {
1024
      if (mode == 'B')
1025
        abort ();
1026
      fprintf (outfile, "N(%d,%s)", idx, namebuf);
1027
      return;
1028
    }
1029
  fprintf (outfile, "%c(%d,%s,", mode, idx, namebuf);
1030
  l1 = getrandll ();
1031
  l2 = getrandll ();
1032
  switch (e->type->type)
1033
    {
1034
    case TYPE_INT:
1035
      signs = generate_random () & 3;
1036
      m = e->type->maxval;
1037
      if (mode == 'B')
1038
        m &= e->len > 1 ? (1ULL << (e->len - 1)) - 1 : 1;
1039
      l1 &= m;
1040
      l2 &= m;
1041
      fprintf (outfile, "%s%llu%s,%s%llu%s",
1042
               (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
1043
               (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
1044
      break;
1045
    case TYPE_UINT:
1046
      m = e->type->maxval;
1047
      if (mode == 'B')
1048
        m &= (1ULL << e->len) - 1;
1049
      l1 &= m;
1050
      l2 &= m;
1051
      fprintf (outfile, "%lluU%s,%lluU%s", l1, l1 > 4294967295U ? "LL" : "",
1052
               l2, l2 > 4294967295U ? "LL" : "");
1053
      break;
1054
    case TYPE_FLOAT:
1055
      l1 &= 0xffffff;
1056
      l2 &= 0xffffff;
1057
      signs = generate_random () & 3;
1058
      fprintf (outfile, "%s%f,%s%f", (signs & 1) ? "-" : "",
1059
               ((double) l1) / 64, (signs & 2) ? "-" : "", ((double) l2) / 64);
1060
      break;
1061
#ifndef SKIP_DECIMAL_FLOAT
1062
    case TYPE_DEC_FLOAT:
1063
      l1 &= 0xffffff;
1064
      l2 &= 0xffffff;
1065
      signs = generate_random () & 3;
1066
 
1067
      /* Get the suffix of Decimal Floting Points per
1068
         e->type->name.  Distinguish these three DFP types by
1069
         e->type->name.  */
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;
1073
      else
1074
        abort ();
1075
 
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]);
1082
      break;
1083
#endif
1084
    case TYPE_CINT:
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;
1092
      l1 = getrandll ();
1093
      l2 = getrandll ();
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" : "");
1099
      break;
1100
    case TYPE_CUINT:
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" : "");
1106
      l1 = getrandll ();
1107
      l2 = getrandll ();
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" : "");
1113
      break;
1114
    case TYPE_CFLOAT:
1115
      l1 &= 0xffffff;
1116
      l2 &= 0xffffff;
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);
1121
      l1 = getrandll ();
1122
      l2 = getrandll ();
1123
      l1 &= 0xffffff;
1124
      l2 &= 0xffffff;
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);
1129
      break;
1130
    case TYPE_UENUM:
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);
1135
      else
1136
        {
1137
          p = strchr (e->type->name, '\0');
1138
          while (--p >= e->type->name && *p >= '0' && *p <= '9');
1139
          p++;
1140
          l1 %= 7;
1141
          l2 %= 7;
1142
          if (l1 > 3)
1143
            l1 += e->type->maxval - 6;
1144
          if (l2 > 3)
1145
            l2 += e->type->maxval - 6;
1146
          fprintf (outfile, "e%s_%lld,e%s_%lld", p, l1, p, l2);
1147
        }
1148
      break;
1149
    case TYPE_SENUM:
1150
      p = strchr (e->type->name, '\0');
1151
      while (--p >= e->type->name && *p >= '0' && *p <= '9');
1152
      p++;
1153
      l1 %= 7;
1154
      l2 %= 7;
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));
1160
      break;
1161
    case TYPE_PTR:
1162
      l1 %= 256;
1163
      l2 %= 256;
1164
      fprintf (outfile, "(%s)&intarray[%lld],(%s)&intarray[%lld]",
1165
               e->type->name, l1, e->type->name, l2);
1166
      break;
1167
    case TYPE_FNPTR:
1168
      l1 %= 10;
1169
      l2 %= 10;
1170
      fprintf (outfile, "fn%lld,fn%lld", l1, l2);
1171
      break;
1172
    default:
1173
      abort ();
1174
    }
1175
  fputs (")", outfile);
1176
}
1177
 
1178
int
1179
subvalues (struct entry *e, char *p, char *letter)
1180
{
1181
  int i, j;
1182
  char *q;
1183
  if (p >= namebuf + sizeof (namebuf) - 32)
1184
    abort ();
1185
  p[0] = *letter;
1186
  p[1] = '\0';
1187
  q = p + 1;
1188
  switch (e[0].etype)
1189
    {
1190
    case ETYPE_STRUCT_ARRAY:
1191
    case ETYPE_UNION_ARRAY:
1192
      if (e[0].arr_len == 0 || e[0].arr_len == 255)
1193
        {
1194
          *letter += 1 + e[0].len;
1195
          return 1 + e[0].len;
1196
        }
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');
1201
      /* FALLTHROUGH */
1202
    case ETYPE_STRUCT:
1203
    case ETYPE_UNION:
1204
      *q++ = '.';
1205
      ++*letter;
1206
      for (i = 1; i <= e[0].len; )
1207
        {
1208
          i += subvalues (e + i, q, letter);
1209
          if (e[0].etype == ETYPE_UNION || e[0].etype == ETYPE_UNION_ARRAY)
1210
            {
1211
              *letter += e[0].len - i + 1;
1212
              break;
1213
            }
1214
        }
1215
      return 1 + e[0].len;
1216
    case ETYPE_TYPE:
1217
      ++*letter;
1218
      output_FNB ('F', e);
1219
      return 1;
1220
    case ETYPE_ARRAY:
1221
      if (e[0].arr_len == 0 || e[0].arr_len == 255)
1222
        {
1223
          ++*letter;
1224
          return 1;
1225
        }
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)
1231
        {
1232
          j = generate_random () % e[0].arr_len;
1233
          if (i != j)
1234
            {
1235
              snprintf (p, sizeof (namebuf) - (p - namebuf),
1236
                        "%c[%d]", *letter, j);
1237
              output_FNB ('F', e);
1238
            }
1239
        }
1240
      ++*letter;
1241
      return 1;
1242
    case ETYPE_BITFLD:
1243
      ++*letter;
1244
      if (e[0].len != 0)
1245
        output_FNB ('B', e);
1246
      return 1;
1247
    }
1248
}
1249
 
1250
/* DERIVED FROM:
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
--------------------------------------------------------------------
1257
*/
1258
 
1259
/*
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:
1271
      a -= b;
1272
      a -= c; x = (c>>13);
1273
      b -= c; a ^= x;
1274
      b -= a; x = (a<<8);
1275
      c -= a; b ^= x;
1276
      c -= b; x = (b>>13);
1277
      ...
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
--------------------------------------------------------------------
1284
*/
1285
/* same, but slower, works on systems that might have 8 byte hashval_t's */
1286
#define mix(a,b,c) \
1287
{ \
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; \
1297
}
1298
 
1299
/*
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.
1308
 
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.
1314
 
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);
1317
 
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.
1320
 
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
--------------------------------------------------------------------
1325
*/
1326
 
1327
static hashval_t
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 */)
1332
{
1333
  register const unsigned char *k = (const unsigned char *)k_in;
1334
  register hashval_t a,b,c,len;
1335
 
1336
  /* Set up the internal state */
1337
  len = length;
1338
  a = b = 0x9e3779b9;  /* the golden ratio; an arbitrary value */
1339
  c = initval;           /* the previous hash value */
1340
 
1341
  /*---------------------------------------- handle most of the key */
1342
    while (len >= 12)
1343
      {
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));
1347
        mix(a,b,c);
1348
        k += 12; len -= 12;
1349
      }
1350
 
1351
  /*------------------------------------- handle the last 11 bytes */
1352
  c += length;
1353
  switch(len)              /* all the case statements fall through */
1354
    {
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);
1362
    case 5 : b+=k[4];
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);
1366
    case 1 : a+=k[0];
1367
      /* case 0: nothing left to add */
1368
    }
1369
  mix(a,b,c);
1370
  /*-------------------------------------------- report the result */
1371
  return c;
1372
}
1373
 
1374
hashval_t
1375
e_hash (const void *a)
1376
{
1377
  const struct entry *e = a;
1378
  hashval_t ret = 0;
1379
  int i;
1380
 
1381
  if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION)
1382
    abort ();
1383
  for (i = 0; i <= e[0].len; ++i)
1384
    {
1385
      int attriblen;
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);
1389
      if (e[i].attrib)
1390
        ret = iterative_hash (e[i].attrib, attriblen, ret);
1391
    }
1392
  return ret;
1393
}
1394
 
1395
int
1396
e_eq (const void *a, const void *b)
1397
{
1398
  const struct entry *ea = a, *eb = b;
1399
  int i;
1400
  if (ea[0].etype != ETYPE_STRUCT && ea[0].etype != ETYPE_UNION)
1401
    abort ();
1402
  if (ea[0].len != eb[0].len)
1403
    return 0;
1404
  for (i = 0; i <= ea[0].len; ++i)
1405
    {
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)
1410
        return 0;
1411
      if ((ea[i].attrib == NULL) ^ (eb[i].attrib == NULL))
1412
        return 0;
1413
      if (ea[i].attrib && strcmp (ea[i].attrib, eb[i].attrib) != 0)
1414
        return 0;
1415
    }
1416
  return 1;
1417
}
1418
 
1419
static int
1420
e_exists (const struct entry *e)
1421
{
1422
  struct entry *h;
1423
  hashval_t hval;
1424
 
1425
  hval = e_hash (e);
1426
  for (h = hash_table[hval % HASH_SIZE]; h; h = h->next)
1427
    if (e_eq (e, h))
1428
      return 1;
1429
  return 0;
1430
}
1431
 
1432
static void
1433
e_insert (struct entry *e)
1434
{
1435
  hashval_t hval;
1436
 
1437
  hval = e_hash (e);
1438
  e->next = hash_table[hval % HASH_SIZE];
1439
  hash_table[hval % HASH_SIZE] = e;
1440
}
1441
 
1442
void
1443
output (struct entry *e)
1444
{
1445
  int i;
1446
  char c;
1447
  struct entry *n;
1448
  const char *skip_cint = "";
1449
 
1450
  if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION)
1451
    abort ();
1452
 
1453
  if (e_exists (e))
1454
    return;
1455
 
1456
  n = (struct entry *) malloc ((e[0].len + 1) * sizeof (struct entry));
1457
  memcpy (n, e, (e[0].len + 1) * sizeof (struct entry));
1458
  e_insert (n);
1459
 
1460
  if (idx == limidx)
1461
    switchfiles (e[0].len);
1462
 
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))
1466
      break;
1467
  if (i <= e[0].len)
1468
    skip_cint = "CI";
1469
  if (e[0].attrib)
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",
1473
             e[0].attrib);
1474
  else if (e[0].etype == ETYPE_STRUCT)
1475
    fprintf (outfile, "T%s(%d,", skip_cint, idx);
1476
  else
1477
    fprintf (outfile, "U%s(%d,", skip_cint, idx);
1478
  c = 'a';
1479
  for (i = 1; i <= e[0].len; )
1480
    i += subfield (e + i, &c);
1481
  fputs (",", outfile);
1482
  c = 'a';
1483
  for (i = 1; i <= e[0].len; )
1484
    {
1485
      i += subvalues (e + i, namebuf, &c);
1486
      if (e[0].etype == ETYPE_UNION)
1487
        break;
1488
    }
1489
  fputs (")\n", outfile);
1490
  if (output_one && idx == limidx)
1491
    exit (0);
1492
  ++idx;
1493
}
1494
 
1495
enum FEATURE
1496
{
1497
  FEATURE_VECTOR = 1,
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
1504
};
1505
 
1506
void
1507
singles (enum FEATURE features)
1508
{
1509
  struct entry e[2];
1510
  int i;
1511
  memset (e, 0, sizeof (e));
1512
  e[0].etype = ETYPE_STRUCT;
1513
  output (e);
1514
  e[0].etype = ETYPE_UNION;
1515
  output (e);
1516
  for (i = 0;
1517
       i < ((features & FEATURE_ALIGNEDPACKED) ? NATTRIBS2 : NATTRIBS1);
1518
       ++i)
1519
    {
1520
      e[0].attrib = attributes[i];
1521
      e[0].etype = ETYPE_STRUCT;
1522
      output (e);
1523
      e[0].etype = ETYPE_UNION;
1524
      output (e);
1525
    }
1526
  e[0].len = 1;
1527
  e[0].attrib = NULL;
1528
  for (i = 0; i < NTYPES2; ++i)
1529
    {
1530
      e[0].etype = ETYPE_STRUCT;
1531
      e[1].etype = ETYPE_TYPE;
1532
      e[1].type = &base_types[i];
1533
      output (e);
1534
      e[0].etype = ETYPE_UNION;
1535
      output (e);
1536
    }
1537
  if (features & FEATURE_COMPLEX)
1538
    for (i = 0; i < NCTYPES2; ++i)
1539
      {
1540
        e[0].etype = ETYPE_STRUCT;
1541
        e[1].etype = ETYPE_TYPE;
1542
        e[1].type = &complex_types[i];
1543
        output (e);
1544
        e[0].etype = ETYPE_UNION;
1545
        output (e);
1546
      }
1547
  if (features & FEATURE_VECTOR)
1548
    for (i = 0; i < NVTYPES2; ++i)
1549
      {
1550
        e[0].etype = ETYPE_STRUCT;
1551
        e[1].etype = ETYPE_TYPE;
1552
        e[1].type = &vector_types[i];
1553
        output (e);
1554
        e[0].etype = ETYPE_UNION;
1555
        output (e);
1556
      }
1557
}
1558
 
1559
void
1560
choose_type (enum FEATURE features, struct entry *e, int r, int in_array)
1561
{
1562
  int i;
1563
 
1564
  i = NTYPES2 - NTYPES1;
1565
  if (features & FEATURE_COMPLEX)
1566
    i += NCTYPES2;
1567
  if (features & FEATURE_VECTOR)
1568
    i += NVTYPES2;
1569
  if ((r & 3) == 0)
1570
    {
1571
      if (in_array)
1572
        {
1573
          i += NAATYPES2;
1574
          if (features & FEATURE_COMPLEX)
1575
            i += NCAATYPES2;
1576
        }
1577
      else
1578
        {
1579
          i += NATYPES2;
1580
          if (features & FEATURE_COMPLEX)
1581
            i += NCATYPES2;
1582
        }
1583
    }
1584
  r >>= 2;
1585
  r %= i;
1586
  if (r < NTYPES2 - NTYPES1)
1587
    e->type = &base_types[r + NTYPES1];
1588
  r -= NTYPES2 - NTYPES1;
1589
  if (e->type == NULL && (features & FEATURE_COMPLEX))
1590
    {
1591
      if (r < NCTYPES2)
1592
        e->type = &complex_types[r];
1593
      r -= NCTYPES2;
1594
    }
1595
  if (e->type == NULL && (features & FEATURE_VECTOR))
1596
    {
1597
      if (r < NVTYPES2)
1598
        e->type = &vector_types[r];
1599
      r -= NVTYPES2;
1600
    }
1601
  if (e->type == NULL && !in_array)
1602
    {
1603
      if (r < NATYPES2)
1604
        e->type = &attrib_types[r];
1605
      r -= NATYPES2;
1606
    }
1607
  if (e->type == NULL && !in_array && (features & FEATURE_COMPLEX))
1608
    {
1609
      if (r < NCATYPES2)
1610
        e->type = &complex_attrib_types[r];
1611
      r -= NCATYPES2;
1612
    }
1613
  if (e->type == NULL && in_array)
1614
    {
1615
      if (r < NAATYPES2)
1616
        e->type = &attrib_array_types[r];
1617
      r -= NAATYPES2;
1618
    }
1619
  if (e->type == NULL && in_array && (features & FEATURE_COMPLEX))
1620
    {
1621
      if (r < NCAATYPES2)
1622
        e->type = &complex_attrib_array_types[r];
1623
      r -= NCAATYPES2;
1624
    }
1625
  if (e->type == NULL)
1626
    abort ();
1627
}
1628
 
1629
/* This is from gcc.c-torture/execute/builtin-bitops-1.c.  */
1630
static int
1631
my_ffsll (unsigned long long x)
1632
{
1633
  int i;
1634
  if (x == 0)
1635
    return 0;
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))
1639
      break;
1640
  return i + 1;
1641
}
1642
 
1643
void
1644
generate_fields (enum FEATURE features, struct entry *e, struct entry *parent,
1645
                 int len)
1646
{
1647
  int r, i, j, ret = 1, n, incr, sametype;
1648
 
1649
  for (n = 0; n < len; n += incr)
1650
    {
1651
      r = generate_random ();
1652
      /* 50% ETYPE_TYPE base_types NTYPES1
1653
         12.5% ETYPE_TYPE other
1654
         12.5% ETYPE_ARRAY
1655
         12.5% ETYPE_BITFLD
1656
         12.5% ETYPE_STRUCT|ETYPE_UNION|ETYPE_STRUCT_ARRAY|ETYPE_UNION_ARRAY */
1657
      i = (r & 7);
1658
      r >>= 3;
1659
      incr = 1;
1660
      switch (i)
1661
        {
1662
        case 0:
1663
        case 1:
1664
        case 2:
1665
        case 3:
1666
          e[n].etype = ETYPE_TYPE;
1667
          e[n].type = &base_types[r % NTYPES1];
1668
          break;
1669
        case 4:
1670
          e[n].etype = ETYPE_TYPE;
1671
          choose_type (features, &e[n], r, 0);
1672
          break;
1673
        case 5:
1674
          e[n].etype = ETYPE_ARRAY;
1675
          i = r & 1;
1676
          r >>= 1;
1677
          if (i)
1678
            e[n].type = &base_types[r % NTYPES1];
1679
          else
1680
            choose_type (features, &e[n], r, 1);
1681
          r = generate_random ();
1682
          if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0)
1683
            {
1684
              e[n].arr_len = 0;
1685
              if (n == len - 1 && (r & 4)
1686
                  && (parent->etype == ETYPE_STRUCT
1687
                      || parent->etype == ETYPE_STRUCT_ARRAY))
1688
                {
1689
                  int k;
1690
                  for (k = 0; k < n; ++k)
1691
                    if (e[k].etype != ETYPE_BITFLD || e[k].len)
1692
                      {
1693
                        e[n].arr_len = 255;
1694
                        break;
1695
                      }
1696
                }
1697
            }
1698
          else if ((r & 3) != 3)
1699
            e[n].arr_len = (r >> 2) & 7;
1700
          else
1701
            e[n].arr_len = (r >> 2) & 31;
1702
          break;
1703
        case 6:
1704
          sametype = 1;
1705
          switch (r & 7)
1706
            {
1707
            case 0:
1708
            case 1:
1709
            case 2:
1710
              break;
1711
            case 3:
1712
            case 4:
1713
            case 5:
1714
              incr = 1 + (r >> 3) % (len - n);
1715
              break;
1716
            case 6:
1717
            case 7:
1718
              sametype = 0;
1719
              incr = 1 + (r >> 3) % (len - n);
1720
              break;
1721
            }
1722
          for (j = n; j < n + incr; ++j)
1723
            {
1724
              int mi, ma;
1725
 
1726
              e[j].etype = ETYPE_BITFLD;
1727
              if (j == n || !sametype)
1728
                {
1729
                  int k;
1730
                  r = generate_random ();
1731
                  k = r & 3;
1732
                  r >>= 2;
1733
                  if (!k)
1734
                    e[j].type
1735
                      = &aligned_bitfld_types[r % n_aligned_bitfld_types];
1736
                  else
1737
                    e[j].type
1738
                      = &bitfld_types[r % n_bitfld_types];
1739
                }
1740
              else
1741
                e[j].type = e[n].type;
1742
              r = generate_random ();
1743
              mi = 0;
1744
              ma = 0;
1745
              switch (e[j].type->bitfld)
1746
                {
1747
                case 'C': ma = 8; break;
1748
                case 'S': ma = 16; break;
1749
                case 'I': ma = 32; break;
1750
                case 'L':
1751
                case 'Q': ma = 64; break;
1752
                case 'B': ma = 1; break;
1753
                case ' ':
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);
1758
                  else
1759
                    abort ();
1760
                  if (!mi)
1761
                    mi = 1;
1762
                  if (mi > 32)
1763
                    ma = 64;
1764
                  else if (mi > 16 || !short_enums)
1765
                    ma = 32;
1766
                  else if (mi > 8)
1767
                    ma = 16;
1768
                  else
1769
                    ma = 8;
1770
                  break;
1771
                default:
1772
                  abort ();
1773
                }
1774
              e[j].len = ma + 1;
1775
              if (sametype && (r & 3) == 0 && ma > 1)
1776
                {
1777
                  int sum = 0, k;
1778
                  for (k = n; k < j; ++k)
1779
                    sum += e[k].len;
1780
                  sum %= ma;
1781
                  e[j].len = sum ? ma - sum : ma;
1782
                }
1783
              r >>= 2;
1784
              if (! (features & FEATURE_ZEROBITFLD) && mi == 0)
1785
                mi = 1;
1786
              if (e[j].len < mi || e[j].len > ma)
1787
                e[j].len = mi + (r % (ma + 1 - mi));
1788
              r >>= 6;
1789
              if ((features & FEATURE_ZEROBITFLD) && (r & 3) == 0
1790
                  && mi == 0)
1791
                e[j].len = 0;
1792
            }
1793
          break;
1794
        case 7:
1795
          switch (r & 7)
1796
            {
1797
            case 0:
1798
            case 1:
1799
            case 2:
1800
              e[n].etype = ETYPE_STRUCT;
1801
              break;
1802
            case 3:
1803
            case 4:
1804
              e[n].etype = ETYPE_UNION;
1805
              break;
1806
            case 5:
1807
            case 6:
1808
              e[n].etype = ETYPE_STRUCT_ARRAY;
1809
              break;
1810
            case 7:
1811
              e[n].etype = ETYPE_UNION_ARRAY;
1812
              break;
1813
            }
1814
          r >>= 3;
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)
1820
            {
1821
              r = generate_random ();
1822
              if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0)
1823
                {
1824
                  e[n].arr_len = 0;
1825
                  if (n + incr == len && (r & 4)
1826
                      && (parent->etype == ETYPE_STRUCT
1827
                          || parent->etype == ETYPE_STRUCT_ARRAY))
1828
                    {
1829
                      int k;
1830
                      for (k = 0; k < n; ++k)
1831
                        if (e[k].etype != ETYPE_BITFLD || e[k].len)
1832
                          {
1833
                            e[n].arr_len = 255;
1834
                            break;
1835
                          }
1836
                    }
1837
                }
1838
              else if ((r & 3) != 3)
1839
                e[n].arr_len = (r >> 2) & 7;
1840
              else
1841
                e[n].arr_len = (r >> 2) & 31;
1842
            }
1843
          break;
1844
        }
1845
      r = generate_random ();
1846
      if ((r & 7) == 0)
1847
        {
1848
          r >>= 3;
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])))
1863
            e[n].attrib = NULL;
1864
        }
1865
    }
1866
}
1867
 
1868
void
1869
generate_random_tests (enum FEATURE features, int len)
1870
{
1871
  struct entry e[len + 1];
1872
  int i, r;
1873
  if (len > 'z' - 'a' + 1)
1874
    abort ();
1875
  memset (e, 0, sizeof (e));
1876
  r = generate_random ();
1877
  if ((r & 7) == 0)
1878
    e[0].etype = ETYPE_UNION;
1879
  else
1880
    e[0].etype = ETYPE_STRUCT;
1881
  r >>= 3;
1882
  e[0].len = len;
1883
  if ((r & 31) == 0)
1884
    {
1885
      r >>= 5;
1886
      if (features & FEATURE_ALIGNEDPACKED)
1887
        r %= NATTRIBS2;
1888
      else
1889
        r %= NATTRIBS1;
1890
      e[0].attrib = attributes[r];
1891
    }
1892
  generate_fields (features, &e[1], &e[0], len);
1893
  output (e);
1894
}
1895
 
1896
struct { const char *name; enum FEATURE f; }
1897
features[] = {
1898
{ "normal", 0 },
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 },
1907
};
1908
 
1909
int
1910
main (int argc, char **argv)
1911
{
1912
  int i, j, count, c, n = 3000;
1913
  char *optarg;
1914
 
1915
  if (sizeof (int) != 4 || sizeof (long long) != 8)
1916
    return 1;
1917
 
1918
  i = 1;
1919
  while (i < argc)
1920
    {
1921
      c = '\0';
1922
      if (argv[i][0] == '-' && argv[i][2] == '\0')
1923
        c = argv[i][1];
1924
      optarg = argv[i + 1];
1925
      if (!optarg)
1926
        goto usage;
1927
      switch (c)
1928
        {
1929
        case 'n':
1930
          n = atoi (optarg);
1931
          break;
1932
        case 'd':
1933
          destdir = optarg;
1934
          break;
1935
        case 's':
1936
          srcdir = optarg;
1937
          break;
1938
        case 'i':
1939
          output_one = 1;
1940
          limidx = atoi (optarg);
1941
          break;
1942
        case 'e':
1943
          short_enums = 1;
1944
          i--;
1945
          break;
1946
        default:
1947
          fprintf (stderr, "unrecognized option %s\n", argv[i]);
1948
          goto usage;
1949
      }
1950
      i += 2;
1951
    }
1952
 
1953
  if (output_one)
1954
    {
1955
      outfile = fopen ("/dev/null", "w");
1956
      if (outfile == NULL)
1957
        {
1958
          fputs ("could not open /dev/null", stderr);
1959
          return 1;
1960
        }
1961
      n = limidx + 1;
1962
    }
1963
 
1964
  if (destdir == NULL && !output_one)
1965
    {
1966
    usage:
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]);
1970
      return 1;
1971
    }
1972
 
1973
  if (srcdir == NULL && !output_one)
1974
    goto usage;
1975
 
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)
1983
    {
1984
      int startidx = idx;
1985
      if (! output_one)
1986
        limidx = idx;
1987
      if (!i)
1988
        count = 200;
1989
      else
1990
        count = 20;
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));
1996
    }
1997
  for (i = 0; n > 3000 && i < sizeof (features) / sizeof (features[0]); ++i)
1998
    {
1999
      int startidx;
2000
      startidx = idx;
2001
      if (! output_one)
2002
        limidx = idx;
2003
      singles (features[i].f);
2004
      if (!i)
2005
        {
2006
          count = 1000;
2007
          while (idx < startidx + 1000)
2008
            generate_random_tests (features[i].f, 1);
2009
        }
2010
      else
2011
        {
2012
          startidx = idx;
2013
          count = 100;
2014
          while (idx < startidx + 100)
2015
            generate_random_tests (features[i].f, 1);
2016
        }
2017
      startidx = idx;
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));
2023
    }
2024
  if (! output_one)
2025
    limidx = idx;
2026
  while (idx < n)
2027
    generate_random_tests (ALL_FEATURES, 1 + (generate_random () % 25));
2028
  fclose (outfile);
2029
  return 0;
2030
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.