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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [gcc/] [testsuite/] [gcc.dg/] [compat/] [struct-layout-1_generate.c] - Blame information for rev 516

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* Structure layout test generator.
2
   Copyright (C) 2004, 2005, 2007, 2008, 2009 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
#if defined __MSVCRT__ 
40
#define COMPAT_PRLL "I64"
41
#else 
42
#define COMPAT_PRLL "ll"
43
#endif
44
 
45
const char *dg_options[] = {
46
"/* { dg-options \"%s-I%s\" } */\n",
47
"/* { dg-options \"%s-I%s -Wno-abi\" } */\n",
48
"/* { dg-options \"%s-I%s -mno-mmx -Wno-abi\" { target i?86-*-* x86_64-*-* } } */\n",
49
"/* { dg-options \"%s-I%s -fno-common\" { target hppa*-*-hpux* powerpc*-*-darwin* } } */\n",
50
"/* { dg-options \"%s-I%s -mno-mmx -fno-common -Wno-abi\" { target i?86-*-darwin* x86_64-*-darwin* } } */\n",
51
"/* { dg-options \"%s-I%s -mno-base-addresses\" { target mmix-*-* } } */\n",
52
"/* { dg-options \"%s-I%s -mlongcalls -mtext-section-literals\" { target xtensa*-*-* } } */\n"
53
#define NDG_OPTIONS (sizeof (dg_options) / sizeof (dg_options[0]))
54
};
55
 
56
typedef unsigned int hashval_t;
57
 
58
enum TYPE
59
{
60
  TYPE_INT,
61
  TYPE_UINT,
62
  TYPE_CINT,
63
  TYPE_CUINT,
64
  TYPE_FLOAT,
65
  TYPE_CFLOAT,
66
  TYPE_DEC_FLOAT,
67
  TYPE_SENUM,
68
  TYPE_UENUM,
69
  TYPE_PTR,
70
  TYPE_FNPTR,
71
  TYPE_OTHER
72
};
73
 
74
struct types
75
{
76
  const char *name;
77
  enum TYPE type;
78
  unsigned long long int maxval;
79
  char bitfld;
80
};
81
 
82
struct types base_types[] = {
83
/* As we don't know whether char will be signed or not, just limit ourselves
84
   to unsigned values less than maximum signed char value.  */
85
{ "char", TYPE_UINT, 127, 'C' },
86
{ "signed char", TYPE_INT, 127, 'C' },
87
{ "unsigned char", TYPE_UINT, 255, 'C' },
88
{ "short int", TYPE_INT, 32767, 'S' },
89
{ "unsigned short int", TYPE_UINT, 65535, 'S' },
90
{ "int", TYPE_INT, 2147483647, 'I' },
91
{ "unsigned int", TYPE_UINT, 4294967295U, 'I' },
92
{ "long int", TYPE_INT, 9223372036854775807LL, 'L' },
93
{ "unsigned long int", TYPE_UINT, 18446744073709551615ULL, 'L' },
94
{ "long long int", TYPE_INT, 9223372036854775807LL, 'Q' },
95
{ "unsigned long long int", TYPE_UINT, 18446744073709551615ULL, 'Q' },
96
{ "bool", TYPE_UINT, 1, 'B' },
97
{ "void *", TYPE_PTR, 0, 0 },
98
{ "char *", TYPE_PTR, 0, 0 },
99
{ "int *", TYPE_PTR, 0, 0 },
100
{ "float", TYPE_FLOAT, 0, 0 },
101
{ "double", TYPE_FLOAT, 0, 0 },
102
{ "long double", TYPE_FLOAT, 0, 0 },
103
#ifndef SKIP_DECIMAL_FLOAT
104
{ "_Decimal32", TYPE_DEC_FLOAT, 0, 0 },
105
{ "_Decimal64", TYPE_DEC_FLOAT, 0, 0 },
106
{ "_Decimal128", TYPE_DEC_FLOAT, 0, 0 },
107
#define NTYPES1 21
108
#else
109
#define NTYPES1 18
110
#endif
111
{ "Tchar", TYPE_UINT, 127, 'C' },
112
{ "Tschar", TYPE_INT, 127, 'C' },
113
{ "Tuchar", TYPE_UINT, 255, 'C' },
114
{ "Tshort", TYPE_INT, 32767, 'S' },
115
{ "Tushort", TYPE_UINT, 65535, 'S' },
116
{ "Tint", TYPE_INT, 2147483647, 'I' },
117
{ "Tuint", TYPE_UINT, 4294967295U, 'I' },
118
{ "Tlong", TYPE_INT, 9223372036854775807LL, 'L' },
119
{ "Tulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
120
{ "Tllong", TYPE_INT, 9223372036854775807LL, 'Q' },
121
{ "Tullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
122
{ "Tbool", TYPE_UINT, 1, 'B' },
123
{ "size_t", TYPE_UINT, 18446744073709551615ULL, 0 },
124
{ "Tptr", TYPE_PTR, 0, 0 },
125
{ "Tcptr", TYPE_PTR, 0, 0 },
126
{ "Tiptr", TYPE_PTR, 0, 0 },
127
{ "Tfnptr", TYPE_FNPTR, 0, 0 },
128
{ "Tfloat", TYPE_FLOAT, 0, 0 },
129
{ "Tdouble", TYPE_FLOAT, 0, 0 },
130
{ "Tldouble", TYPE_FLOAT, 0, 0 },
131
#ifndef SKIP_DECIMAL_FLOAT
132
{ "TDecimal32", TYPE_DEC_FLOAT, 0, 0 },
133
{ "TDecimal64", TYPE_DEC_FLOAT, 0, 0 },
134
{ "TDecimal128", TYPE_DEC_FLOAT, 0, 0 },
135
#endif
136
{ "enum E0", TYPE_UENUM, 0, ' ' },
137
{ "enum E1", TYPE_UENUM, 1, ' ' },
138
{ "enum E2", TYPE_SENUM, 3, ' ' },
139
{ "enum E3", TYPE_SENUM, 127, ' ' },
140
{ "enum E4", TYPE_UENUM, 255, ' ' },
141
{ "enum E5", TYPE_SENUM, 32767, ' ' },
142
{ "enum E6", TYPE_UENUM, 65535, ' ' },
143
{ "enum E7", TYPE_SENUM, 2147483647, ' ' },
144
{ "enum E8", TYPE_UENUM, 4294967295U, ' ' },
145
{ "enum E9", TYPE_SENUM, 1099511627775LL, ' ' },
146
{ "TE0", TYPE_UENUM, 0, ' ' },
147
{ "TE1", TYPE_UENUM, 1, ' ' },
148
{ "TE2", TYPE_SENUM, 3, ' ' },
149
{ "TE3", TYPE_SENUM, 127, ' ' },
150
{ "TE4", TYPE_UENUM, 255, ' ' },
151
{ "TE5", TYPE_SENUM, 32767, ' ' },
152
{ "TE6", TYPE_UENUM, 65535, ' ' },
153
{ "TE7", TYPE_SENUM, 2147483647, ' ' },
154
{ "TE8", TYPE_UENUM, 4294967295U, ' ' },
155
{ "TE9", TYPE_SENUM, 1099511627775LL, ' ' },
156
/* vector-defs.h typedefs */
157
{ "qi", TYPE_INT, 127, 0 },
158
{ "hi", TYPE_INT, 32767, 0 },
159
{ "si", TYPE_INT, 2147483647, 0 },
160
{ "di", TYPE_INT, 9223372036854775807LL, 0 },
161
{ "sf", TYPE_FLOAT, 0, 0 },
162
{ "df", TYPE_FLOAT, 0, 0 }
163
#define NTYPES2 (sizeof (base_types) / sizeof (base_types[0]))
164
};
165
struct types complex_types[] = {
166
{ "_Complex char", TYPE_CUINT, 127, 0 },
167
{ "_Complex signed char", TYPE_CINT, 127, 0 },
168
{ "_Complex unsigned char", TYPE_CUINT, 255, 0 },
169
{ "_Complex short int", TYPE_CINT, 32767, 0 },
170
{ "_Complex unsigned short int", TYPE_CUINT, 65535, 0 },
171
{ "_Complex int", TYPE_CINT, 2147483647, 0 },
172
{ "_Complex unsigned int", TYPE_CUINT, 4294967295U, 0 },
173
{ "_Complex long int", TYPE_CINT, 9223372036854775807LL, 0 },
174
{ "_Complex unsigned long int", TYPE_CUINT, 18446744073709551615ULL, 0 },
175
{ "_Complex long long int", TYPE_CINT, 9223372036854775807LL, 0 },
176
{ "_Complex unsigned long long int", TYPE_CUINT, 18446744073709551615ULL, 0 },
177
{ "_Complex float", TYPE_CFLOAT, 0, 0 },
178
{ "_Complex double", TYPE_CFLOAT, 0, 0 },
179
{ "_Complex long double", TYPE_CFLOAT, 0, 0 },
180
{ "Tcchar", TYPE_CUINT, 127, 0 },
181
{ "Tcschar", TYPE_CINT, 127, 0 },
182
{ "Tcuchar", TYPE_CUINT, 255, 0 },
183
{ "Tcshort", TYPE_CINT, 32767, 0 },
184
{ "Tcushort", TYPE_CUINT, 65535, 0 },
185
{ "Tcint", TYPE_CINT, 2147483647, 0 },
186
{ "Tcuint", TYPE_CUINT, 4294967295U, 0 },
187
{ "Tclong", TYPE_CINT, 9223372036854775807LL, 0 },
188
{ "Tculong", TYPE_CUINT, 18446744073709551615ULL, 0 },
189
{ "Tcllong", TYPE_CINT, 9223372036854775807LL, 0 },
190
{ "Tcullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
191
{ "Tcfloat", TYPE_CFLOAT, 0, 0 },
192
{ "Tcdouble", TYPE_CFLOAT, 0, 0 },
193
{ "Tcldouble", TYPE_CFLOAT, 0, 0 }
194
#define NCTYPES2 (sizeof (complex_types) / sizeof (complex_types[0]))
195
};
196
struct types vector_types[] = {
197
/* vector-defs.h typedefs */
198
{ "v8qi", TYPE_OTHER, 0, 0 },
199
{ "v16qi", TYPE_OTHER, 0, 0 },
200
{ "v32qi", TYPE_OTHER, 0, 0 },
201
{ "v2hi", TYPE_OTHER, 0, 0 },
202
{ "v4hi", TYPE_OTHER, 0, 0 },
203
{ "v8hi", TYPE_OTHER, 0, 0 },
204
{ "v16hi", TYPE_OTHER, 0, 0 },
205
{ "v2si", TYPE_OTHER, 0, 0 },
206
{ "v4si", TYPE_OTHER, 0, 0 },
207
{ "v8si", TYPE_OTHER, 0, 0 },
208
{ "v1di", TYPE_OTHER, 0, 0 },
209
{ "v2di", TYPE_OTHER, 0, 0 },
210
{ "v4di", TYPE_OTHER, 0, 0 },
211
{ "v2sf", TYPE_OTHER, 0, 0 },
212
{ "v4sf", TYPE_OTHER, 0, 0 },
213
{ "v8sf", TYPE_OTHER, 0, 0 },
214
{ "v16sf", TYPE_OTHER, 0, 0 },
215
{ "v2df", TYPE_OTHER, 0, 0 },
216
{ "v4df", TYPE_OTHER, 0, 0 },
217
{ "u8qi", TYPE_OTHER, 0, 0 },
218
{ "u16qi", TYPE_OTHER, 0, 0 },
219
{ "u32qi", TYPE_OTHER, 0, 0 },
220
{ "u2hi", TYPE_OTHER, 0, 0 },
221
{ "u4hi", TYPE_OTHER, 0, 0 },
222
{ "u8hi", TYPE_OTHER, 0, 0 },
223
{ "u16hi", TYPE_OTHER, 0, 0 },
224
{ "u2si", TYPE_OTHER, 0, 0 },
225
{ "u4si", TYPE_OTHER, 0, 0 },
226
{ "u8si", TYPE_OTHER, 0, 0 },
227
{ "u1di", TYPE_OTHER, 0, 0 },
228
{ "u2di", TYPE_OTHER, 0, 0 },
229
{ "u4di", TYPE_OTHER, 0, 0 },
230
{ "u2sf", TYPE_OTHER, 0, 0 },
231
{ "u4sf", TYPE_OTHER, 0, 0 },
232
{ "u8sf", TYPE_OTHER, 0, 0 },
233
{ "u16sf", TYPE_OTHER, 0, 0 },
234
{ "u2df", TYPE_OTHER, 0, 0 },
235
{ "u4df", TYPE_OTHER, 0, 0 },
236
{ "__m64", TYPE_OTHER, 0, 0 },
237
{ "__m128", TYPE_OTHER, 0, 0 }
238
#define NVTYPES2 (sizeof (vector_types) / sizeof (vector_types[0]))
239
};
240
struct types attrib_types[] = {
241
{ "Talchar", TYPE_UINT, 127, 'C' },
242
{ "Talschar", TYPE_INT, 127, 'C' },
243
{ "Taluchar", TYPE_UINT, 255, 'C' },
244
{ "Talshort", TYPE_INT, 32767, 'S' },
245
{ "Talushort", TYPE_UINT, 65535, 'S' },
246
{ "Talint", TYPE_INT, 2147483647, 'I' },
247
{ "Taluint", TYPE_UINT, 4294967295U, 'I' },
248
{ "Tallong", TYPE_INT, 9223372036854775807LL, 'L' },
249
{ "Talulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
250
{ "Talllong", TYPE_INT, 9223372036854775807LL, 'Q' },
251
{ "Talullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
252
{ "Talbool", TYPE_UINT, 1, 'B' },
253
{ "Talptr", TYPE_PTR, 0, 0 },
254
{ "Talcptr", TYPE_PTR, 0, 0 },
255
{ "Taliptr", TYPE_PTR, 0, 0 },
256
{ "Talfloat", TYPE_FLOAT, 0, 0 },
257
{ "Taldouble", TYPE_FLOAT, 0, 0 },
258
{ "Talldouble", TYPE_FLOAT, 0, 0 },
259
#ifndef SKIP_DECIMAL_FLOAT
260
{ "TalDecimal32", TYPE_DEC_FLOAT, 0, 0 },
261
{ "TalDecimal64", TYPE_DEC_FLOAT, 0, 0 },
262
{ "TalDecimal128", TYPE_DEC_FLOAT, 0, 0 },
263
#endif
264
{ "TalE0", TYPE_UENUM, 0, ' ' },
265
{ "TalE1", TYPE_UENUM, 1, ' ' },
266
{ "TalE2", TYPE_SENUM, 3, ' ' },
267
{ "TalE3", TYPE_SENUM, 127, ' ' },
268
{ "TalE4", TYPE_UENUM, 255, ' ' },
269
{ "TalE5", TYPE_SENUM, 32767, ' ' },
270
{ "TalE6", TYPE_UENUM, 65535, ' ' },
271
{ "TalE7", TYPE_SENUM, 2147483647, ' ' },
272
{ "TalE8", TYPE_UENUM, 4294967295U, ' ' },
273
{ "TalE9", TYPE_SENUM, 1099511627775LL, ' ' },
274
{ "Tal1char", TYPE_UINT, 127, 'C' },
275
{ "Tal1schar", TYPE_INT, 127, 'C' },
276
{ "Tal1uchar", TYPE_UINT, 255, 'C' },
277
{ "Tal1short", TYPE_INT, 32767, 'S' },
278
{ "Tal1ushort", TYPE_UINT, 65535, 'S' },
279
{ "Tal1int", TYPE_INT, 2147483647, 'I' },
280
{ "Tal1uint", TYPE_UINT, 4294967295U, 'I' },
281
{ "Tal1long", TYPE_INT, 9223372036854775807LL, 'L' },
282
{ "Tal1ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
283
{ "Tal1llong", TYPE_INT, 9223372036854775807LL, 'Q' },
284
{ "Tal1ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
285
{ "Tal1bool", TYPE_UINT, 1, 'B' },
286
{ "Tal1ptr", TYPE_PTR, 0, 0 },
287
{ "Tal1cptr", TYPE_PTR, 0, 0 },
288
{ "Tal1iptr", TYPE_PTR, 0, 0 },
289
{ "Tal1float", TYPE_FLOAT, 0, 0 },
290
{ "Tal1double", TYPE_FLOAT, 0, 0 },
291
{ "Tal1ldouble", TYPE_FLOAT, 0, 0 },
292
#ifndef SKIP_DECIMAL_FLOAT
293
{ "Tal1Decimal32", TYPE_DEC_FLOAT, 0, 0},
294
{ "Tal1Decimal64", TYPE_DEC_FLOAT, 0, 0},
295
{ "Tal1Decimal128", TYPE_DEC_FLOAT, 0, 0},
296
#endif
297
{ "Tal1E0", TYPE_UENUM, 0, ' ' },
298
{ "Tal1E1", TYPE_UENUM, 1, ' ' },
299
{ "Tal1E2", TYPE_SENUM, 3, ' ' },
300
{ "Tal1E3", TYPE_SENUM, 127, ' ' },
301
{ "Tal1E4", TYPE_UENUM, 255, ' ' },
302
{ "Tal1E5", TYPE_SENUM, 32767, ' ' },
303
{ "Tal1E6", TYPE_UENUM, 65535, ' ' },
304
{ "Tal1E7", TYPE_SENUM, 2147483647, ' ' },
305
{ "Tal1E8", TYPE_UENUM, 4294967295U, ' ' },
306
{ "Tal1E9", TYPE_SENUM, 1099511627775LL, ' ' },
307
{ "Tal2char", TYPE_UINT, 127, 'C' },
308
{ "Tal2schar", TYPE_INT, 127, 'C' },
309
{ "Tal2uchar", TYPE_UINT, 255, 'C' },
310
{ "Tal2short", TYPE_INT, 32767, 'S' },
311
{ "Tal2ushort", TYPE_UINT, 65535, 'S' },
312
{ "Tal2int", TYPE_INT, 2147483647, 'I' },
313
{ "Tal2uint", TYPE_UINT, 4294967295U, 'I' },
314
{ "Tal2long", TYPE_INT, 9223372036854775807LL, 'L' },
315
{ "Tal2ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
316
{ "Tal2llong", TYPE_INT, 9223372036854775807LL, 'Q' },
317
{ "Tal2ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
318
{ "Tal2bool", TYPE_UINT, 1, 'B' },
319
{ "Tal2ptr", TYPE_PTR, 0, 0 },
320
{ "Tal2cptr", TYPE_PTR, 0, 0 },
321
{ "Tal2iptr", TYPE_PTR, 0, 0 },
322
{ "Tal2float", TYPE_FLOAT, 0, 0 },
323
{ "Tal2double", TYPE_FLOAT, 0, 0 },
324
{ "Tal2ldouble", TYPE_FLOAT, 0, 0 },
325
#ifndef SKIP_DECIMAL_FLOAT
326
{ "Tal2Decimal32", TYPE_DEC_FLOAT, 0, 0 },
327
{ "Tal2Decimal64", TYPE_DEC_FLOAT, 0, 0 },
328
{ "Tal2Decimal128", TYPE_DEC_FLOAT, 0, 0 },
329
#endif
330
{ "Tal2E0", TYPE_UENUM, 0, ' ' },
331
{ "Tal2E1", TYPE_UENUM, 1, ' ' },
332
{ "Tal2E2", TYPE_SENUM, 3, ' ' },
333
{ "Tal2E3", TYPE_SENUM, 127, ' ' },
334
{ "Tal2E4", TYPE_UENUM, 255, ' ' },
335
{ "Tal2E5", TYPE_SENUM, 32767, ' ' },
336
{ "Tal2E6", TYPE_UENUM, 65535, ' ' },
337
{ "Tal2E7", TYPE_SENUM, 2147483647, ' ' },
338
{ "Tal2E8", TYPE_UENUM, 4294967295U, ' ' },
339
{ "Tal2E9", TYPE_SENUM, 1099511627775LL, ' ' },
340
{ "Tal4char", TYPE_UINT, 127, 'C' },
341
{ "Tal4schar", TYPE_INT, 127, 'C' },
342
{ "Tal4uchar", TYPE_UINT, 255, 'C' },
343
{ "Tal4short", TYPE_INT, 32767, 'S' },
344
{ "Tal4ushort", TYPE_UINT, 65535, 'S' },
345
{ "Tal4int", TYPE_INT, 2147483647, 'I' },
346
{ "Tal4uint", TYPE_UINT, 4294967295U, 'I' },
347
{ "Tal4long", TYPE_INT, 9223372036854775807LL, 'L' },
348
{ "Tal4ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
349
{ "Tal4llong", TYPE_INT, 9223372036854775807LL, 'Q' },
350
{ "Tal4ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
351
{ "Tal4bool", TYPE_UINT, 1, 'B' },
352
{ "Tal4ptr", TYPE_PTR, 0, 0 },
353
{ "Tal4cptr", TYPE_PTR, 0, 0 },
354
{ "Tal4iptr", TYPE_PTR, 0, 0 },
355
{ "Tal4float", TYPE_FLOAT, 0, 0 },
356
{ "Tal4double", TYPE_FLOAT, 0, 0 },
357
{ "Tal4ldouble", TYPE_FLOAT, 0, 0 },
358
#ifndef SKIP_DECIMAL_FLOAT
359
{ "Tal4Decimal32", TYPE_DEC_FLOAT, 0, 0 },
360
{ "Tal4Decimal64", TYPE_DEC_FLOAT, 0, 0 },
361
{ "Tal4Decimal128", TYPE_DEC_FLOAT, 0, 0 },
362
#endif
363
{ "Tal4E0", TYPE_UENUM, 0, ' ' },
364
{ "Tal4E1", TYPE_UENUM, 1, ' ' },
365
{ "Tal4E2", TYPE_SENUM, 3, ' ' },
366
{ "Tal4E3", TYPE_SENUM, 127, ' ' },
367
{ "Tal4E4", TYPE_UENUM, 255, ' ' },
368
{ "Tal4E5", TYPE_SENUM, 32767, ' ' },
369
{ "Tal4E6", TYPE_UENUM, 65535, ' ' },
370
{ "Tal4E7", TYPE_SENUM, 2147483647, ' ' },
371
{ "Tal4E8", TYPE_UENUM, 4294967295U, ' ' },
372
{ "Tal4E9", TYPE_SENUM, 1099511627775LL, ' ' },
373
{ "Tal8char", TYPE_UINT, 127, 'C' },
374
{ "Tal8schar", TYPE_INT, 127, 'C' },
375
{ "Tal8uchar", TYPE_UINT, 255, 'C' },
376
{ "Tal8short", TYPE_INT, 32767, 'S' },
377
{ "Tal8ushort", TYPE_UINT, 65535, 'S' },
378
{ "Tal8int", TYPE_INT, 2147483647, 'I' },
379
{ "Tal8uint", TYPE_UINT, 4294967295U, 'I' },
380
{ "Tal8long", TYPE_INT, 9223372036854775807LL, 'L' },
381
{ "Tal8ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
382
{ "Tal8llong", TYPE_INT, 9223372036854775807LL, 'Q' },
383
{ "Tal8ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
384
{ "Tal8bool", TYPE_UINT, 1, 'B' },
385
{ "Tal8ptr", TYPE_PTR, 0, 0 },
386
{ "Tal8cptr", TYPE_PTR, 0, 0 },
387
{ "Tal8iptr", TYPE_PTR, 0, 0 },
388
{ "Tal8float", TYPE_FLOAT, 0, 0 },
389
{ "Tal8double", TYPE_FLOAT, 0, 0 },
390
{ "Tal8ldouble", TYPE_FLOAT, 0, 0 },
391
#ifndef SKIP_DECIMAL_FLOAT
392
{ "Tal8Decimal32", TYPE_DEC_FLOAT, 0, 0 },
393
{ "Tal8Decimal64", TYPE_DEC_FLOAT, 0, 0 },
394
{ "Tal8Decimal128", TYPE_DEC_FLOAT, 0, 0 },
395
#endif
396
{ "Tal8E0", TYPE_UENUM, 0, ' ' },
397
{ "Tal8E1", TYPE_UENUM, 1, ' ' },
398
{ "Tal8E2", TYPE_SENUM, 3, ' ' },
399
{ "Tal8E3", TYPE_SENUM, 127, ' ' },
400
{ "Tal8E4", TYPE_UENUM, 255, ' ' },
401
{ "Tal8E5", TYPE_SENUM, 32767, ' ' },
402
{ "Tal8E6", TYPE_UENUM, 65535, ' ' },
403
{ "Tal8E7", TYPE_SENUM, 2147483647, ' ' },
404
{ "Tal8E8", TYPE_UENUM, 4294967295U, ' ' },
405
{ "Tal8E9", TYPE_SENUM, 1099511627775LL, ' ' },
406
{ "Tal16char", TYPE_UINT, 127, 'C' },
407
{ "Tal16schar", TYPE_INT, 127, 'C' },
408
{ "Tal16uchar", TYPE_UINT, 255, 'C' },
409
{ "Tal16short", TYPE_INT, 32767, 'S' },
410
{ "Tal16ushort", TYPE_UINT, 65535, 'S' },
411
{ "Tal16int", TYPE_INT, 2147483647, 'I' },
412
{ "Tal16uint", TYPE_UINT, 4294967295U, 'I' },
413
{ "Tal16long", TYPE_INT, 9223372036854775807LL, 'L' },
414
{ "Tal16ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
415
{ "Tal16llong", TYPE_INT, 9223372036854775807LL, 'Q' },
416
{ "Tal16ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
417
{ "Tal16bool", TYPE_UINT, 1, 'B' },
418
{ "Tal16ptr", TYPE_PTR, 0, 0 },
419
{ "Tal16cptr", TYPE_PTR, 0, 0 },
420
{ "Tal16iptr", TYPE_PTR, 0, 0 },
421
{ "Tal16float", TYPE_FLOAT, 0, 0 },
422
{ "Tal16double", TYPE_FLOAT, 0, 0 },
423
{ "Tal16ldouble", TYPE_FLOAT, 0, 0 },
424
#ifndef SKIP_DECIMAL_FLOAT
425
{ "Tal16Decimal32", TYPE_DEC_FLOAT, 0, 0 },
426
{ "Tal16Decimal64", TYPE_DEC_FLOAT, 0, 0 },
427
{ "Tal16Decimal128", TYPE_DEC_FLOAT, 0, 0 },
428
#endif
429
{ "Tal16E0", TYPE_UENUM, 0, ' ' },
430
{ "Tal16E1", TYPE_UENUM, 1, ' ' },
431
{ "Tal16E2", TYPE_SENUM, 3, ' ' },
432
{ "Tal16E3", TYPE_SENUM, 127, ' ' },
433
{ "Tal16E4", TYPE_UENUM, 255, ' ' },
434
{ "Tal16E5", TYPE_SENUM, 32767, ' ' },
435
{ "Tal16E6", TYPE_UENUM, 65535, ' ' },
436
{ "Tal16E7", TYPE_SENUM, 2147483647, ' ' },
437
{ "Tal16E8", TYPE_UENUM, 4294967295U, ' ' },
438
{ "Tal16E9", TYPE_SENUM, 1099511627775LL, ' ' }
439
#define NATYPES2 (sizeof (attrib_types) / sizeof (attrib_types[0]))
440
};
441
struct types complex_attrib_types[] = {
442
{ "Talcchar", TYPE_CUINT, 127, 0 },
443
{ "Talcschar", TYPE_CINT, 127, 0 },
444
{ "Talcuchar", TYPE_CUINT, 255, 0 },
445
{ "Talcshort", TYPE_CINT, 32767, 0 },
446
{ "Talcushort", TYPE_CUINT, 65535, 0 },
447
{ "Talcint", TYPE_CINT, 2147483647, 0 },
448
{ "Talcuint", TYPE_CUINT, 4294967295U, 0 },
449
{ "Talclong", TYPE_CINT, 9223372036854775807LL, 0 },
450
{ "Talculong", TYPE_CUINT, 18446744073709551615ULL, 0 },
451
{ "Talcllong", TYPE_CINT, 9223372036854775807LL, 0 },
452
{ "Talcullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
453
{ "Talcfloat", TYPE_CFLOAT, 0, 0 },
454
{ "Talcdouble", TYPE_CFLOAT, 0, 0 },
455
{ "Talcldouble", TYPE_CFLOAT, 0, 0 },
456
{ "Tal1cchar", TYPE_CUINT, 127, 0 },
457
{ "Tal1cschar", TYPE_CINT, 127, 0 },
458
{ "Tal1cuchar", TYPE_CUINT, 255, 0 },
459
{ "Tal1cshort", TYPE_CINT, 32767, 0 },
460
{ "Tal1cushort", TYPE_CUINT, 65535, 0 },
461
{ "Tal1cint", TYPE_CINT, 2147483647, 0 },
462
{ "Tal1cuint", TYPE_CUINT, 4294967295U, 0 },
463
{ "Tal1clong", TYPE_CINT, 9223372036854775807LL, 0 },
464
{ "Tal1culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
465
{ "Tal1cllong", TYPE_CINT, 9223372036854775807LL, 0 },
466
{ "Tal1cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
467
{ "Tal1cfloat", TYPE_CFLOAT, 0, 0 },
468
{ "Tal1cdouble", TYPE_CFLOAT, 0, 0 },
469
{ "Tal1cldouble", TYPE_CFLOAT, 0, 0 },
470
{ "Tal2cchar", TYPE_CUINT, 127, 0 },
471
{ "Tal2cschar", TYPE_CINT, 127, 0 },
472
{ "Tal2cuchar", TYPE_CUINT, 255, 0 },
473
{ "Tal2cshort", TYPE_CINT, 32767, 0 },
474
{ "Tal2cushort", TYPE_CUINT, 65535, 0 },
475
{ "Tal2cint", TYPE_CINT, 2147483647, 0 },
476
{ "Tal2cuint", TYPE_CUINT, 4294967295U, 0 },
477
{ "Tal2clong", TYPE_CINT, 9223372036854775807LL, 0 },
478
{ "Tal2culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
479
{ "Tal2cllong", TYPE_CINT, 9223372036854775807LL, 0 },
480
{ "Tal2cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
481
{ "Tal2cfloat", TYPE_CFLOAT, 0, 0 },
482
{ "Tal2cdouble", TYPE_CFLOAT, 0, 0 },
483
{ "Tal2cldouble", TYPE_CFLOAT, 0, 0 },
484
{ "Tal4cchar", TYPE_CUINT, 127, 0 },
485
{ "Tal4cschar", TYPE_CINT, 127, 0 },
486
{ "Tal4cuchar", TYPE_CUINT, 255, 0 },
487
{ "Tal4cshort", TYPE_CINT, 32767, 0 },
488
{ "Tal4cushort", TYPE_CUINT, 65535, 0 },
489
{ "Tal4cint", TYPE_CINT, 2147483647, 0 },
490
{ "Tal4cuint", TYPE_CUINT, 4294967295U, 0 },
491
{ "Tal4clong", TYPE_CINT, 9223372036854775807LL, 0 },
492
{ "Tal4culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
493
{ "Tal4cllong", TYPE_CINT, 9223372036854775807LL, 0 },
494
{ "Tal4cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
495
{ "Tal4cfloat", TYPE_CFLOAT, 0, 0 },
496
{ "Tal4cdouble", TYPE_CFLOAT, 0, 0 },
497
{ "Tal4cldouble", TYPE_CFLOAT, 0, 0 },
498
{ "Tal8cchar", TYPE_CUINT, 127, 0 },
499
{ "Tal8cschar", TYPE_CINT, 127, 0 },
500
{ "Tal8cuchar", TYPE_CUINT, 255, 0 },
501
{ "Tal8cshort", TYPE_CINT, 32767, 0 },
502
{ "Tal8cushort", TYPE_CUINT, 65535, 0 },
503
{ "Tal8cint", TYPE_CINT, 2147483647, 0 },
504
{ "Tal8cuint", TYPE_CUINT, 4294967295U, 0 },
505
{ "Tal8clong", TYPE_CINT, 9223372036854775807LL, 0 },
506
{ "Tal8culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
507
{ "Tal8cllong", TYPE_CINT, 9223372036854775807LL, 0 },
508
{ "Tal8cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
509
{ "Tal8cfloat", TYPE_CFLOAT, 0, 0 },
510
{ "Tal8cdouble", TYPE_CFLOAT, 0, 0 },
511
{ "Tal8cldouble", TYPE_CFLOAT, 0, 0 },
512
{ "Tal16cchar", TYPE_CUINT, 127, 0 },
513
{ "Tal16cschar", TYPE_CINT, 127, 0 },
514
{ "Tal16cuchar", TYPE_CUINT, 255, 0 },
515
{ "Tal16cshort", TYPE_CINT, 32767, 0 },
516
{ "Tal16cushort", TYPE_CUINT, 65535, 0 },
517
{ "Tal16cint", TYPE_CINT, 2147483647, 0 },
518
{ "Tal16cuint", TYPE_CUINT, 4294967295U, 0 },
519
{ "Tal16clong", TYPE_CINT, 9223372036854775807LL, 0 },
520
{ "Tal16culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
521
{ "Tal16cllong", TYPE_CINT, 9223372036854775807LL, 0 },
522
{ "Tal16cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
523
{ "Tal16cfloat", TYPE_CFLOAT, 0, 0 },
524
{ "Tal16cdouble", TYPE_CFLOAT, 0, 0 },
525
{ "Tal16cldouble", TYPE_CFLOAT, 0, 0 }
526
#define NCATYPES2 (sizeof (complex_attrib_types) / sizeof (complex_attrib_types[0]))
527
};
528
struct types attrib_array_types[] = {
529
{ "Talx1char", TYPE_UINT, 127, 'C' },
530
{ "Talx1schar", TYPE_INT, 127, 'C' },
531
{ "Talx1uchar", TYPE_UINT, 255, 'C' },
532
{ "Talx1short", TYPE_INT, 32767, 'S' },
533
{ "Talx1ushort", TYPE_UINT, 65535, 'S' },
534
{ "Talx1int", TYPE_INT, 2147483647, 'I' },
535
{ "Talx1uint", TYPE_UINT, 4294967295U, 'I' },
536
{ "Talx1long", TYPE_INT, 9223372036854775807LL, 'L' },
537
{ "Talx1ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
538
{ "Talx1llong", TYPE_INT, 9223372036854775807LL, 'Q' },
539
{ "Talx1ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
540
{ "Talx1bool", TYPE_UINT, 1, 'B' },
541
{ "Talx1ptr", TYPE_PTR, 0, 0 },
542
{ "Talx1cptr", TYPE_PTR, 0, 0 },
543
{ "Talx1iptr", TYPE_PTR, 0, 0 },
544
{ "Talx1float", TYPE_FLOAT, 0, 0 },
545
{ "Talx1double", TYPE_FLOAT, 0, 0 },
546
{ "Talx1ldouble", TYPE_FLOAT, 0, 0 },
547
#ifndef SKIP_DECIMAL_FLOAT
548
{ "Talx1Decimal32", TYPE_DEC_FLOAT, 0 ,0 },
549
{ "Talx1Decimal64", TYPE_DEC_FLOAT, 0 ,0 },
550
{ "Talx1Decimal128", TYPE_DEC_FLOAT, 0 ,0 },
551
#endif
552
{ "Talx1E0", TYPE_UENUM, 0, ' ' },
553
{ "Talx1E1", TYPE_UENUM, 1, ' ' },
554
{ "Talx1E2", TYPE_SENUM, 3, ' ' },
555
{ "Talx1E3", TYPE_SENUM, 127, ' ' },
556
{ "Talx1E4", TYPE_UENUM, 255, ' ' },
557
{ "Talx1E5", TYPE_SENUM, 32767, ' ' },
558
{ "Talx1E6", TYPE_UENUM, 65535, ' ' },
559
{ "Talx1E7", TYPE_SENUM, 2147483647, ' ' },
560
{ "Talx1E8", TYPE_UENUM, 4294967295U, ' ' },
561
{ "Talx1E9", TYPE_SENUM, 1099511627775LL, ' ' },
562
{ "Talx2short", TYPE_INT, 32767, 'S' },
563
{ "Talx2ushort", TYPE_UINT, 65535, 'S' },
564
{ "Talx2int", TYPE_INT, 2147483647, 'I' },
565
{ "Talx2uint", TYPE_UINT, 4294967295U, 'I' },
566
{ "Talx2long", TYPE_INT, 9223372036854775807LL, 'L' },
567
{ "Talx2ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
568
{ "Talx2llong", TYPE_INT, 9223372036854775807LL, 'Q' },
569
{ "Talx2ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
570
{ "Talx2ptr", TYPE_PTR, 0, 0 },
571
{ "Talx2cptr", TYPE_PTR, 0, 0 },
572
{ "Talx2iptr", TYPE_PTR, 0, 0 },
573
{ "Talx2float", TYPE_FLOAT, 0, 0 },
574
{ "Talx2double", TYPE_FLOAT, 0, 0 },
575
{ "Talx2ldouble", TYPE_FLOAT, 0, 0 },
576
#ifndef SKIP_DECIMAL_FLOAT
577
{ "Talx2Decimal32", TYPE_DEC_FLOAT, 0 , 0 },
578
{ "Talx2Decimal64", TYPE_DEC_FLOAT, 0 , 0 },
579
{ "Talx2Decimal128", TYPE_DEC_FLOAT, 0 , 0 },
580
#endif
581
{ "Talx2E0", TYPE_UENUM, 0, ' ' },
582
{ "Talx2E1", TYPE_UENUM, 1, ' ' },
583
{ "Talx2E2", TYPE_SENUM, 3, ' ' },
584
{ "Talx2E3", TYPE_SENUM, 127, ' ' },
585
{ "Talx2E4", TYPE_UENUM, 255, ' ' },
586
{ "Talx2E5", TYPE_SENUM, 32767, ' ' },
587
{ "Talx2E6", TYPE_UENUM, 65535, ' ' },
588
{ "Talx2E7", TYPE_SENUM, 2147483647, ' ' },
589
{ "Talx2E8", TYPE_UENUM, 4294967295U, ' ' },
590
{ "Talx2E9", TYPE_SENUM, 1099511627775LL, ' ' },
591
{ "Talx4int", TYPE_INT, 2147483647, 'I' },
592
{ "Talx4uint", TYPE_UINT, 4294967295U, 'I' },
593
{ "Talx4long", TYPE_INT, 9223372036854775807LL, 'L' },
594
{ "Talx4ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
595
{ "Talx4llong", TYPE_INT, 9223372036854775807LL, 'Q' },
596
{ "Talx4ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
597
{ "Talx4ptr", TYPE_PTR, 0, 0 },
598
{ "Talx4cptr", TYPE_PTR, 0, 0 },
599
{ "Talx4iptr", TYPE_PTR, 0, 0 },
600
{ "Talx4float", TYPE_FLOAT, 0, 0 },
601
{ "Talx4double", TYPE_FLOAT, 0, 0 },
602
{ "Talx4ldouble", TYPE_FLOAT, 0, 0 },
603
#ifndef SKIP_DECIMAL_FLOAT
604
{ "Talx4Decimal32", TYPE_DEC_FLOAT, 0 , 0 },
605
{ "Talx4Decimal64", TYPE_DEC_FLOAT, 0 , 0 },
606
{ "Talx4Decimal128", TYPE_DEC_FLOAT, 0 , 0 },
607
#endif
608
{ "Talx4E0", TYPE_UENUM, 0, ' ' },
609
{ "Talx4E1", TYPE_UENUM, 1, ' ' },
610
{ "Talx4E2", TYPE_SENUM, 3, ' ' },
611
{ "Talx4E3", TYPE_SENUM, 127, ' ' },
612
{ "Talx4E4", TYPE_UENUM, 255, ' ' },
613
{ "Talx4E5", TYPE_SENUM, 32767, ' ' },
614
{ "Talx4E6", TYPE_UENUM, 65535, ' ' },
615
{ "Talx4E7", TYPE_SENUM, 2147483647, ' ' },
616
{ "Talx4E8", TYPE_UENUM, 4294967295U, ' ' },
617
{ "Talx4E9", TYPE_SENUM, 1099511627775LL, ' ' },
618
{ "Taly8long", TYPE_INT, 9223372036854775807LL, 'L' },
619
{ "Taly8ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
620
{ "Talx8llong", TYPE_INT, 9223372036854775807LL, 'Q' },
621
{ "Talx8ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
622
{ "Taly8ptr", TYPE_PTR, 0, 0 },
623
{ "Taly8cptr", TYPE_PTR, 0, 0 },
624
{ "Taly8iptr", TYPE_PTR, 0, 0 },
625
{ "Talx8double", TYPE_FLOAT, 0, 0 },
626
{ "Talx8ldouble", TYPE_FLOAT, 0, 0 },
627
#ifndef SKIP_DECIMAL_FLOAT
628
{ "Talx8Decimal64", TYPE_DEC_FLOAT, 0, 0 },
629
{ "Talx8Decimal128", TYPE_DEC_FLOAT, 0, 0 }
630
#endif
631
#define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0]))
632
};
633
struct types complex_attrib_array_types[] = {
634
{ "Talx1cchar", TYPE_CUINT, 127, 0 },
635
{ "Talx1cschar", TYPE_CINT, 127, 0 },
636
{ "Talx1cuchar", TYPE_CUINT, 255, 0 },
637
{ "Talx1cshort", TYPE_CINT, 32767, 0 },
638
{ "Talx1cushort", TYPE_CUINT, 65535, 0 },
639
{ "Talx1cint", TYPE_CINT, 2147483647, 0 },
640
{ "Talx1cuint", TYPE_CUINT, 4294967295U, 0 },
641
{ "Talx1clong", TYPE_CINT, 9223372036854775807LL, 0 },
642
{ "Talx1culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
643
{ "Talx1cllong", TYPE_CINT, 9223372036854775807LL, 0 },
644
{ "Talx1cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
645
{ "Talx1cfloat", TYPE_CFLOAT, 0, 0 },
646
{ "Talx1cdouble", TYPE_CFLOAT, 0, 0 },
647
{ "Talx1cldouble", TYPE_CFLOAT, 0, 0 },
648
{ "Talx2cchar", TYPE_CUINT, 127, 0 },
649
{ "Talx2cschar", TYPE_CINT, 127, 0 },
650
{ "Talx2cuchar", TYPE_CUINT, 255, 0 },
651
{ "Talx2cshort", TYPE_CINT, 32767, 0 },
652
{ "Talx2cushort", TYPE_CUINT, 65535, 0 },
653
{ "Talx2cint", TYPE_CINT, 2147483647, 0 },
654
{ "Talx2cuint", TYPE_CUINT, 4294967295U, 0 },
655
{ "Talx2clong", TYPE_CINT, 9223372036854775807LL, 0 },
656
{ "Talx2culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
657
{ "Talx2cllong", TYPE_CINT, 9223372036854775807LL, 0 },
658
{ "Talx2cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
659
{ "Talx2cfloat", TYPE_CFLOAT, 0, 0 },
660
{ "Talx2cdouble", TYPE_CFLOAT, 0, 0 },
661
{ "Talx2cldouble", TYPE_CFLOAT, 0, 0 },
662
{ "Talx4cshort", TYPE_CINT, 32767, 0 },
663
{ "Talx4cushort", TYPE_CUINT, 65535, 0 },
664
{ "Talx4cint", TYPE_CINT, 2147483647, 0 },
665
{ "Talx4cuint", TYPE_CUINT, 4294967295U, 0 },
666
{ "Talx4clong", TYPE_CINT, 9223372036854775807LL, 0 },
667
{ "Talx4culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
668
{ "Talx4cllong", TYPE_CINT, 9223372036854775807LL, 0 },
669
{ "Talx4cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
670
{ "Talx4cfloat", TYPE_CFLOAT, 0, 0 },
671
{ "Talx4cdouble", TYPE_CFLOAT, 0, 0 },
672
{ "Talx4cldouble", TYPE_CFLOAT, 0, 0 },
673
{ "Talx8cint", TYPE_CINT, 2147483647, 0 },
674
{ "Talx8cuint", TYPE_CUINT, 4294967295U, 0 },
675
{ "Talx8clong", TYPE_CINT, 9223372036854775807LL, 0 },
676
{ "Talx8culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
677
{ "Talx8cllong", TYPE_CINT, 9223372036854775807LL, 0 },
678
{ "Talx8cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
679
{ "Talx8cfloat", TYPE_CFLOAT, 0, 0 },
680
{ "Talx8cdouble", TYPE_CFLOAT, 0, 0 },
681
{ "Talx8cldouble", TYPE_CFLOAT, 0, 0 },
682
{ "Taly16clong", TYPE_CINT, 9223372036854775807LL, 0 },
683
{ "Taly16culong", TYPE_CUINT, 18446744073709551615ULL, 0 },
684
{ "Talx16cllong", TYPE_CINT, 9223372036854775807LL, 0 },
685
{ "Talx16cullong", TYPE_CUINT, 18446744073709551615ULL, 0 },
686
{ "Talx16cdouble", TYPE_CFLOAT, 0, 0 },
687
{ "Talx16cldouble", TYPE_CFLOAT, 0, 0 }
688
#define NCAATYPES2 (sizeof (complex_attrib_array_types) / sizeof (complex_attrib_array_types[0]))
689
};
690
 
691
struct types bitfld_types[NTYPES2];
692
int n_bitfld_types;
693
struct types aligned_bitfld_types[NATYPES2];
694
int n_aligned_bitfld_types;
695
 
696
const char *attributes[] = {
697
"atal",
698
"atpa",
699
"atal1",
700
"atal2",
701
"atal4",
702
"atal8",
703
"atal16",
704
#define NATTRIBS1 7
705
"atalpa",
706
"atpaal",
707
"atal1pa",
708
"atal2pa",
709
"atal4pa",
710
"atal8pa",
711
"atal16pa",
712
"atpaal1",
713
"atpaal2",
714
"atpaal4",
715
"atpaal8",
716
"atpaal16"
717
#define NATTRIBS2 (sizeof (attributes) / sizeof (attributes[0]))
718
};
719
 
720
enum ETYPE
721
{
722
  ETYPE_TYPE,
723
  ETYPE_ARRAY,
724
  ETYPE_BITFLD,
725
  ETYPE_STRUCT,
726
  ETYPE_UNION,
727
  ETYPE_STRUCT_ARRAY,
728
  ETYPE_UNION_ARRAY
729
};
730
 
731
struct entry
732
{
733
#ifdef __GNUC__
734
  enum ETYPE etype : 8;
735
#else
736
  unsigned char etype;
737
#endif
738
  unsigned short len;
739
  unsigned char arr_len;
740
  struct types *type;
741
  const char *attrib;
742
  /* Used to chain together entries in the hash table.  */
743
  struct entry *next;
744
};
745
 
746
/* A prime number giving the number of slots in the hash table.  */
747
#define HASH_SIZE 32749 
748
static struct entry *hash_table[HASH_SIZE];
749
 
750
static int idx, limidx, output_one, short_enums;
751
static const char *destdir;
752
static const char *srcdir;
753
static const char *srcdir_safe;
754
FILE *outfile;
755
 
756
void
757
switchfiles (int fields)
758
{
759
  static int filecnt;
760
  static char *destbuf, *destptr;
761
  int i;
762
 
763
  ++filecnt;
764
  if (outfile)
765
    fclose (outfile);
766
  if (output_one)
767
    {
768
      outfile = stdout;
769
      return;
770
    }
771
  if (destbuf == NULL)
772
    {
773
      size_t len = strlen (destdir);
774
      destbuf = malloc (len + 20);
775
      if (!destbuf)
776
        abort ();
777
      memcpy (destbuf, destdir, len);
778
      if (!len || destbuf[len - 1] != '/')
779
        destbuf[len++] = '/';
780
      destptr = destbuf + len;
781
    }
782
  sprintf (destptr, "t%03d_main.c", filecnt);
783
  outfile = fopen (destbuf, "w");
784
  if (outfile == NULL)
785
    {
786
    fail:
787
      fputs ("failed to create test files\n", stderr);
788
      exit (1);
789
    }
790
  fprintf (outfile, "/* { dg-require-effective-target int32plus } */\n");
791
  for (i = 0; i < NDG_OPTIONS; i++)
792
    fprintf (outfile, dg_options[i], "", srcdir_safe);
793
  fprintf (outfile, "/* { dg-prune-output \".*-Wno-abi.*\" } */\n");
794
  fprintf (outfile, "/* { dg-prune-output \".*Offset of packed bit-field.*\" } */\n");
795
  fprintf (outfile, "\
796
#include \"struct-layout-1.h\"\n\
797
\n\
798
#define TX(n, type, attrs, fields, ops) extern void test##n (void);\n\
799
#include \"t%03d_test.h\"\n\
800
#undef TX\n\
801
\n\
802
int main (void)\n\
803
{\n\
804
#define TX(n, type, attrs, fields, ops)   test##n ();\n\
805
#include \"t%03d_test.h\"\n\
806
#undef TX\n\
807
  if (fails)\n\
808
    {\n\
809
      fflush (stdout);\n\
810
      abort ();\n\
811
    }\n\
812
  exit (0);\n\
813
}\n", filecnt, filecnt);
814
  fclose (outfile);
815
  sprintf (destptr, "t%03d_x.c", filecnt);
816
  outfile = fopen (destbuf, "w");
817
  if (outfile == NULL)
818
    goto fail;
819
  for (i = 0; i < NDG_OPTIONS; i++)
820
    fprintf (outfile, dg_options[i], "-w ", srcdir_safe);
821
  fprintf (outfile, "\
822
#include \"struct-layout-1_x1.h\"\n\
823
#include \"t%03d_test.h\"\n\
824
#include \"struct-layout-1_x2.h\"\n\
825
#include \"t%03d_test.h\"\n", filecnt, filecnt);
826
  fclose (outfile);
827
  sprintf (destptr, "t%03d_y.c", filecnt);
828
  outfile = fopen (destbuf, "w");
829
  if (outfile == NULL)
830
    goto fail;
831
  for (i = 0; i < NDG_OPTIONS; i++)
832
    fprintf (outfile, dg_options[i], "-w ", srcdir_safe);
833
  fprintf (outfile, "\
834
#include \"struct-layout-1_y1.h\"\n\
835
#include \"t%03d_test.h\"\n\
836
#include \"struct-layout-1_y2.h\"\n\
837
#include \"t%03d_test.h\"\n", filecnt, filecnt);
838
  fclose (outfile);
839
  sprintf (destptr, "t%03d_test.h", filecnt);
840
  outfile = fopen (destbuf, "w");
841
  if (outfile == NULL)
842
    goto fail;
843
  if (fields <= 2)
844
    limidx = idx + 300;
845
  else if (fields <= 4)
846
    limidx = idx + 200;
847
  else if (fields <= 6)
848
    limidx = idx + 100;
849
  else
850
    limidx = idx + 50;
851
}
852
 
853
unsigned long long int
854
getrandll (void)
855
{
856
  unsigned long long int ret;
857
  ret = generate_random () & 0xffffff;
858
  ret |= (generate_random () & 0xffffffLL) << 24;
859
  ret |= ((unsigned long long int) generate_random ()) << 48;
860
  return ret;
861
}
862
 
863
int
864
subfield (struct entry *e, char *letter)
865
{
866
  int i, type;
867
  char buf[20];
868
  const char *p;
869
  switch (e[0].etype)
870
    {
871
    case ETYPE_STRUCT:
872
    case ETYPE_UNION:
873
    case ETYPE_STRUCT_ARRAY:
874
    case ETYPE_UNION_ARRAY:
875
      type = e[0].attrib ? 1 + (generate_random () & 3) : 0;
876
      if (e[0].etype == ETYPE_STRUCT || e[0].etype == ETYPE_STRUCT_ARRAY)
877
        p = "struct";
878
      else
879
        p = "union";
880
      if (e[0].etype == ETYPE_STRUCT_ARRAY || e[0].etype == ETYPE_UNION_ARRAY)
881
        {
882
          if (e[0].arr_len == 255)
883
            snprintf (buf, 20, "%c[]", *letter);
884
          else
885
            snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len);
886
          /* If this is an array type, do not put aligned attributes on
887
             elements.  Aligning elements to a value greater than their
888
             size will result in a compiler error.  */
889
          if (type == 1
890
              && ((strncmp (e[0].attrib, "atal", 4) == 0)
891
                   || strncmp (e[0].attrib, "atpaal", 6) == 0))
892
            type = 2;
893
        }
894
      else
895
        {
896
          buf[0] = *letter;
897
          buf[1] = '\0';
898
        }
899
      ++*letter;
900
      switch (type)
901
        {
902
        case 0:
903
        case 3:
904
        case 4:
905
          fprintf (outfile, "%s{", p);
906
          break;
907
        case 1:
908
          fprintf (outfile, "%s %s{", e[0].attrib, p);
909
          break;
910
        case 2:
911
          fprintf (outfile, "%s %s{", p, e[0].attrib);
912
          break;
913
        }
914
 
915
      for (i = 1; i <= e[0].len; )
916
        i += subfield (e + i, letter);
917
 
918
      switch (type)
919
        {
920
        case 0:
921
        case 1:
922
        case 2:
923
          fprintf (outfile, "}%s;", buf);
924
          break;
925
        case 3:
926
          fprintf (outfile, "}%s %s;", e[0].attrib, buf);
927
          break;
928
        case 4:
929
          fprintf (outfile, "}%s %s;", buf, e[0].attrib);
930
          break;
931
        }
932
      return 1 + e[0].len;
933
    case ETYPE_TYPE:
934
    case ETYPE_ARRAY:
935
      if (e[0].etype == ETYPE_ARRAY)
936
        {
937
          if (e[0].arr_len == 255)
938
            snprintf (buf, 20, "%c[]", *letter);
939
          else
940
            snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len);
941
        }
942
      else
943
        {
944
          buf[0] = *letter;
945
          buf[1] = '\0';
946
        }
947
      ++*letter;
948
      if (e[0].attrib)
949
        {
950
          /* If this is an array type, do not put aligned attributes on
951
             elements.  Aligning elements to a value greater than their
952
             size will result in a compiler error.  */
953
          if (e[0].etype == ETYPE_ARRAY
954
              && ((strncmp (e[0].attrib, "atal", 4) == 0)
955
                   || strncmp (e[0].attrib, "atpaal", 6) == 0))
956
            type = 2;
957
          else
958
            type = generate_random () % 3;
959
          switch (type)
960
            {
961
            case 0:
962
              fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name,
963
                       buf);
964
              break;
965
            case 1:
966
              fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib,
967
                       buf);
968
              break;
969
            case 2:
970
              fprintf (outfile, "%s %s %s;", e[0].type->name, buf,
971
                       e[0].attrib);
972
              break;
973
            }
974
        }
975
      else
976
        fprintf (outfile, "%s %s;", e[0].type->name, buf);
977
      return 1;
978
    case ETYPE_BITFLD:
979
      if (e[0].len == 0)
980
        {
981
          if (e[0].attrib)
982
            switch (generate_random () % 3)
983
              {
984
              case 0:
985
                fprintf (outfile, "%s %s:0;", e[0].attrib, e[0].type->name);
986
                break;
987
              case 1:
988
                fprintf (outfile, "%s %s:0;", e[0].type->name, e[0].attrib);
989
                break;
990
              case 2:
991
                fprintf (outfile, "%s:0 %s;", e[0].type->name, e[0].attrib);
992
                break;
993
              }
994
          else
995
            fprintf (outfile, "%s:0;", e[0].type->name);
996
          ++*letter;
997
          return 1;
998
        }
999
      switch (e[0].type->bitfld)
1000
        {
1001
        case 'C':
1002
        case 'S':
1003
        case 'I':
1004
        case 'L':
1005
        case 'Q':
1006
          snprintf (buf, 20, "B%cN(%d)", e[0].type->bitfld, e[0].len);
1007
          break;
1008
        case 'B':
1009
        case ' ':
1010
          snprintf (buf, 20, "%d", e[0].len);
1011
          break;
1012
        default:
1013
          abort ();
1014
        }
1015
      if (e[0].attrib)
1016
        switch (generate_random () % 3)
1017
          {
1018
          case 0:
1019
            fprintf (outfile, "%s %s %c:%s;", e[0].attrib, e[0].type->name,
1020
                     *letter, buf);
1021
            break;
1022
          case 1:
1023
            fprintf (outfile, "%s %s %c:%s;", e[0].type->name, e[0].attrib,
1024
                     *letter, buf);
1025
            break;
1026
          case 2:
1027
            fprintf (outfile, "%s %c:%s %s;", e[0].type->name, *letter,
1028
                     buf, e[0].attrib);
1029
            break;
1030
          }
1031
      else
1032
        fprintf (outfile, "%s %c:%s;", e[0].type->name, *letter, buf);
1033
      ++*letter;
1034
      return 1;
1035
    default:
1036
      abort ();
1037
  }
1038
}
1039
 
1040
char namebuf[1024];
1041
 
1042
void
1043
output_FNB (char mode, struct entry *e)
1044
{
1045
  unsigned long long int l1, l2, m;
1046
  int signs = 0;
1047
#ifndef SKIP_DECIMAL_FLOAT
1048
  int suffix = 0;
1049
  char DEC_SUFFIX[3][3]={"DF","DD","DL"};
1050
#endif
1051
 
1052
  const char *p, *q;
1053
 
1054
  if (e->type->type == TYPE_OTHER)
1055
    {
1056
      if (mode == 'B')
1057
        abort ();
1058
      fprintf (outfile, "N(%d,%s)", idx, namebuf);
1059
      return;
1060
    }
1061
  fprintf (outfile, "%c(%d,%s,", mode, idx, namebuf);
1062
  l1 = getrandll ();
1063
  l2 = getrandll ();
1064
  switch (e->type->type)
1065
    {
1066
    case TYPE_INT:
1067
      signs = generate_random () & 3;
1068
      m = e->type->maxval;
1069
      if (mode == 'B')
1070
        m &= e->len > 1 ? (1ULL << (e->len - 1)) - 1 : 1;
1071
      l1 &= m;
1072
      l2 &= m;
1073
      fprintf (outfile, "%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s",
1074
               (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
1075
               (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
1076
      break;
1077
    case TYPE_UINT:
1078
      m = e->type->maxval;
1079
      if (mode == 'B')
1080
        m &= (1ULL << e->len) - 1;
1081
      l1 &= m;
1082
      l2 &= m;
1083
      fprintf (outfile, "%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s",
1084
               l1, l1 > 4294967295U ? "LL" : "",
1085
               l2, l2 > 4294967295U ? "LL" : "");
1086
      break;
1087
    case TYPE_FLOAT:
1088
      l1 &= 0xffffff;
1089
      l2 &= 0xffffff;
1090
      signs = generate_random () & 3;
1091
      fprintf (outfile, "%s%f,%s%f", (signs & 1) ? "-" : "",
1092
               ((double) l1) / 64, (signs & 2) ? "-" : "", ((double) l2) / 64);
1093
      break;
1094
#ifndef SKIP_DECIMAL_FLOAT
1095
    case TYPE_DEC_FLOAT:
1096
      l1 &= 0xffffff;
1097
      l2 &= 0xffffff;
1098
      signs = generate_random () & 3;
1099
 
1100
      /* Get the suffix of Decimal Floting Points per
1101
         e->type->name.  Distinguish these three DFP types by
1102
         e->type->name.  */
1103
      if (strstr(e->type->name, "Decimal32")) suffix=0;
1104
      else if (strstr(e->type->name, "Decimal64")) suffix=1;
1105
      else if (strstr(e->type->name, "Decimal128")) suffix=2;
1106
      else
1107
        abort ();
1108
 
1109
      /* Formatted input/output specifiers for DFP types have not been
1110
         implemented in GLIBC.  %f here used in fprintf is just to
1111
         dump the numbers to outfile.  */
1112
      fprintf (outfile, "%s%f%s,%s%f%s",
1113
               (signs & 1) ? "-" : "", ((double) l1) / 64, DEC_SUFFIX[suffix],
1114
               (signs & 2) ? "-" : "", ((double) l2) / 64, DEC_SUFFIX[suffix]);
1115
      break;
1116
#endif
1117
    case TYPE_CINT:
1118
      signs = generate_random () & 3;
1119
      l1 &= e->type->maxval;
1120
      l2 &= e->type->maxval;
1121
      fprintf (outfile,
1122
               "CINT(%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s),",
1123
               (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
1124
               (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
1125
      signs = generate_random () & 3;
1126
      l1 = getrandll ();
1127
      l2 = getrandll ();
1128
      l1 &= e->type->maxval;
1129
      l2 &= e->type->maxval;
1130
      fprintf (outfile,
1131
               "CINT(%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s)",
1132
               (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
1133
               (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
1134
      break;
1135
    case TYPE_CUINT:
1136
      l1 &= e->type->maxval;
1137
      l2 &= e->type->maxval;
1138
      fprintf (outfile,
1139
               "CINT(%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s),",
1140
               l1, l1 > 4294967295U ? "LL" : "",
1141
               l2, l2 > 4294967295U ? "LL" : "");
1142
      l1 = getrandll ();
1143
      l2 = getrandll ();
1144
      l1 &= e->type->maxval;
1145
      l2 &= e->type->maxval;
1146
      fprintf (outfile,
1147
               "CINT(%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s)",
1148
               l1, l1 > 4294967295U ? "LL" : "",
1149
               l2, l2 > 4294967295U ? "LL" : "");
1150
      break;
1151
    case TYPE_CFLOAT:
1152
      l1 &= 0xffffff;
1153
      l2 &= 0xffffff;
1154
      signs = generate_random () & 3;
1155
      fprintf (outfile, "CDBL(%s%f,%s%f),",
1156
               (signs & 1) ? "-" : "", ((double) l1) / 64,
1157
               (signs & 2) ? "-" : "", ((double) l2) / 64);
1158
      l1 = getrandll ();
1159
      l2 = getrandll ();
1160
      l1 &= 0xffffff;
1161
      l2 &= 0xffffff;
1162
      signs = generate_random () & 3;
1163
      fprintf (outfile, "CDBL(%s%f,%s%f)",
1164
               (signs & 1) ? "-" : "", ((double) l1) / 64,
1165
               (signs & 2) ? "-" : "", ((double) l2) / 64);
1166
      break;
1167
    case TYPE_UENUM:
1168
      if (e->type->maxval == 0)
1169
        fputs ("e0_0,e0_0", outfile);
1170
      else if (e->type->maxval == 1)
1171
        fprintf (outfile, "e1_%" COMPAT_PRLL "d,e1_%" COMPAT_PRLL "d",
1172
                 l1 & 1, l2 & 1);
1173
      else
1174
        {
1175
          p = strchr (e->type->name, '\0');
1176
          while (--p >= e->type->name && *p >= '0' && *p <= '9');
1177
          p++;
1178
          l1 %= 7;
1179
          l2 %= 7;
1180
          if (l1 > 3)
1181
            l1 += e->type->maxval - 6;
1182
          if (l2 > 3)
1183
            l2 += e->type->maxval - 6;
1184
          fprintf (outfile, "e%s_%" COMPAT_PRLL "d,e%s_%" COMPAT_PRLL "d",
1185
                   p, l1, p, l2);
1186
        }
1187
      break;
1188
    case TYPE_SENUM:
1189
      p = strchr (e->type->name, '\0');
1190
      while (--p >= e->type->name && *p >= '0' && *p <= '9');
1191
      p++;
1192
      l1 %= 7;
1193
      l2 %= 7;
1194
      fprintf (outfile, "e%s_%s%" COMPAT_PRLL "d,e%s_%s%" COMPAT_PRLL "d",
1195
               p, l1 < 3 ? "m" : "",
1196
               l1 == 3 ? 0LL : e->type->maxval - (l1 & 3),
1197
               p, l2 < 3 ? "m" : "",
1198
               l2 == 3 ? 0LL : e->type->maxval - (l2 & 3));
1199
      break;
1200
    case TYPE_PTR:
1201
      l1 %= 256;
1202
      l2 %= 256;
1203
      fprintf (outfile,
1204
               "(%s)&intarray[%" COMPAT_PRLL "d], (%s)&intarray[%" COMPAT_PRLL "d]",
1205
               e->type->name, l1, e->type->name, l2);
1206
      break;
1207
    case TYPE_FNPTR:
1208
      l1 %= 10;
1209
      l2 %= 10;
1210
      fprintf (outfile, "fn%" COMPAT_PRLL "d,fn%" COMPAT_PRLL "d", l1, l2);
1211
      break;
1212
    default:
1213
      abort ();
1214
    }
1215
  fputs (")", outfile);
1216
}
1217
 
1218
int
1219
subvalues (struct entry *e, char *p, char *letter)
1220
{
1221
  int i, j;
1222
  char *q;
1223
  if (p >= namebuf + sizeof (namebuf) - 32)
1224
    abort ();
1225
  p[0] = *letter;
1226
  p[1] = '\0';
1227
  q = p + 1;
1228
  switch (e[0].etype)
1229
    {
1230
    case ETYPE_STRUCT_ARRAY:
1231
    case ETYPE_UNION_ARRAY:
1232
      if (e[0].arr_len == 0 || e[0].arr_len == 255)
1233
        {
1234
          *letter += 1 + e[0].len;
1235
          return 1 + e[0].len;
1236
        }
1237
      i = generate_random () % e[0].arr_len;
1238
      snprintf (p, sizeof (namebuf) - (p - namebuf) - 1,
1239
                "%c[%d]", *letter, i);
1240
      q = strchr (p, '\0');
1241
      /* FALLTHROUGH */
1242
    case ETYPE_STRUCT:
1243
    case ETYPE_UNION:
1244
      *q++ = '.';
1245
      ++*letter;
1246
      for (i = 1; i <= e[0].len; )
1247
        {
1248
          i += subvalues (e + i, q, letter);
1249
          if (e[0].etype == ETYPE_UNION || e[0].etype == ETYPE_UNION_ARRAY)
1250
            {
1251
              *letter += e[0].len - i + 1;
1252
              break;
1253
            }
1254
        }
1255
      return 1 + e[0].len;
1256
    case ETYPE_TYPE:
1257
      ++*letter;
1258
      output_FNB ('F', e);
1259
      return 1;
1260
    case ETYPE_ARRAY:
1261
      if (e[0].arr_len == 0 || e[0].arr_len == 255)
1262
        {
1263
          ++*letter;
1264
          return 1;
1265
        }
1266
      i = generate_random () % e[0].arr_len;
1267
      snprintf (p, sizeof (namebuf) - (p - namebuf),
1268
                "%c[%d]", *letter, i);
1269
      output_FNB ('F', e);
1270
      if ((generate_random () & 7) == 0)
1271
        {
1272
          j = generate_random () % e[0].arr_len;
1273
          if (i != j)
1274
            {
1275
              snprintf (p, sizeof (namebuf) - (p - namebuf),
1276
                        "%c[%d]", *letter, j);
1277
              output_FNB ('F', e);
1278
            }
1279
        }
1280
      ++*letter;
1281
      return 1;
1282
    case ETYPE_BITFLD:
1283
      ++*letter;
1284
      if (e[0].len != 0)
1285
        output_FNB ('B', e);
1286
      return 1;
1287
    }
1288
}
1289
 
1290
/* DERIVED FROM:
1291
--------------------------------------------------------------------
1292
lookup2.c, by Bob Jenkins, December 1996, Public Domain.
1293
hash(), hash2(), hash3, and mix() are externally useful functions.
1294
Routines to test the hash are included if SELF_TEST is defined.
1295
You can use this free for any purpose.  It has no warranty.
1296
--------------------------------------------------------------------
1297
*/
1298
 
1299
/*
1300
--------------------------------------------------------------------
1301
mix -- mix 3 32-bit values reversibly.
1302
For every delta with one or two bit set, and the deltas of all three
1303
  high bits or all three low bits, whether the original value of a,b,c
1304
  is almost all zero or is uniformly distributed,
1305
* If mix() is run forward or backward, at least 32 bits in a,b,c
1306
  have at least 1/4 probability of changing.
1307
* If mix() is run forward, every bit of c will change between 1/3 and
1308
  2/3 of the time.  (Well, 22/100 and 78/100 for some 2-bit deltas.)
1309
mix() was built out of 36 single-cycle latency instructions in a
1310
  structure that could supported 2x parallelism, like so:
1311
      a -= b;
1312
      a -= c; x = (c>>13);
1313
      b -= c; a ^= x;
1314
      b -= a; x = (a<<8);
1315
      c -= a; b ^= x;
1316
      c -= b; x = (b>>13);
1317
      ...
1318
  Unfortunately, superscalar Pentiums and Sparcs can't take advantage
1319
  of that parallelism.  They've also turned some of those single-cycle
1320
  latency instructions into multi-cycle latency instructions.  Still,
1321
  this is the fastest good hash I could find.  There were about 2^^68
1322
  to choose from.  I only looked at a billion or so.
1323
--------------------------------------------------------------------
1324
*/
1325
/* same, but slower, works on systems that might have 8 byte hashval_t's */
1326
#define mix(a,b,c) \
1327
{ \
1328
  a -= b; a -= c; a ^= (c>>13); \
1329
  b -= c; b -= a; b ^= (a<< 8); \
1330
  c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \
1331
  a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \
1332
  b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \
1333
  c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \
1334
  a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \
1335
  b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \
1336
  c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \
1337
}
1338
 
1339
/*
1340
--------------------------------------------------------------------
1341
hash() -- hash a variable-length key into a 32-bit value
1342
  k     : the key (the unaligned variable-length array of bytes)
1343
  len   : the length of the key, counting by bytes
1344
  level : can be any 4-byte value
1345
Returns a 32-bit value.  Every bit of the key affects every bit of
1346
the return value.  Every 1-bit and 2-bit delta achieves avalanche.
1347
About 36+6len instructions.
1348
 
1349
The best hash table sizes are powers of 2.  There is no need to do
1350
mod a prime (mod is sooo slow!).  If you need less than 32 bits,
1351
use a bitmask.  For example, if you need only 10 bits, do
1352
  h = (h & hashmask(10));
1353
In which case, the hash table should have hashsize(10) elements.
1354
 
1355
If you are hashing n strings (ub1 **)k, do it like this:
1356
  for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
1357
 
1358
By Bob Jenkins, 1996.  bob_jenkins@burtleburtle.net.  You may use this
1359
code any way you wish, private, educational, or commercial.  It's free.
1360
 
1361
See http://burtleburtle.net/bob/hash/evahash.html
1362
Use for hash table lookup, or anything where one collision in 2^32 is
1363
acceptable.  Do NOT use for cryptographic purposes.
1364
--------------------------------------------------------------------
1365
*/
1366
 
1367
static hashval_t
1368
iterative_hash (const void *k_in /* the key */,
1369
                register size_t  length /* the length of the key */,
1370
                register hashval_t initval /* the previous hash, or
1371
                                              an arbitrary value */)
1372
{
1373
  register const unsigned char *k = (const unsigned char *)k_in;
1374
  register hashval_t a,b,c,len;
1375
 
1376
  /* Set up the internal state */
1377
  len = length;
1378
  a = b = 0x9e3779b9;  /* the golden ratio; an arbitrary value */
1379
  c = initval;           /* the previous hash value */
1380
 
1381
  /*---------------------------------------- handle most of the key */
1382
    while (len >= 12)
1383
      {
1384
        a += (k[0] +((hashval_t)k[1]<<8) +((hashval_t)k[2]<<16) +((hashval_t)k[3]<<24));
1385
        b += (k[4] +((hashval_t)k[5]<<8) +((hashval_t)k[6]<<16) +((hashval_t)k[7]<<24));
1386
        c += (k[8] +((hashval_t)k[9]<<8) +((hashval_t)k[10]<<16)+((hashval_t)k[11]<<24));
1387
        mix(a,b,c);
1388
        k += 12; len -= 12;
1389
      }
1390
 
1391
  /*------------------------------------- handle the last 11 bytes */
1392
  c += length;
1393
  switch(len)              /* all the case statements fall through */
1394
    {
1395
    case 11: c+=((hashval_t)k[10]<<24);
1396
    case 10: c+=((hashval_t)k[9]<<16);
1397
    case 9 : c+=((hashval_t)k[8]<<8);
1398
      /* the first byte of c is reserved for the length */
1399
    case 8 : b+=((hashval_t)k[7]<<24);
1400
    case 7 : b+=((hashval_t)k[6]<<16);
1401
    case 6 : b+=((hashval_t)k[5]<<8);
1402
    case 5 : b+=k[4];
1403
    case 4 : a+=((hashval_t)k[3]<<24);
1404
    case 3 : a+=((hashval_t)k[2]<<16);
1405
    case 2 : a+=((hashval_t)k[1]<<8);
1406
    case 1 : a+=k[0];
1407
      /* case 0: nothing left to add */
1408
    }
1409
  mix(a,b,c);
1410
  /*-------------------------------------------- report the result */
1411
  return c;
1412
}
1413
 
1414
hashval_t
1415
e_hash (const void *a)
1416
{
1417
  const struct entry *e = a;
1418
  hashval_t ret = 0;
1419
  int i;
1420
 
1421
  if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION)
1422
    abort ();
1423
  for (i = 0; i <= e[0].len; ++i)
1424
    {
1425
      int attriblen;
1426
      ret = iterative_hash (&e[i], offsetof (struct entry, attrib), ret);
1427
      attriblen = e[i].attrib ? strlen (e[i].attrib) : -1;
1428
      ret = iterative_hash (&attriblen, sizeof (int), ret);
1429
      if (e[i].attrib)
1430
        ret = iterative_hash (e[i].attrib, attriblen, ret);
1431
    }
1432
  return ret;
1433
}
1434
 
1435
int
1436
e_eq (const void *a, const void *b)
1437
{
1438
  const struct entry *ea = a, *eb = b;
1439
  int i;
1440
  if (ea[0].etype != ETYPE_STRUCT && ea[0].etype != ETYPE_UNION)
1441
    abort ();
1442
  if (ea[0].len != eb[0].len)
1443
    return 0;
1444
  for (i = 0; i <= ea[0].len; ++i)
1445
    {
1446
      if (ea[i].etype != eb[i].etype
1447
          || ea[i].len != eb[i].len
1448
          || ea[i].arr_len != eb[i].arr_len
1449
          || ea[i].type != eb[i].type)
1450
        return 0;
1451
      if ((ea[i].attrib == NULL) ^ (eb[i].attrib == NULL))
1452
        return 0;
1453
      if (ea[i].attrib && strcmp (ea[i].attrib, eb[i].attrib) != 0)
1454
        return 0;
1455
    }
1456
  return 1;
1457
}
1458
 
1459
static int
1460
e_exists (const struct entry *e)
1461
{
1462
  struct entry *h;
1463
  hashval_t hval;
1464
 
1465
  hval = e_hash (e);
1466
  for (h = hash_table[hval % HASH_SIZE]; h; h = h->next)
1467
    if (e_eq (e, h))
1468
      return 1;
1469
  return 0;
1470
}
1471
 
1472
static void
1473
e_insert (struct entry *e)
1474
{
1475
  hashval_t hval;
1476
 
1477
  hval = e_hash (e);
1478
  e->next = hash_table[hval % HASH_SIZE];
1479
  hash_table[hval % HASH_SIZE] = e;
1480
}
1481
 
1482
void
1483
output (struct entry *e)
1484
{
1485
  int i;
1486
  char c;
1487
  struct entry *n;
1488
  const char *skip_cint = "";
1489
 
1490
  if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION)
1491
    abort ();
1492
 
1493
  if (e_exists (e))
1494
    return;
1495
 
1496
  n = (struct entry *) malloc ((e[0].len + 1) * sizeof (struct entry));
1497
  memcpy (n, e, (e[0].len + 1) * sizeof (struct entry));
1498
  e_insert (n);
1499
 
1500
  if (idx == limidx)
1501
    switchfiles (e[0].len);
1502
 
1503
  for (i = 1; i <= e[0].len; ++i)
1504
    if ((e[i].etype == ETYPE_TYPE || e[i].etype == ETYPE_ARRAY)
1505
        && (e[i].type->type == TYPE_CINT || e[i].type->type == TYPE_CUINT))
1506
      break;
1507
  if (i <= e[0].len)
1508
    skip_cint = "CI";
1509
  if (e[0].attrib)
1510
    fprintf (outfile, (generate_random () & 1)
1511
             ? "TX%s(%d,%s %s,," : "TX%s(%d,%s,%s,", skip_cint,
1512
             idx, e[0].etype == ETYPE_STRUCT ? "struct" : "union",
1513
             e[0].attrib);
1514
  else if (e[0].etype == ETYPE_STRUCT)
1515
    fprintf (outfile, "T%s(%d,", skip_cint, idx);
1516
  else
1517
    fprintf (outfile, "U%s(%d,", skip_cint, idx);
1518
  c = 'a';
1519
  for (i = 1; i <= e[0].len; )
1520
    i += subfield (e + i, &c);
1521
  fputs (",", outfile);
1522
  c = 'a';
1523
  for (i = 1; i <= e[0].len; )
1524
    {
1525
      i += subvalues (e + i, namebuf, &c);
1526
      if (e[0].etype == ETYPE_UNION)
1527
        break;
1528
    }
1529
  fputs (")\n", outfile);
1530
  if (output_one && idx == limidx)
1531
    exit (0);
1532
  ++idx;
1533
}
1534
 
1535
enum FEATURE
1536
{
1537
  FEATURE_VECTOR = 1,
1538
  FEATURE_COMPLEX = 2,
1539
  FEATURE_ALIGNEDPACKED = 4,
1540
  FEATURE_ZEROARRAY = 8,
1541
  FEATURE_ZEROBITFLD = 16,
1542
  ALL_FEATURES = FEATURE_COMPLEX | FEATURE_VECTOR | FEATURE_ZEROARRAY
1543
                 | FEATURE_ALIGNEDPACKED | FEATURE_ZEROBITFLD
1544
};
1545
 
1546
void
1547
singles (enum FEATURE features)
1548
{
1549
  struct entry e[2];
1550
  int i;
1551
  memset (e, 0, sizeof (e));
1552
  e[0].etype = ETYPE_STRUCT;
1553
  output (e);
1554
  e[0].etype = ETYPE_UNION;
1555
  output (e);
1556
  for (i = 0;
1557
       i < ((features & FEATURE_ALIGNEDPACKED) ? NATTRIBS2 : NATTRIBS1);
1558
       ++i)
1559
    {
1560
      e[0].attrib = attributes[i];
1561
      e[0].etype = ETYPE_STRUCT;
1562
      output (e);
1563
      e[0].etype = ETYPE_UNION;
1564
      output (e);
1565
    }
1566
  e[0].len = 1;
1567
  e[0].attrib = NULL;
1568
  for (i = 0; i < NTYPES2; ++i)
1569
    {
1570
      e[0].etype = ETYPE_STRUCT;
1571
      e[1].etype = ETYPE_TYPE;
1572
      e[1].type = &base_types[i];
1573
      output (e);
1574
      e[0].etype = ETYPE_UNION;
1575
      output (e);
1576
    }
1577
  if (features & FEATURE_COMPLEX)
1578
    for (i = 0; i < NCTYPES2; ++i)
1579
      {
1580
        e[0].etype = ETYPE_STRUCT;
1581
        e[1].etype = ETYPE_TYPE;
1582
        e[1].type = &complex_types[i];
1583
        output (e);
1584
        e[0].etype = ETYPE_UNION;
1585
        output (e);
1586
      }
1587
  if (features & FEATURE_VECTOR)
1588
    for (i = 0; i < NVTYPES2; ++i)
1589
      {
1590
        e[0].etype = ETYPE_STRUCT;
1591
        e[1].etype = ETYPE_TYPE;
1592
        e[1].type = &vector_types[i];
1593
        output (e);
1594
        e[0].etype = ETYPE_UNION;
1595
        output (e);
1596
      }
1597
}
1598
 
1599
void
1600
choose_type (enum FEATURE features, struct entry *e, int r, int in_array)
1601
{
1602
  int i;
1603
 
1604
  i = NTYPES2 - NTYPES1;
1605
  if (features & FEATURE_COMPLEX)
1606
    i += NCTYPES2;
1607
  if (features & FEATURE_VECTOR)
1608
    i += NVTYPES2;
1609
  if ((r & 3) == 0)
1610
    {
1611
      if (in_array)
1612
        {
1613
          i += NAATYPES2;
1614
          if (features & FEATURE_COMPLEX)
1615
            i += NCAATYPES2;
1616
        }
1617
      else
1618
        {
1619
          i += NATYPES2;
1620
          if (features & FEATURE_COMPLEX)
1621
            i += NCATYPES2;
1622
        }
1623
    }
1624
  r >>= 2;
1625
  r %= i;
1626
  if (r < NTYPES2 - NTYPES1)
1627
    e->type = &base_types[r + NTYPES1];
1628
  r -= NTYPES2 - NTYPES1;
1629
  if (e->type == NULL && (features & FEATURE_COMPLEX))
1630
    {
1631
      if (r < NCTYPES2)
1632
        e->type = &complex_types[r];
1633
      r -= NCTYPES2;
1634
    }
1635
  if (e->type == NULL && (features & FEATURE_VECTOR))
1636
    {
1637
      if (r < NVTYPES2)
1638
        e->type = &vector_types[r];
1639
      r -= NVTYPES2;
1640
    }
1641
  if (e->type == NULL && !in_array)
1642
    {
1643
      if (r < NATYPES2)
1644
        e->type = &attrib_types[r];
1645
      r -= NATYPES2;
1646
    }
1647
  if (e->type == NULL && !in_array && (features & FEATURE_COMPLEX))
1648
    {
1649
      if (r < NCATYPES2)
1650
        e->type = &complex_attrib_types[r];
1651
      r -= NCATYPES2;
1652
    }
1653
  if (e->type == NULL && in_array)
1654
    {
1655
      if (r < NAATYPES2)
1656
        e->type = &attrib_array_types[r];
1657
      r -= NAATYPES2;
1658
    }
1659
  if (e->type == NULL && in_array && (features & FEATURE_COMPLEX))
1660
    {
1661
      if (r < NCAATYPES2)
1662
        e->type = &complex_attrib_array_types[r];
1663
      r -= NCAATYPES2;
1664
    }
1665
  if (e->type == NULL)
1666
    abort ();
1667
}
1668
 
1669
/* This is from gcc.c-torture/execute/builtin-bitops-1.c.  */
1670
static int
1671
my_ffsll (unsigned long long x)
1672
{
1673
  int i;
1674
  if (x == 0)
1675
    return 0;
1676
  /* We've tested LLONG_MAX for 64 bits so this should be safe.  */
1677
  for (i = 0; i < 64; i++)
1678
    if (x & (1ULL << i))
1679
      break;
1680
  return i + 1;
1681
}
1682
 
1683
void
1684
generate_fields (enum FEATURE features, struct entry *e, struct entry *parent,
1685
                 int len)
1686
{
1687
  int r, i, j, ret = 1, n, incr, sametype;
1688
 
1689
  for (n = 0; n < len; n += incr)
1690
    {
1691
      r = generate_random ();
1692
      /* 50% ETYPE_TYPE base_types NTYPES1
1693
         12.5% ETYPE_TYPE other
1694
         12.5% ETYPE_ARRAY
1695
         12.5% ETYPE_BITFLD
1696
         12.5% ETYPE_STRUCT|ETYPE_UNION|ETYPE_STRUCT_ARRAY|ETYPE_UNION_ARRAY */
1697
      i = (r & 7);
1698
      r >>= 3;
1699
      incr = 1;
1700
      switch (i)
1701
        {
1702
        case 0:
1703
        case 1:
1704
        case 2:
1705
        case 3:
1706
          e[n].etype = ETYPE_TYPE;
1707
          e[n].type = &base_types[r % NTYPES1];
1708
          break;
1709
        case 4:
1710
          e[n].etype = ETYPE_TYPE;
1711
          choose_type (features, &e[n], r, 0);
1712
          break;
1713
        case 5:
1714
          e[n].etype = ETYPE_ARRAY;
1715
          i = r & 1;
1716
          r >>= 1;
1717
          if (i)
1718
            e[n].type = &base_types[r % NTYPES1];
1719
          else
1720
            choose_type (features, &e[n], r, 1);
1721
          r = generate_random ();
1722
          if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0)
1723
            {
1724
              e[n].arr_len = 0;
1725
              if (n == len - 1 && (r & 4)
1726
                  && (parent->etype == ETYPE_STRUCT
1727
                      || parent->etype == ETYPE_STRUCT_ARRAY))
1728
                {
1729
                  int k;
1730
                  for (k = 0; k < n; ++k)
1731
                    if (e[k].etype != ETYPE_BITFLD || e[k].len)
1732
                      {
1733
                        e[n].arr_len = 255;
1734
                        break;
1735
                      }
1736
                }
1737
            }
1738
          else if ((r & 3) != 3)
1739
            e[n].arr_len = (r >> 2) & 7;
1740
          else
1741
            e[n].arr_len = (r >> 2) & 31;
1742
          break;
1743
        case 6:
1744
          sametype = 1;
1745
          switch (r & 7)
1746
            {
1747
            case 0:
1748
            case 1:
1749
            case 2:
1750
              break;
1751
            case 3:
1752
            case 4:
1753
            case 5:
1754
              incr = 1 + (r >> 3) % (len - n);
1755
              break;
1756
            case 6:
1757
            case 7:
1758
              sametype = 0;
1759
              incr = 1 + (r >> 3) % (len - n);
1760
              break;
1761
            }
1762
          for (j = n; j < n + incr; ++j)
1763
            {
1764
              int mi, ma;
1765
 
1766
              e[j].etype = ETYPE_BITFLD;
1767
              if (j == n || !sametype)
1768
                {
1769
                  int k;
1770
                  r = generate_random ();
1771
                  k = r & 3;
1772
                  r >>= 2;
1773
                  if (!k)
1774
                    e[j].type
1775
                      = &aligned_bitfld_types[r % n_aligned_bitfld_types];
1776
                  else
1777
                    e[j].type
1778
                      = &bitfld_types[r % n_bitfld_types];
1779
                }
1780
              else
1781
                e[j].type = e[n].type;
1782
              r = generate_random ();
1783
              mi = 0;
1784
              ma = 0;
1785
              switch (e[j].type->bitfld)
1786
                {
1787
                case 'C': ma = 8; break;
1788
                case 'S': ma = 16; break;
1789
                case 'I': ma = 32; break;
1790
                case 'L':
1791
                case 'Q': ma = 64; break;
1792
                case 'B': ma = 1; break;
1793
                case ' ':
1794
                  if (e[j].type->type == TYPE_UENUM)
1795
                    mi = my_ffsll (e[j].type->maxval + 1) - 1;
1796
                  else if (e[j].type->type == TYPE_SENUM)
1797
                    mi = my_ffsll (e[j].type->maxval + 1);
1798
                  else
1799
                    abort ();
1800
                  if (!mi)
1801
                    mi = 1;
1802
                  if (mi > 32)
1803
                    ma = 64;
1804
                  else if (mi > 16 || !short_enums)
1805
                    ma = 32;
1806
                  else if (mi > 8)
1807
                    ma = 16;
1808
                  else
1809
                    ma = 8;
1810
                  break;
1811
                default:
1812
                  abort ();
1813
                }
1814
              e[j].len = ma + 1;
1815
              if (sametype && (r & 3) == 0 && ma > 1)
1816
                {
1817
                  int sum = 0, k;
1818
                  for (k = n; k < j; ++k)
1819
                    sum += e[k].len;
1820
                  sum %= ma;
1821
                  e[j].len = sum ? ma - sum : ma;
1822
                }
1823
              r >>= 2;
1824
              if (! (features & FEATURE_ZEROBITFLD) && mi == 0)
1825
                mi = 1;
1826
              if (e[j].len < mi || e[j].len > ma)
1827
                e[j].len = mi + (r % (ma + 1 - mi));
1828
              r >>= 6;
1829
              if ((features & FEATURE_ZEROBITFLD) && (r & 3) == 0
1830
                  && mi == 0)
1831
                e[j].len = 0;
1832
            }
1833
          break;
1834
        case 7:
1835
          switch (r & 7)
1836
            {
1837
            case 0:
1838
            case 1:
1839
            case 2:
1840
              e[n].etype = ETYPE_STRUCT;
1841
              break;
1842
            case 3:
1843
            case 4:
1844
              e[n].etype = ETYPE_UNION;
1845
              break;
1846
            case 5:
1847
            case 6:
1848
              e[n].etype = ETYPE_STRUCT_ARRAY;
1849
              break;
1850
            case 7:
1851
              e[n].etype = ETYPE_UNION_ARRAY;
1852
              break;
1853
            }
1854
          r >>= 3;
1855
          e[n].len = r % (len - n);
1856
          incr = 1 + e[n].len;
1857
          generate_fields (features, &e[n + 1], &e[n], e[n].len);
1858
          if (e[n].etype == ETYPE_STRUCT_ARRAY
1859
              || e[n].etype == ETYPE_UNION_ARRAY)
1860
            {
1861
              r = generate_random ();
1862
              if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0)
1863
                {
1864
                  e[n].arr_len = 0;
1865
                  if (n + incr == len && (r & 4)
1866
                      && (parent->etype == ETYPE_STRUCT
1867
                          || parent->etype == ETYPE_STRUCT_ARRAY))
1868
                    {
1869
                      int k;
1870
                      for (k = 0; k < n; ++k)
1871
                        if (e[k].etype != ETYPE_BITFLD || e[k].len)
1872
                          {
1873
                            e[n].arr_len = 255;
1874
                            break;
1875
                          }
1876
                    }
1877
                }
1878
              else if ((r & 3) != 3)
1879
                e[n].arr_len = (r >> 2) & 7;
1880
              else
1881
                e[n].arr_len = (r >> 2) & 31;
1882
            }
1883
          break;
1884
        }
1885
      r = generate_random ();
1886
      if ((r & 7) == 0)
1887
        {
1888
          r >>= 3;
1889
          i = (features & FEATURE_ALIGNEDPACKED) ? NATTRIBS2 : NATTRIBS1;
1890
          e[n].attrib = attributes[r % i];
1891
          if (! (features & FEATURE_ALIGNEDPACKED)
1892
              && strcmp (e[n].attrib, "atpa") == 0
1893
              && ((e[n].type >= &attrib_types[0]
1894
                   && e[n].type < &attrib_types[NATYPES2])
1895
                  || (e[n].type >= &complex_attrib_types[0]
1896
                      && e[n].type < &complex_attrib_types[NCATYPES2])
1897
                  || (e[n].type >= &attrib_array_types[0]
1898
                      && e[n].type < &attrib_array_types[NAATYPES2])
1899
                  || (e[n].type >= &complex_attrib_array_types[0]
1900
                      && e[n].type < &complex_attrib_array_types[NAATYPES2])
1901
                  || (e[n].type >= &aligned_bitfld_types[0]
1902
                      && e[n].type < &aligned_bitfld_types[n_aligned_bitfld_types])))
1903
            e[n].attrib = NULL;
1904
        }
1905
    }
1906
}
1907
 
1908
void
1909
generate_random_tests (enum FEATURE features, int len)
1910
{
1911
  struct entry e[len + 1];
1912
  int i, r;
1913
  if (len > 'z' - 'a' + 1)
1914
    abort ();
1915
  memset (e, 0, sizeof (e));
1916
  r = generate_random ();
1917
  if ((r & 7) == 0)
1918
    e[0].etype = ETYPE_UNION;
1919
  else
1920
    e[0].etype = ETYPE_STRUCT;
1921
  r >>= 3;
1922
  e[0].len = len;
1923
  if ((r & 31) == 0)
1924
    {
1925
      r >>= 5;
1926
      if (features & FEATURE_ALIGNEDPACKED)
1927
        r %= NATTRIBS2;
1928
      else
1929
        r %= NATTRIBS1;
1930
      e[0].attrib = attributes[r];
1931
    }
1932
  generate_fields (features, &e[1], &e[0], len);
1933
  output (e);
1934
}
1935
 
1936
struct { const char *name; enum FEATURE f; }
1937
features[] = {
1938
{ "normal", 0 },
1939
{ "complex", FEATURE_COMPLEX },
1940
{ "vector", FEATURE_VECTOR },
1941
{ "[0] :0", FEATURE_ZEROARRAY | FEATURE_ZEROBITFLD },
1942
{ "complex vector [0]",
1943
  FEATURE_COMPLEX | FEATURE_VECTOR | FEATURE_ZEROARRAY },
1944
{ "aligned packed complex vector [0] :0",
1945
  FEATURE_COMPLEX | FEATURE_VECTOR | FEATURE_ZEROARRAY
1946
  | FEATURE_ALIGNEDPACKED | FEATURE_ZEROBITFLD },
1947
};
1948
 
1949
int
1950
main (int argc, char **argv)
1951
{
1952
  int i, j, count, c, n = 3000;
1953
  char *optarg;
1954
 
1955
  if (sizeof (int) != 4 || sizeof (long long) != 8)
1956
    return 1;
1957
 
1958
  i = 1;
1959
  while (i < argc)
1960
    {
1961
      c = '\0';
1962
      if (argv[i][0] == '-' && argv[i][2] == '\0')
1963
        c = argv[i][1];
1964
      optarg = argv[i + 1];
1965
      if (!optarg)
1966
        goto usage;
1967
      switch (c)
1968
        {
1969
        case 'n':
1970
          n = atoi (optarg);
1971
          break;
1972
        case 'd':
1973
          destdir = optarg;
1974
          break;
1975
        case 's':
1976
          srcdir = optarg;
1977
          break;
1978
        case 'i':
1979
          output_one = 1;
1980
          limidx = atoi (optarg);
1981
          break;
1982
        case 'e':
1983
          short_enums = 1;
1984
          i--;
1985
          break;
1986
        default:
1987
          fprintf (stderr, "unrecognized option %s\n", argv[i]);
1988
          goto usage;
1989
      }
1990
      i += 2;
1991
    }
1992
 
1993
  if (output_one)
1994
    {
1995
      outfile = fopen ("/dev/null", "w");
1996
      if (outfile == NULL)
1997
        {
1998
          fputs ("could not open /dev/null", stderr);
1999
          return 1;
2000
        }
2001
      n = limidx + 1;
2002
    }
2003
 
2004
  if (destdir == NULL && !output_one)
2005
    {
2006
    usage:
2007
      fprintf (stderr, "Usage:\n\
2008
%s [-e] [-s srcdir -d destdir] [-n count] [-i idx]\n\
2009
Either -s srcdir -d destdir or -i idx must be used\n", argv[0]);
2010
      return 1;
2011
    }
2012
 
2013
  if (srcdir == NULL && !output_one)
2014
    goto usage;
2015
 
2016
  if (srcdir != NULL)
2017
    {
2018
      const char *s = srcdir;
2019
      char *ss, *t;
2020
      t = ss = malloc (strlen (srcdir) + 1);
2021
      if (!ss)
2022
        abort ();
2023
      do {
2024
        if (*s == '\\')
2025
          *t++ = '/';
2026
        else
2027
          *t++ = *s;
2028
      } while (*s++);
2029
      srcdir_safe = ss;
2030
    }
2031
 
2032
  for (i = 0; i < NTYPES2; ++i)
2033
    if (base_types[i].bitfld)
2034
      bitfld_types[n_bitfld_types++] = base_types[i];
2035
  for (i = 0; i < NATYPES2; ++i)
2036
    if (attrib_types[i].bitfld)
2037
      aligned_bitfld_types[n_aligned_bitfld_types++] = attrib_types[i];
2038
  for (i = 0; i < sizeof (features) / sizeof (features[0]); ++i)
2039
    {
2040
      int startidx = idx;
2041
      if (! output_one)
2042
        limidx = idx;
2043
      if (!i)
2044
        count = 200;
2045
      else
2046
        count = 20;
2047
      for (j = 1; j <= 9; ++j)
2048
        while (idx < startidx + j * count)
2049
          generate_random_tests (features[i].f, j);
2050
      while (idx < startidx + count * 10)
2051
        generate_random_tests (features[i].f, 10 + (generate_random () % 16));
2052
    }
2053
  for (i = 0; n > 3000 && i < sizeof (features) / sizeof (features[0]); ++i)
2054
    {
2055
      int startidx;
2056
      startidx = idx;
2057
      if (! output_one)
2058
        limidx = idx;
2059
      singles (features[i].f);
2060
      if (!i)
2061
        {
2062
          count = 1000;
2063
          while (idx < startidx + 1000)
2064
            generate_random_tests (features[i].f, 1);
2065
        }
2066
      else
2067
        {
2068
          startidx = idx;
2069
          count = 100;
2070
          while (idx < startidx + 100)
2071
            generate_random_tests (features[i].f, 1);
2072
        }
2073
      startidx = idx;
2074
      for (j = 2; j <= 9; ++j)
2075
        while (idx < startidx + (j - 1) * count)
2076
          generate_random_tests (features[i].f, j);
2077
      while (idx < startidx + count * 9)
2078
        generate_random_tests (features[i].f, 10 + (generate_random () % 16));
2079
    }
2080
  if (! output_one)
2081
    limidx = idx;
2082
  while (idx < n)
2083
    generate_random_tests (ALL_FEATURES, 1 + (generate_random () % 25));
2084
  fclose (outfile);
2085
  return 0;
2086
}

powered by: WebSVN 2.1.0

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