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