OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc2/] [gcc/] [testsuite/] [g++.dg/] [compat/] [struct-layout-1_generate.c] - Diff between revs 301 and 384

Only display areas with differences | Details | Blame | View Log

Rev 301 Rev 384
/* Structure layout test generator.
/* Structure layout test generator.
   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
   Contributed by Jakub Jelinek <jakub@redhat.com>.
   Contributed by Jakub Jelinek <jakub@redhat.com>.
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify it under
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
Software Foundation; either version 3, or (at your option) any later
version.
version.
 
 
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
<http://www.gnu.org/licenses/>.  */
 
 
 
 
/* Compile with gcc -o struct-layout-1_generate{,.c} generate_random{,_r}.c */
/* Compile with gcc -o struct-layout-1_generate{,.c} generate_random{,_r}.c */
 
 
/* N.B. -- This program cannot use libiberty as that will not work
/* N.B. -- This program cannot use libiberty as that will not work
   when testing an installed compiler.  */
   when testing an installed compiler.  */
#include <limits.h>
#include <limits.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <stddef.h>
#include <stddef.h>
/* We use our own pseudo-random number generator, so that it gives the same
/* We use our own pseudo-random number generator, so that it gives the same
   values on all hosts.  */
   values on all hosts.  */
#include "../../gcc.dg/compat/generate-random.h"
#include "../../gcc.dg/compat/generate-random.h"
 
 
#if LLONG_MAX != 9223372036854775807LL && __LONG_LONG_MAX__ != 9223372036854775807LL
#if LLONG_MAX != 9223372036854775807LL && __LONG_LONG_MAX__ != 9223372036854775807LL
# error Need 64-bit long long
# error Need 64-bit long long
#endif
#endif
 
 
#if defined __MSVCRT__ 
#if defined __MSVCRT__ 
#define COMPAT_PRLL "I64"
#define COMPAT_PRLL "I64"
#else 
#else 
#define COMPAT_PRLL "ll"
#define COMPAT_PRLL "ll"
#endif
#endif
 
 
const char *dg_options[] = {
const char *dg_options[] = {
"/* { dg-options \"%s-I%s\" } */\n",
"/* { dg-options \"%s-I%s\" } */\n",
"/* { dg-options \"%s-I%s -mno-mmx -Wno-abi\" { target i?86-*-* x86_64-*-* } } */\n",
"/* { dg-options \"%s-I%s -mno-mmx -Wno-abi\" { target i?86-*-* x86_64-*-* } } */\n",
"/* { dg-options \"%s-I%s -fno-common\" { target hppa*-*-hpux* powerpc*-*-darwin* *-*-mingw32* *-*-cygwin* } } */\n",
"/* { dg-options \"%s-I%s -fno-common\" { target hppa*-*-hpux* powerpc*-*-darwin* *-*-mingw32* *-*-cygwin* } } */\n",
"/* { dg-options \"%s-I%s -mno-mmx -fno-common -Wno-abi\" { target i?86-*-darwin* x86_64-*-darwin* } } */\n",
"/* { dg-options \"%s-I%s -mno-mmx -fno-common -Wno-abi\" { target i?86-*-darwin* x86_64-*-darwin* } } */\n",
"/* { dg-options \"%s-I%s -mno-base-addresses\" { target mmix-*-* } } */\n",
"/* { dg-options \"%s-I%s -mno-base-addresses\" { target mmix-*-* } } */\n",
"/* { dg-options \"%s-I%s -mlongcalls -mtext-section-literals\" { target xtensa*-*-* } } */\n"
"/* { dg-options \"%s-I%s -mlongcalls -mtext-section-literals\" { target xtensa*-*-* } } */\n"
#define NDG_OPTIONS (sizeof (dg_options) / sizeof (dg_options[0]))
#define NDG_OPTIONS (sizeof (dg_options) / sizeof (dg_options[0]))
};
};
 
 
typedef unsigned int hashval_t;
typedef unsigned int hashval_t;
 
 
enum TYPE
enum TYPE
{
{
  TYPE_INT,
  TYPE_INT,
  TYPE_UINT,
  TYPE_UINT,
  TYPE_FLOAT,
  TYPE_FLOAT,
  TYPE_SENUM,
  TYPE_SENUM,
  TYPE_UENUM,
  TYPE_UENUM,
  TYPE_PTR,
  TYPE_PTR,
  TYPE_FNPTR,
  TYPE_FNPTR,
  TYPE_OTHER
  TYPE_OTHER
};
};
 
 
struct types
struct types
{
{
  const char *name;
  const char *name;
  enum TYPE type;
  enum TYPE type;
  unsigned long long int maxval;
  unsigned long long int maxval;
  char bitfld;
  char bitfld;
};
};
 
 
struct types base_types[] = {
struct types base_types[] = {
/* As we don't know whether char will be signed or not, just limit ourselves
/* As we don't know whether char will be signed or not, just limit ourselves
   to unsigned values less than maximum signed char value.  */
   to unsigned values less than maximum signed char value.  */
{ "char", TYPE_UINT, 127, 'C' },
{ "char", TYPE_UINT, 127, 'C' },
{ "signed char", TYPE_INT, 127, 'C' },
{ "signed char", TYPE_INT, 127, 'C' },
{ "unsigned char", TYPE_UINT, 255, 'C' },
{ "unsigned char", TYPE_UINT, 255, 'C' },
{ "short int", TYPE_INT, 32767, 'S' },
{ "short int", TYPE_INT, 32767, 'S' },
{ "unsigned short int", TYPE_UINT, 65535, 'S' },
{ "unsigned short int", TYPE_UINT, 65535, 'S' },
{ "int", TYPE_INT, 2147483647, 'I' },
{ "int", TYPE_INT, 2147483647, 'I' },
{ "unsigned int", TYPE_UINT, 4294967295U, 'I' },
{ "unsigned int", TYPE_UINT, 4294967295U, 'I' },
{ "long int", TYPE_INT, 9223372036854775807LL, 'L' },
{ "long int", TYPE_INT, 9223372036854775807LL, 'L' },
{ "unsigned long int", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "unsigned long int", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "long long int", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "long long int", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "unsigned long long int", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "unsigned long long int", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "bool", TYPE_UINT, 1, 'B' },
{ "bool", TYPE_UINT, 1, 'B' },
{ "void *", TYPE_PTR, 0, 0 },
{ "void *", TYPE_PTR, 0, 0 },
{ "char *", TYPE_PTR, 0, 0 },
{ "char *", TYPE_PTR, 0, 0 },
{ "int *", TYPE_PTR, 0, 0 },
{ "int *", TYPE_PTR, 0, 0 },
{ "float", TYPE_FLOAT, 0, 0 },
{ "float", TYPE_FLOAT, 0, 0 },
{ "double", TYPE_FLOAT, 0, 0 },
{ "double", TYPE_FLOAT, 0, 0 },
{ "long double", TYPE_FLOAT, 0, 0 },
{ "long double", TYPE_FLOAT, 0, 0 },
#define NTYPES1 18
#define NTYPES1 18
{ "Tchar", TYPE_UINT, 127, 'C' },
{ "Tchar", TYPE_UINT, 127, 'C' },
{ "Tschar", TYPE_INT, 127, 'C' },
{ "Tschar", TYPE_INT, 127, 'C' },
{ "Tuchar", TYPE_UINT, 255, 'C' },
{ "Tuchar", TYPE_UINT, 255, 'C' },
{ "Tshort", TYPE_INT, 32767, 'S' },
{ "Tshort", TYPE_INT, 32767, 'S' },
{ "Tushort", TYPE_UINT, 65535, 'S' },
{ "Tushort", TYPE_UINT, 65535, 'S' },
{ "Tint", TYPE_INT, 2147483647, 'I' },
{ "Tint", TYPE_INT, 2147483647, 'I' },
{ "Tuint", TYPE_UINT, 4294967295U, 'I' },
{ "Tuint", TYPE_UINT, 4294967295U, 'I' },
{ "Tlong", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tlong", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tllong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tllong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tbool", TYPE_UINT, 1, 'B' },
{ "Tbool", TYPE_UINT, 1, 'B' },
{ "size_t", TYPE_UINT, 18446744073709551615ULL, 0 },
{ "size_t", TYPE_UINT, 18446744073709551615ULL, 0 },
{ "Tptr", TYPE_PTR, 0, 0 },
{ "Tptr", TYPE_PTR, 0, 0 },
{ "Tcptr", TYPE_PTR, 0, 0 },
{ "Tcptr", TYPE_PTR, 0, 0 },
{ "Tiptr", TYPE_PTR, 0, 0 },
{ "Tiptr", TYPE_PTR, 0, 0 },
{ "Tfnptr", TYPE_FNPTR, 0, 0 },
{ "Tfnptr", TYPE_FNPTR, 0, 0 },
{ "Tfloat", TYPE_FLOAT, 0, 0 },
{ "Tfloat", TYPE_FLOAT, 0, 0 },
{ "Tdouble", TYPE_FLOAT, 0, 0 },
{ "Tdouble", TYPE_FLOAT, 0, 0 },
{ "Tldouble", TYPE_FLOAT, 0, 0 },
{ "Tldouble", TYPE_FLOAT, 0, 0 },
{ "enum E0", TYPE_UENUM, 0, ' ' },
{ "enum E0", TYPE_UENUM, 0, ' ' },
{ "enum E1", TYPE_UENUM, 1, ' ' },
{ "enum E1", TYPE_UENUM, 1, ' ' },
{ "enum E2", TYPE_SENUM, 3, ' ' },
{ "enum E2", TYPE_SENUM, 3, ' ' },
{ "enum E3", TYPE_SENUM, 127, ' ' },
{ "enum E3", TYPE_SENUM, 127, ' ' },
{ "enum E4", TYPE_UENUM, 255, ' ' },
{ "enum E4", TYPE_UENUM, 255, ' ' },
{ "enum E5", TYPE_SENUM, 32767, ' ' },
{ "enum E5", TYPE_SENUM, 32767, ' ' },
{ "enum E6", TYPE_UENUM, 65535, ' ' },
{ "enum E6", TYPE_UENUM, 65535, ' ' },
{ "enum E7", TYPE_SENUM, 2147483647, ' ' },
{ "enum E7", TYPE_SENUM, 2147483647, ' ' },
{ "enum E8", TYPE_UENUM, 4294967295U, ' ' },
{ "enum E8", TYPE_UENUM, 4294967295U, ' ' },
{ "enum E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "enum E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "TE0", TYPE_UENUM, 0, ' ' },
{ "TE0", TYPE_UENUM, 0, ' ' },
{ "TE1", TYPE_UENUM, 1, ' ' },
{ "TE1", TYPE_UENUM, 1, ' ' },
{ "TE2", TYPE_SENUM, 3, ' ' },
{ "TE2", TYPE_SENUM, 3, ' ' },
{ "TE3", TYPE_SENUM, 127, ' ' },
{ "TE3", TYPE_SENUM, 127, ' ' },
{ "TE4", TYPE_UENUM, 255, ' ' },
{ "TE4", TYPE_UENUM, 255, ' ' },
{ "TE5", TYPE_SENUM, 32767, ' ' },
{ "TE5", TYPE_SENUM, 32767, ' ' },
{ "TE6", TYPE_UENUM, 65535, ' ' },
{ "TE6", TYPE_UENUM, 65535, ' ' },
{ "TE7", TYPE_SENUM, 2147483647, ' ' },
{ "TE7", TYPE_SENUM, 2147483647, ' ' },
{ "TE8", TYPE_UENUM, 4294967295U, ' ' },
{ "TE8", TYPE_UENUM, 4294967295U, ' ' },
{ "TE9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "TE9", TYPE_SENUM, 1099511627775LL, ' ' },
/* vector-defs.h typedefs */
/* vector-defs.h typedefs */
{ "qi", TYPE_INT, 127, 0 },
{ "qi", TYPE_INT, 127, 0 },
{ "hi", TYPE_INT, 32767, 0 },
{ "hi", TYPE_INT, 32767, 0 },
{ "si", TYPE_INT, 2147483647, 0 },
{ "si", TYPE_INT, 2147483647, 0 },
{ "di", TYPE_INT, 9223372036854775807LL, 0 },
{ "di", TYPE_INT, 9223372036854775807LL, 0 },
{ "sf", TYPE_FLOAT, 0, 0 },
{ "sf", TYPE_FLOAT, 0, 0 },
{ "df", TYPE_FLOAT, 0, 0 }
{ "df", TYPE_FLOAT, 0, 0 }
#define NTYPES2 (sizeof (base_types) / sizeof (base_types[0]))
#define NTYPES2 (sizeof (base_types) / sizeof (base_types[0]))
};
};
struct types vector_types[] = {
struct types vector_types[] = {
/* vector-defs.h typedefs */
/* vector-defs.h typedefs */
{ "v8qi", TYPE_OTHER, 0, 0 },
{ "v8qi", TYPE_OTHER, 0, 0 },
{ "v16qi", TYPE_OTHER, 0, 0 },
{ "v16qi", TYPE_OTHER, 0, 0 },
{ "v2hi", TYPE_OTHER, 0, 0 },
{ "v2hi", TYPE_OTHER, 0, 0 },
{ "v4hi", TYPE_OTHER, 0, 0 },
{ "v4hi", TYPE_OTHER, 0, 0 },
{ "v8hi", TYPE_OTHER, 0, 0 },
{ "v8hi", TYPE_OTHER, 0, 0 },
{ "v2si", TYPE_OTHER, 0, 0 },
{ "v2si", TYPE_OTHER, 0, 0 },
{ "v4si", TYPE_OTHER, 0, 0 },
{ "v4si", TYPE_OTHER, 0, 0 },
{ "v1di", TYPE_OTHER, 0, 0 },
{ "v1di", TYPE_OTHER, 0, 0 },
{ "v2di", TYPE_OTHER, 0, 0 },
{ "v2di", TYPE_OTHER, 0, 0 },
{ "v2sf", TYPE_OTHER, 0, 0 },
{ "v2sf", TYPE_OTHER, 0, 0 },
{ "v4sf", TYPE_OTHER, 0, 0 },
{ "v4sf", TYPE_OTHER, 0, 0 },
{ "v16sf", TYPE_OTHER, 0, 0 },
{ "v16sf", TYPE_OTHER, 0, 0 },
{ "v2df", TYPE_OTHER, 0, 0 },
{ "v2df", TYPE_OTHER, 0, 0 },
{ "u8qi", TYPE_OTHER, 0, 0 },
{ "u8qi", TYPE_OTHER, 0, 0 },
{ "u16qi", TYPE_OTHER, 0, 0 },
{ "u16qi", TYPE_OTHER, 0, 0 },
{ "u2hi", TYPE_OTHER, 0, 0 },
{ "u2hi", TYPE_OTHER, 0, 0 },
{ "u4hi", TYPE_OTHER, 0, 0 },
{ "u4hi", TYPE_OTHER, 0, 0 },
{ "u8hi", TYPE_OTHER, 0, 0 },
{ "u8hi", TYPE_OTHER, 0, 0 },
{ "u2si", TYPE_OTHER, 0, 0 },
{ "u2si", TYPE_OTHER, 0, 0 },
{ "u4si", TYPE_OTHER, 0, 0 },
{ "u4si", TYPE_OTHER, 0, 0 },
{ "u1di", TYPE_OTHER, 0, 0 },
{ "u1di", TYPE_OTHER, 0, 0 },
{ "u2di", TYPE_OTHER, 0, 0 },
{ "u2di", TYPE_OTHER, 0, 0 },
{ "u2sf", TYPE_OTHER, 0, 0 },
{ "u2sf", TYPE_OTHER, 0, 0 },
{ "u4sf", TYPE_OTHER, 0, 0 },
{ "u4sf", TYPE_OTHER, 0, 0 },
{ "u16sf", TYPE_OTHER, 0, 0 },
{ "u16sf", TYPE_OTHER, 0, 0 },
{ "u2df", TYPE_OTHER, 0, 0 },
{ "u2df", TYPE_OTHER, 0, 0 },
{ "__m64", TYPE_OTHER, 0, 0 },
{ "__m64", TYPE_OTHER, 0, 0 },
{ "__m128", TYPE_OTHER, 0, 0 }
{ "__m128", TYPE_OTHER, 0, 0 }
#define NVTYPES2 (sizeof (vector_types) / sizeof (vector_types[0]))
#define NVTYPES2 (sizeof (vector_types) / sizeof (vector_types[0]))
};
};
struct types attrib_types[] = {
struct types attrib_types[] = {
{ "Talchar", TYPE_UINT, 127, 'C' },
{ "Talchar", TYPE_UINT, 127, 'C' },
{ "Talschar", TYPE_INT, 127, 'C' },
{ "Talschar", TYPE_INT, 127, 'C' },
{ "Taluchar", TYPE_UINT, 255, 'C' },
{ "Taluchar", TYPE_UINT, 255, 'C' },
{ "Talshort", TYPE_INT, 32767, 'S' },
{ "Talshort", TYPE_INT, 32767, 'S' },
{ "Talushort", TYPE_UINT, 65535, 'S' },
{ "Talushort", TYPE_UINT, 65535, 'S' },
{ "Talint", TYPE_INT, 2147483647, 'I' },
{ "Talint", TYPE_INT, 2147483647, 'I' },
{ "Taluint", TYPE_UINT, 4294967295U, 'I' },
{ "Taluint", TYPE_UINT, 4294967295U, 'I' },
{ "Tallong", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tallong", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Talulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Talulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Talllong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talllong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Talullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Talbool", TYPE_UINT, 1, 'B' },
{ "Talbool", TYPE_UINT, 1, 'B' },
{ "Talptr", TYPE_PTR, 0, 0 },
{ "Talptr", TYPE_PTR, 0, 0 },
{ "Talcptr", TYPE_PTR, 0, 0 },
{ "Talcptr", TYPE_PTR, 0, 0 },
{ "Taliptr", TYPE_PTR, 0, 0 },
{ "Taliptr", TYPE_PTR, 0, 0 },
{ "Talfloat", TYPE_FLOAT, 0, 0 },
{ "Talfloat", TYPE_FLOAT, 0, 0 },
{ "Taldouble", TYPE_FLOAT, 0, 0 },
{ "Taldouble", TYPE_FLOAT, 0, 0 },
{ "Talldouble", TYPE_FLOAT, 0, 0 },
{ "Talldouble", TYPE_FLOAT, 0, 0 },
{ "TalE0", TYPE_UENUM, 0, ' ' },
{ "TalE0", TYPE_UENUM, 0, ' ' },
{ "TalE1", TYPE_UENUM, 1, ' ' },
{ "TalE1", TYPE_UENUM, 1, ' ' },
{ "TalE2", TYPE_SENUM, 3, ' ' },
{ "TalE2", TYPE_SENUM, 3, ' ' },
{ "TalE3", TYPE_SENUM, 127, ' ' },
{ "TalE3", TYPE_SENUM, 127, ' ' },
{ "TalE4", TYPE_UENUM, 255, ' ' },
{ "TalE4", TYPE_UENUM, 255, ' ' },
{ "TalE5", TYPE_SENUM, 32767, ' ' },
{ "TalE5", TYPE_SENUM, 32767, ' ' },
{ "TalE6", TYPE_UENUM, 65535, ' ' },
{ "TalE6", TYPE_UENUM, 65535, ' ' },
{ "TalE7", TYPE_SENUM, 2147483647, ' ' },
{ "TalE7", TYPE_SENUM, 2147483647, ' ' },
{ "TalE8", TYPE_UENUM, 4294967295U, ' ' },
{ "TalE8", TYPE_UENUM, 4294967295U, ' ' },
{ "TalE9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "TalE9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Tal1char", TYPE_UINT, 127, 'C' },
{ "Tal1char", TYPE_UINT, 127, 'C' },
{ "Tal1schar", TYPE_INT, 127, 'C' },
{ "Tal1schar", TYPE_INT, 127, 'C' },
{ "Tal1uchar", TYPE_UINT, 255, 'C' },
{ "Tal1uchar", TYPE_UINT, 255, 'C' },
{ "Tal1short", TYPE_INT, 32767, 'S' },
{ "Tal1short", TYPE_INT, 32767, 'S' },
{ "Tal1ushort", TYPE_UINT, 65535, 'S' },
{ "Tal1ushort", TYPE_UINT, 65535, 'S' },
{ "Tal1int", TYPE_INT, 2147483647, 'I' },
{ "Tal1int", TYPE_INT, 2147483647, 'I' },
{ "Tal1uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal1uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal1long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal1long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal1ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal1ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal1llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal1llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal1ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal1ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal1bool", TYPE_UINT, 1, 'B' },
{ "Tal1bool", TYPE_UINT, 1, 'B' },
{ "Tal1ptr", TYPE_PTR, 0, 0 },
{ "Tal1ptr", TYPE_PTR, 0, 0 },
{ "Tal1cptr", TYPE_PTR, 0, 0 },
{ "Tal1cptr", TYPE_PTR, 0, 0 },
{ "Tal1iptr", TYPE_PTR, 0, 0 },
{ "Tal1iptr", TYPE_PTR, 0, 0 },
{ "Tal1float", TYPE_FLOAT, 0, 0 },
{ "Tal1float", TYPE_FLOAT, 0, 0 },
{ "Tal1double", TYPE_FLOAT, 0, 0 },
{ "Tal1double", TYPE_FLOAT, 0, 0 },
{ "Tal1ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal1ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal1E0", TYPE_UENUM, 0, ' ' },
{ "Tal1E0", TYPE_UENUM, 0, ' ' },
{ "Tal1E1", TYPE_UENUM, 1, ' ' },
{ "Tal1E1", TYPE_UENUM, 1, ' ' },
{ "Tal1E2", TYPE_SENUM, 3, ' ' },
{ "Tal1E2", TYPE_SENUM, 3, ' ' },
{ "Tal1E3", TYPE_SENUM, 127, ' ' },
{ "Tal1E3", TYPE_SENUM, 127, ' ' },
{ "Tal1E4", TYPE_UENUM, 255, ' ' },
{ "Tal1E4", TYPE_UENUM, 255, ' ' },
{ "Tal1E5", TYPE_SENUM, 32767, ' ' },
{ "Tal1E5", TYPE_SENUM, 32767, ' ' },
{ "Tal1E6", TYPE_UENUM, 65535, ' ' },
{ "Tal1E6", TYPE_UENUM, 65535, ' ' },
{ "Tal1E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal1E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal1E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal1E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal1E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Tal1E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Tal2char", TYPE_UINT, 127, 'C' },
{ "Tal2char", TYPE_UINT, 127, 'C' },
{ "Tal2schar", TYPE_INT, 127, 'C' },
{ "Tal2schar", TYPE_INT, 127, 'C' },
{ "Tal2uchar", TYPE_UINT, 255, 'C' },
{ "Tal2uchar", TYPE_UINT, 255, 'C' },
{ "Tal2short", TYPE_INT, 32767, 'S' },
{ "Tal2short", TYPE_INT, 32767, 'S' },
{ "Tal2ushort", TYPE_UINT, 65535, 'S' },
{ "Tal2ushort", TYPE_UINT, 65535, 'S' },
{ "Tal2int", TYPE_INT, 2147483647, 'I' },
{ "Tal2int", TYPE_INT, 2147483647, 'I' },
{ "Tal2uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal2uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal2long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal2long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal2ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal2ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal2llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal2llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal2ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal2ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal2bool", TYPE_UINT, 1, 'B' },
{ "Tal2bool", TYPE_UINT, 1, 'B' },
{ "Tal2ptr", TYPE_PTR, 0, 0 },
{ "Tal2ptr", TYPE_PTR, 0, 0 },
{ "Tal2cptr", TYPE_PTR, 0, 0 },
{ "Tal2cptr", TYPE_PTR, 0, 0 },
{ "Tal2iptr", TYPE_PTR, 0, 0 },
{ "Tal2iptr", TYPE_PTR, 0, 0 },
{ "Tal2float", TYPE_FLOAT, 0, 0 },
{ "Tal2float", TYPE_FLOAT, 0, 0 },
{ "Tal2double", TYPE_FLOAT, 0, 0 },
{ "Tal2double", TYPE_FLOAT, 0, 0 },
{ "Tal2ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal2ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal2E0", TYPE_UENUM, 0, ' ' },
{ "Tal2E0", TYPE_UENUM, 0, ' ' },
{ "Tal2E1", TYPE_UENUM, 1, ' ' },
{ "Tal2E1", TYPE_UENUM, 1, ' ' },
{ "Tal2E2", TYPE_SENUM, 3, ' ' },
{ "Tal2E2", TYPE_SENUM, 3, ' ' },
{ "Tal2E3", TYPE_SENUM, 127, ' ' },
{ "Tal2E3", TYPE_SENUM, 127, ' ' },
{ "Tal2E4", TYPE_UENUM, 255, ' ' },
{ "Tal2E4", TYPE_UENUM, 255, ' ' },
{ "Tal2E5", TYPE_SENUM, 32767, ' ' },
{ "Tal2E5", TYPE_SENUM, 32767, ' ' },
{ "Tal2E6", TYPE_UENUM, 65535, ' ' },
{ "Tal2E6", TYPE_UENUM, 65535, ' ' },
{ "Tal2E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal2E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal2E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal2E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal2E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Tal2E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Tal4char", TYPE_UINT, 127, 'C' },
{ "Tal4char", TYPE_UINT, 127, 'C' },
{ "Tal4schar", TYPE_INT, 127, 'C' },
{ "Tal4schar", TYPE_INT, 127, 'C' },
{ "Tal4uchar", TYPE_UINT, 255, 'C' },
{ "Tal4uchar", TYPE_UINT, 255, 'C' },
{ "Tal4short", TYPE_INT, 32767, 'S' },
{ "Tal4short", TYPE_INT, 32767, 'S' },
{ "Tal4ushort", TYPE_UINT, 65535, 'S' },
{ "Tal4ushort", TYPE_UINT, 65535, 'S' },
{ "Tal4int", TYPE_INT, 2147483647, 'I' },
{ "Tal4int", TYPE_INT, 2147483647, 'I' },
{ "Tal4uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal4uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal4long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal4long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal4ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal4ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal4llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal4llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal4ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal4ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal4bool", TYPE_UINT, 1, 'B' },
{ "Tal4bool", TYPE_UINT, 1, 'B' },
{ "Tal4ptr", TYPE_PTR, 0, 0 },
{ "Tal4ptr", TYPE_PTR, 0, 0 },
{ "Tal4cptr", TYPE_PTR, 0, 0 },
{ "Tal4cptr", TYPE_PTR, 0, 0 },
{ "Tal4iptr", TYPE_PTR, 0, 0 },
{ "Tal4iptr", TYPE_PTR, 0, 0 },
{ "Tal4float", TYPE_FLOAT, 0, 0 },
{ "Tal4float", TYPE_FLOAT, 0, 0 },
{ "Tal4double", TYPE_FLOAT, 0, 0 },
{ "Tal4double", TYPE_FLOAT, 0, 0 },
{ "Tal4ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal4ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal4E0", TYPE_UENUM, 0, ' ' },
{ "Tal4E0", TYPE_UENUM, 0, ' ' },
{ "Tal4E1", TYPE_UENUM, 1, ' ' },
{ "Tal4E1", TYPE_UENUM, 1, ' ' },
{ "Tal4E2", TYPE_SENUM, 3, ' ' },
{ "Tal4E2", TYPE_SENUM, 3, ' ' },
{ "Tal4E3", TYPE_SENUM, 127, ' ' },
{ "Tal4E3", TYPE_SENUM, 127, ' ' },
{ "Tal4E4", TYPE_UENUM, 255, ' ' },
{ "Tal4E4", TYPE_UENUM, 255, ' ' },
{ "Tal4E5", TYPE_SENUM, 32767, ' ' },
{ "Tal4E5", TYPE_SENUM, 32767, ' ' },
{ "Tal4E6", TYPE_UENUM, 65535, ' ' },
{ "Tal4E6", TYPE_UENUM, 65535, ' ' },
{ "Tal4E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal4E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal4E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal4E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal4E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Tal4E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Tal8char", TYPE_UINT, 127, 'C' },
{ "Tal8char", TYPE_UINT, 127, 'C' },
{ "Tal8schar", TYPE_INT, 127, 'C' },
{ "Tal8schar", TYPE_INT, 127, 'C' },
{ "Tal8uchar", TYPE_UINT, 255, 'C' },
{ "Tal8uchar", TYPE_UINT, 255, 'C' },
{ "Tal8short", TYPE_INT, 32767, 'S' },
{ "Tal8short", TYPE_INT, 32767, 'S' },
{ "Tal8ushort", TYPE_UINT, 65535, 'S' },
{ "Tal8ushort", TYPE_UINT, 65535, 'S' },
{ "Tal8int", TYPE_INT, 2147483647, 'I' },
{ "Tal8int", TYPE_INT, 2147483647, 'I' },
{ "Tal8uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal8uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal8long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal8long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal8ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal8ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal8llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal8llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal8ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal8ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal8bool", TYPE_UINT, 1, 'B' },
{ "Tal8bool", TYPE_UINT, 1, 'B' },
{ "Tal8ptr", TYPE_PTR, 0, 0 },
{ "Tal8ptr", TYPE_PTR, 0, 0 },
{ "Tal8cptr", TYPE_PTR, 0, 0 },
{ "Tal8cptr", TYPE_PTR, 0, 0 },
{ "Tal8iptr", TYPE_PTR, 0, 0 },
{ "Tal8iptr", TYPE_PTR, 0, 0 },
{ "Tal8float", TYPE_FLOAT, 0, 0 },
{ "Tal8float", TYPE_FLOAT, 0, 0 },
{ "Tal8double", TYPE_FLOAT, 0, 0 },
{ "Tal8double", TYPE_FLOAT, 0, 0 },
{ "Tal8ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal8ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal8E0", TYPE_UENUM, 0, ' ' },
{ "Tal8E0", TYPE_UENUM, 0, ' ' },
{ "Tal8E1", TYPE_UENUM, 1, ' ' },
{ "Tal8E1", TYPE_UENUM, 1, ' ' },
{ "Tal8E2", TYPE_SENUM, 3, ' ' },
{ "Tal8E2", TYPE_SENUM, 3, ' ' },
{ "Tal8E3", TYPE_SENUM, 127, ' ' },
{ "Tal8E3", TYPE_SENUM, 127, ' ' },
{ "Tal8E4", TYPE_UENUM, 255, ' ' },
{ "Tal8E4", TYPE_UENUM, 255, ' ' },
{ "Tal8E5", TYPE_SENUM, 32767, ' ' },
{ "Tal8E5", TYPE_SENUM, 32767, ' ' },
{ "Tal8E6", TYPE_UENUM, 65535, ' ' },
{ "Tal8E6", TYPE_UENUM, 65535, ' ' },
{ "Tal8E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal8E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal8E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal8E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal8E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Tal8E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Tal16char", TYPE_UINT, 127, 'C' },
{ "Tal16char", TYPE_UINT, 127, 'C' },
{ "Tal16schar", TYPE_INT, 127, 'C' },
{ "Tal16schar", TYPE_INT, 127, 'C' },
{ "Tal16uchar", TYPE_UINT, 255, 'C' },
{ "Tal16uchar", TYPE_UINT, 255, 'C' },
{ "Tal16short", TYPE_INT, 32767, 'S' },
{ "Tal16short", TYPE_INT, 32767, 'S' },
{ "Tal16ushort", TYPE_UINT, 65535, 'S' },
{ "Tal16ushort", TYPE_UINT, 65535, 'S' },
{ "Tal16int", TYPE_INT, 2147483647, 'I' },
{ "Tal16int", TYPE_INT, 2147483647, 'I' },
{ "Tal16uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal16uint", TYPE_UINT, 4294967295U, 'I' },
{ "Tal16long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal16long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Tal16ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal16ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Tal16llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal16llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Tal16ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal16ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Tal16bool", TYPE_UINT, 1, 'B' },
{ "Tal16bool", TYPE_UINT, 1, 'B' },
{ "Tal16ptr", TYPE_PTR, 0, 0 },
{ "Tal16ptr", TYPE_PTR, 0, 0 },
{ "Tal16cptr", TYPE_PTR, 0, 0 },
{ "Tal16cptr", TYPE_PTR, 0, 0 },
{ "Tal16iptr", TYPE_PTR, 0, 0 },
{ "Tal16iptr", TYPE_PTR, 0, 0 },
{ "Tal16float", TYPE_FLOAT, 0, 0 },
{ "Tal16float", TYPE_FLOAT, 0, 0 },
{ "Tal16double", TYPE_FLOAT, 0, 0 },
{ "Tal16double", TYPE_FLOAT, 0, 0 },
{ "Tal16ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal16ldouble", TYPE_FLOAT, 0, 0 },
{ "Tal16E0", TYPE_UENUM, 0, ' ' },
{ "Tal16E0", TYPE_UENUM, 0, ' ' },
{ "Tal16E1", TYPE_UENUM, 1, ' ' },
{ "Tal16E1", TYPE_UENUM, 1, ' ' },
{ "Tal16E2", TYPE_SENUM, 3, ' ' },
{ "Tal16E2", TYPE_SENUM, 3, ' ' },
{ "Tal16E3", TYPE_SENUM, 127, ' ' },
{ "Tal16E3", TYPE_SENUM, 127, ' ' },
{ "Tal16E4", TYPE_UENUM, 255, ' ' },
{ "Tal16E4", TYPE_UENUM, 255, ' ' },
{ "Tal16E5", TYPE_SENUM, 32767, ' ' },
{ "Tal16E5", TYPE_SENUM, 32767, ' ' },
{ "Tal16E6", TYPE_UENUM, 65535, ' ' },
{ "Tal16E6", TYPE_UENUM, 65535, ' ' },
{ "Tal16E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal16E7", TYPE_SENUM, 2147483647, ' ' },
{ "Tal16E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal16E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Tal16E9", TYPE_SENUM, 1099511627775LL, ' ' }
{ "Tal16E9", TYPE_SENUM, 1099511627775LL, ' ' }
#define NATYPES2 (sizeof (attrib_types) / sizeof (attrib_types[0]))
#define NATYPES2 (sizeof (attrib_types) / sizeof (attrib_types[0]))
};
};
 
 
struct types bitfld_types[NTYPES2];
struct types bitfld_types[NTYPES2];
int n_bitfld_types;
int n_bitfld_types;
struct types aligned_bitfld_types[NATYPES2];
struct types aligned_bitfld_types[NATYPES2];
int n_aligned_bitfld_types;
int n_aligned_bitfld_types;
 
 
const char *attributes[] = {
const char *attributes[] = {
"atal",
"atal",
"atpa",
"atpa",
"atal1",
"atal1",
"atal2",
"atal2",
"atal4",
"atal4",
"atal8",
"atal8",
"atal16",
"atal16",
#define NATTRIBS1 7
#define NATTRIBS1 7
"atalpa",
"atalpa",
"atpaal",
"atpaal",
"atal1pa",
"atal1pa",
"atal2pa",
"atal2pa",
"atal4pa",
"atal4pa",
"atal8pa",
"atal8pa",
"atal16pa",
"atal16pa",
"atpaal1",
"atpaal1",
"atpaal2",
"atpaal2",
"atpaal4",
"atpaal4",
"atpaal8",
"atpaal8",
"atpaal16"
"atpaal16"
#define NATTRIBS2 (sizeof (attributes) / sizeof (attributes[0]))
#define NATTRIBS2 (sizeof (attributes) / sizeof (attributes[0]))
};
};
 
 
enum ETYPE
enum ETYPE
{
{
  ETYPE_TYPE,
  ETYPE_TYPE,
  ETYPE_ARRAY,
  ETYPE_ARRAY,
  ETYPE_BITFLD,
  ETYPE_BITFLD,
  ETYPE_STRUCT,
  ETYPE_STRUCT,
  ETYPE_UNION,
  ETYPE_UNION,
  ETYPE_STRUCT_ARRAY,
  ETYPE_STRUCT_ARRAY,
  ETYPE_UNION_ARRAY
  ETYPE_UNION_ARRAY
};
};
 
 
struct entry
struct entry
{
{
#ifdef __GNUC__
#ifdef __GNUC__
  enum ETYPE etype : 8;
  enum ETYPE etype : 8;
#else
#else
  unsigned char etype;
  unsigned char etype;
#endif
#endif
  unsigned short len;
  unsigned short len;
  unsigned char arr_len;
  unsigned char arr_len;
  struct types *type;
  struct types *type;
  const char *attrib;
  const char *attrib;
  /* Used to chain together entries in the hash table.  */
  /* Used to chain together entries in the hash table.  */
  struct entry *next;
  struct entry *next;
};
};
struct types attrib_array_types[] = {
struct types attrib_array_types[] = {
{ "Talx1char", TYPE_UINT, 127, 'C' },
{ "Talx1char", TYPE_UINT, 127, 'C' },
{ "Talx1schar", TYPE_INT, 127, 'C' },
{ "Talx1schar", TYPE_INT, 127, 'C' },
{ "Talx1uchar", TYPE_UINT, 255, 'C' },
{ "Talx1uchar", TYPE_UINT, 255, 'C' },
{ "Talx1short", TYPE_INT, 32767, 'S' },
{ "Talx1short", TYPE_INT, 32767, 'S' },
{ "Talx1ushort", TYPE_UINT, 65535, 'S' },
{ "Talx1ushort", TYPE_UINT, 65535, 'S' },
{ "Talx1int", TYPE_INT, 2147483647, 'I' },
{ "Talx1int", TYPE_INT, 2147483647, 'I' },
{ "Talx1uint", TYPE_UINT, 4294967295U, 'I' },
{ "Talx1uint", TYPE_UINT, 4294967295U, 'I' },
{ "Talx1long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Talx1long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Talx1ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Talx1ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Talx1llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talx1llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talx1ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Talx1ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Talx1bool", TYPE_UINT, 1, 'B' },
{ "Talx1bool", TYPE_UINT, 1, 'B' },
{ "Talx1ptr", TYPE_PTR, 0, 0 },
{ "Talx1ptr", TYPE_PTR, 0, 0 },
{ "Talx1cptr", TYPE_PTR, 0, 0 },
{ "Talx1cptr", TYPE_PTR, 0, 0 },
{ "Talx1iptr", TYPE_PTR, 0, 0 },
{ "Talx1iptr", TYPE_PTR, 0, 0 },
{ "Talx1float", TYPE_FLOAT, 0, 0 },
{ "Talx1float", TYPE_FLOAT, 0, 0 },
{ "Talx1double", TYPE_FLOAT, 0, 0 },
{ "Talx1double", TYPE_FLOAT, 0, 0 },
{ "Talx1ldouble", TYPE_FLOAT, 0, 0 },
{ "Talx1ldouble", TYPE_FLOAT, 0, 0 },
{ "Talx1E0", TYPE_UENUM, 0, ' ' },
{ "Talx1E0", TYPE_UENUM, 0, ' ' },
{ "Talx1E1", TYPE_UENUM, 1, ' ' },
{ "Talx1E1", TYPE_UENUM, 1, ' ' },
{ "Talx1E2", TYPE_SENUM, 3, ' ' },
{ "Talx1E2", TYPE_SENUM, 3, ' ' },
{ "Talx1E3", TYPE_SENUM, 127, ' ' },
{ "Talx1E3", TYPE_SENUM, 127, ' ' },
{ "Talx1E4", TYPE_UENUM, 255, ' ' },
{ "Talx1E4", TYPE_UENUM, 255, ' ' },
{ "Talx1E5", TYPE_SENUM, 32767, ' ' },
{ "Talx1E5", TYPE_SENUM, 32767, ' ' },
{ "Talx1E6", TYPE_UENUM, 65535, ' ' },
{ "Talx1E6", TYPE_UENUM, 65535, ' ' },
{ "Talx1E7", TYPE_SENUM, 2147483647, ' ' },
{ "Talx1E7", TYPE_SENUM, 2147483647, ' ' },
{ "Talx1E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Talx1E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Talx1E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Talx1E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Talx2short", TYPE_INT, 32767, 'S' },
{ "Talx2short", TYPE_INT, 32767, 'S' },
{ "Talx2ushort", TYPE_UINT, 65535, 'S' },
{ "Talx2ushort", TYPE_UINT, 65535, 'S' },
{ "Talx2int", TYPE_INT, 2147483647, 'I' },
{ "Talx2int", TYPE_INT, 2147483647, 'I' },
{ "Talx2uint", TYPE_UINT, 4294967295U, 'I' },
{ "Talx2uint", TYPE_UINT, 4294967295U, 'I' },
{ "Talx2long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Talx2long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Talx2ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Talx2ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Talx2llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talx2llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talx2ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Talx2ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Talx2ptr", TYPE_PTR, 0, 0 },
{ "Talx2ptr", TYPE_PTR, 0, 0 },
{ "Talx2cptr", TYPE_PTR, 0, 0 },
{ "Talx2cptr", TYPE_PTR, 0, 0 },
{ "Talx2iptr", TYPE_PTR, 0, 0 },
{ "Talx2iptr", TYPE_PTR, 0, 0 },
{ "Talx2float", TYPE_FLOAT, 0, 0 },
{ "Talx2float", TYPE_FLOAT, 0, 0 },
{ "Talx2double", TYPE_FLOAT, 0, 0 },
{ "Talx2double", TYPE_FLOAT, 0, 0 },
{ "Talx2ldouble", TYPE_FLOAT, 0, 0 },
{ "Talx2ldouble", TYPE_FLOAT, 0, 0 },
{ "Talx2E0", TYPE_UENUM, 0, ' ' },
{ "Talx2E0", TYPE_UENUM, 0, ' ' },
{ "Talx2E1", TYPE_UENUM, 1, ' ' },
{ "Talx2E1", TYPE_UENUM, 1, ' ' },
{ "Talx2E2", TYPE_SENUM, 3, ' ' },
{ "Talx2E2", TYPE_SENUM, 3, ' ' },
{ "Talx2E3", TYPE_SENUM, 127, ' ' },
{ "Talx2E3", TYPE_SENUM, 127, ' ' },
{ "Talx2E4", TYPE_UENUM, 255, ' ' },
{ "Talx2E4", TYPE_UENUM, 255, ' ' },
{ "Talx2E5", TYPE_SENUM, 32767, ' ' },
{ "Talx2E5", TYPE_SENUM, 32767, ' ' },
{ "Talx2E6", TYPE_UENUM, 65535, ' ' },
{ "Talx2E6", TYPE_UENUM, 65535, ' ' },
{ "Talx2E7", TYPE_SENUM, 2147483647, ' ' },
{ "Talx2E7", TYPE_SENUM, 2147483647, ' ' },
{ "Talx2E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Talx2E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Talx2E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Talx2E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Talx4int", TYPE_INT, 2147483647, 'I' },
{ "Talx4int", TYPE_INT, 2147483647, 'I' },
{ "Talx4uint", TYPE_UINT, 4294967295U, 'I' },
{ "Talx4uint", TYPE_UINT, 4294967295U, 'I' },
{ "Talx4long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Talx4long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Talx4ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Talx4ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Talx4llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talx4llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talx4ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Talx4ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Talx4ptr", TYPE_PTR, 0, 0 },
{ "Talx4ptr", TYPE_PTR, 0, 0 },
{ "Talx4cptr", TYPE_PTR, 0, 0 },
{ "Talx4cptr", TYPE_PTR, 0, 0 },
{ "Talx4iptr", TYPE_PTR, 0, 0 },
{ "Talx4iptr", TYPE_PTR, 0, 0 },
{ "Talx4float", TYPE_FLOAT, 0, 0 },
{ "Talx4float", TYPE_FLOAT, 0, 0 },
{ "Talx4double", TYPE_FLOAT, 0, 0 },
{ "Talx4double", TYPE_FLOAT, 0, 0 },
{ "Talx4ldouble", TYPE_FLOAT, 0, 0 },
{ "Talx4ldouble", TYPE_FLOAT, 0, 0 },
{ "Talx4E0", TYPE_UENUM, 0, ' ' },
{ "Talx4E0", TYPE_UENUM, 0, ' ' },
{ "Talx4E1", TYPE_UENUM, 1, ' ' },
{ "Talx4E1", TYPE_UENUM, 1, ' ' },
{ "Talx4E2", TYPE_SENUM, 3, ' ' },
{ "Talx4E2", TYPE_SENUM, 3, ' ' },
{ "Talx4E3", TYPE_SENUM, 127, ' ' },
{ "Talx4E3", TYPE_SENUM, 127, ' ' },
{ "Talx4E4", TYPE_UENUM, 255, ' ' },
{ "Talx4E4", TYPE_UENUM, 255, ' ' },
{ "Talx4E5", TYPE_SENUM, 32767, ' ' },
{ "Talx4E5", TYPE_SENUM, 32767, ' ' },
{ "Talx4E6", TYPE_UENUM, 65535, ' ' },
{ "Talx4E6", TYPE_UENUM, 65535, ' ' },
{ "Talx4E7", TYPE_SENUM, 2147483647, ' ' },
{ "Talx4E7", TYPE_SENUM, 2147483647, ' ' },
{ "Talx4E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Talx4E8", TYPE_UENUM, 4294967295U, ' ' },
{ "Talx4E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Talx4E9", TYPE_SENUM, 1099511627775LL, ' ' },
{ "Taly8long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Taly8long", TYPE_INT, 9223372036854775807LL, 'L' },
{ "Taly8ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Taly8ulong", TYPE_UINT, 18446744073709551615ULL, 'L' },
{ "Talx8llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talx8llong", TYPE_INT, 9223372036854775807LL, 'Q' },
{ "Talx8ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Talx8ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' },
{ "Taly8ptr", TYPE_PTR, 0, 0 },
{ "Taly8ptr", TYPE_PTR, 0, 0 },
{ "Taly8cptr", TYPE_PTR, 0, 0 },
{ "Taly8cptr", TYPE_PTR, 0, 0 },
{ "Taly8iptr", TYPE_PTR, 0, 0 },
{ "Taly8iptr", TYPE_PTR, 0, 0 },
{ "Talx8double", TYPE_FLOAT, 0, 0 },
{ "Talx8double", TYPE_FLOAT, 0, 0 },
{ "Talx8ldouble", TYPE_FLOAT, 0, 0 }
{ "Talx8ldouble", TYPE_FLOAT, 0, 0 }
#define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0]))
#define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0]))
};
};
 
 
/* A prime number giving the number of slots in the hash table.  */
/* A prime number giving the number of slots in the hash table.  */
#define HASH_SIZE 32749
#define HASH_SIZE 32749
static struct entry *hash_table[HASH_SIZE];
static struct entry *hash_table[HASH_SIZE];
 
 
static int idx, limidx, output_one, short_enums;
static int idx, limidx, output_one, short_enums;
static const char *destdir;
static const char *destdir;
static const char *srcdir;
static const char *srcdir;
static const char *srcdir_safe;
static const char *srcdir_safe;
FILE *outfile;
FILE *outfile;
 
 
void
void
switchfiles (int fields)
switchfiles (int fields)
{
{
  static int filecnt;
  static int filecnt;
  static char *destbuf, *destptr;
  static char *destbuf, *destptr;
  int i;
  int i;
 
 
  ++filecnt;
  ++filecnt;
  if (outfile)
  if (outfile)
    fclose (outfile);
    fclose (outfile);
  if (output_one)
  if (output_one)
    {
    {
      outfile = stdout;
      outfile = stdout;
      return;
      return;
    }
    }
  if (destbuf == NULL)
  if (destbuf == NULL)
    {
    {
      size_t len = strlen (destdir);
      size_t len = strlen (destdir);
      destbuf = malloc (len + 20);
      destbuf = malloc (len + 20);
      if (!destbuf)
      if (!destbuf)
        abort ();
        abort ();
      memcpy (destbuf, destdir, len);
      memcpy (destbuf, destdir, len);
      if (!len || destbuf[len - 1] != '/')
      if (!len || destbuf[len - 1] != '/')
        destbuf[len++] = '/';
        destbuf[len++] = '/';
      destptr = destbuf + len;
      destptr = destbuf + len;
    }
    }
  sprintf (destptr, "t%03d_main.C", filecnt);
  sprintf (destptr, "t%03d_main.C", filecnt);
  outfile = fopen (destbuf, "w");
  outfile = fopen (destbuf, "w");
  if (outfile == NULL)
  if (outfile == NULL)
    {
    {
    fail:
    fail:
      fputs ("failed to create test files\n", stderr);
      fputs ("failed to create test files\n", stderr);
      exit (1);
      exit (1);
    }
    }
  for (i = 0; i < NDG_OPTIONS; i++)
  for (i = 0; i < NDG_OPTIONS; i++)
    fprintf (outfile, dg_options[i], "", srcdir_safe);
    fprintf (outfile, dg_options[i], "", srcdir_safe);
  fprintf (outfile, "\n\
  fprintf (outfile, "\n\
#include \"struct-layout-1.h\"\n\
#include \"struct-layout-1.h\"\n\
\n\
\n\
#define TX(n, type, attrs, fields, ops) extern void test##n (void);\n\
#define TX(n, type, attrs, fields, ops) extern void test##n (void);\n\
#include \"t%03d_test.h\"\n\
#include \"t%03d_test.h\"\n\
#undef TX\n\
#undef TX\n\
\n\
\n\
int main (void)\n\
int main (void)\n\
{\n\
{\n\
#define TX(n, type, attrs, fields, ops)   test##n ();\n\
#define TX(n, type, attrs, fields, ops)   test##n ();\n\
#include \"t%03d_test.h\"\n\
#include \"t%03d_test.h\"\n\
#undef TX\n\
#undef TX\n\
  if (fails)\n\
  if (fails)\n\
    {\n\
    {\n\
      fflush (stdout);\n\
      fflush (stdout);\n\
      abort ();\n\
      abort ();\n\
    }\n\
    }\n\
  exit (0);\n\
  exit (0);\n\
}\n", filecnt, filecnt);
}\n", filecnt, filecnt);
  fclose (outfile);
  fclose (outfile);
  sprintf (destptr, "t%03d_x.C", filecnt);
  sprintf (destptr, "t%03d_x.C", filecnt);
  outfile = fopen (destbuf, "w");
  outfile = fopen (destbuf, "w");
  if (outfile == NULL)
  if (outfile == NULL)
    goto fail;
    goto fail;
  for (i = 0; i < NDG_OPTIONS; i++)
  for (i = 0; i < NDG_OPTIONS; i++)
    fprintf (outfile, dg_options[i], "-w ", srcdir_safe);
    fprintf (outfile, dg_options[i], "-w ", srcdir_safe);
  fprintf (outfile, "\n\
  fprintf (outfile, "\n\
#include \"struct-layout-1_x1.h\"\n\
#include \"struct-layout-1_x1.h\"\n\
#include \"t%03d_test.h\"\n\
#include \"t%03d_test.h\"\n\
#include \"struct-layout-1_x2.h\"\n\
#include \"struct-layout-1_x2.h\"\n\
#include \"t%03d_test.h\"\n", filecnt, filecnt);
#include \"t%03d_test.h\"\n", filecnt, filecnt);
  fclose (outfile);
  fclose (outfile);
  sprintf (destptr, "t%03d_y.C", filecnt);
  sprintf (destptr, "t%03d_y.C", filecnt);
  outfile = fopen (destbuf, "w");
  outfile = fopen (destbuf, "w");
  if (outfile == NULL)
  if (outfile == NULL)
    goto fail;
    goto fail;
  for (i = 0; i < NDG_OPTIONS; i++)
  for (i = 0; i < NDG_OPTIONS; i++)
    fprintf (outfile, dg_options[i], "-w ", srcdir_safe);
    fprintf (outfile, dg_options[i], "-w ", srcdir_safe);
  fprintf (outfile, "\n\
  fprintf (outfile, "\n\
#include \"struct-layout-1_y1.h\"\n\
#include \"struct-layout-1_y1.h\"\n\
#include \"t%03d_test.h\"\n\
#include \"t%03d_test.h\"\n\
#include \"struct-layout-1_y2.h\"\n\
#include \"struct-layout-1_y2.h\"\n\
#include \"t%03d_test.h\"\n", filecnt, filecnt);
#include \"t%03d_test.h\"\n", filecnt, filecnt);
  fclose (outfile);
  fclose (outfile);
  sprintf (destptr, "t%03d_test.h", filecnt);
  sprintf (destptr, "t%03d_test.h", filecnt);
  outfile = fopen (destbuf, "w");
  outfile = fopen (destbuf, "w");
  if (outfile == NULL)
  if (outfile == NULL)
    goto fail;
    goto fail;
  if (fields <= 2)
  if (fields <= 2)
    limidx = idx + 300;
    limidx = idx + 300;
  else if (fields <= 4)
  else if (fields <= 4)
    limidx = idx + 200;
    limidx = idx + 200;
  else if (fields <= 6)
  else if (fields <= 6)
    limidx = idx + 100;
    limidx = idx + 100;
  else
  else
    limidx = idx + 50;
    limidx = idx + 50;
}
}
 
 
unsigned long long int
unsigned long long int
getrandll (void)
getrandll (void)
{
{
  unsigned long long int ret;
  unsigned long long int ret;
  ret = generate_random () & 0xffffff;
  ret = generate_random () & 0xffffff;
  ret |= (generate_random () & 0xffffffLL) << 24;
  ret |= (generate_random () & 0xffffffLL) << 24;
  ret |= ((unsigned long long int) generate_random ()) << 48;
  ret |= ((unsigned long long int) generate_random ()) << 48;
  return ret;
  return ret;
}
}
 
 
int
int
subfield (struct entry *e, char *letter)
subfield (struct entry *e, char *letter)
{
{
  int i, type;
  int i, type;
  char buf[20];
  char buf[20];
  const char *p;
  const char *p;
  switch (e[0].etype)
  switch (e[0].etype)
    {
    {
    case ETYPE_STRUCT:
    case ETYPE_STRUCT:
    case ETYPE_UNION:
    case ETYPE_UNION:
    case ETYPE_STRUCT_ARRAY:
    case ETYPE_STRUCT_ARRAY:
    case ETYPE_UNION_ARRAY:
    case ETYPE_UNION_ARRAY:
      type = e[0].attrib ? 1 + (generate_random () & 3) : 0;
      type = e[0].attrib ? 1 + (generate_random () & 3) : 0;
      if (e[0].etype == ETYPE_STRUCT || e[0].etype == ETYPE_STRUCT_ARRAY)
      if (e[0].etype == ETYPE_STRUCT || e[0].etype == ETYPE_STRUCT_ARRAY)
        p = "struct";
        p = "struct";
      else
      else
        p = "union";
        p = "union";
      if (e[0].etype == ETYPE_STRUCT_ARRAY || e[0].etype == ETYPE_UNION_ARRAY)
      if (e[0].etype == ETYPE_STRUCT_ARRAY || e[0].etype == ETYPE_UNION_ARRAY)
        {
        {
          if (e[0].arr_len == 255)
          if (e[0].arr_len == 255)
            snprintf (buf, 20, "%c[]", *letter);
            snprintf (buf, 20, "%c[]", *letter);
          else
          else
            snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len);
            snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len);
          /* If this is an array type, do not put aligned attributes on
          /* If this is an array type, do not put aligned attributes on
             elements.  Aligning elements to a value greater than their
             elements.  Aligning elements to a value greater than their
             size will result in a compiler error.  */
             size will result in a compiler error.  */
          if (type == 1
          if (type == 1
              && ((strncmp (e[0].attrib, "atal", 4) == 0)
              && ((strncmp (e[0].attrib, "atal", 4) == 0)
                   || strncmp (e[0].attrib, "atpaal", 6) == 0))
                   || strncmp (e[0].attrib, "atpaal", 6) == 0))
            type = 2;
            type = 2;
        }
        }
      else
      else
        {
        {
          buf[0] = *letter;
          buf[0] = *letter;
          buf[1] = '\0';
          buf[1] = '\0';
        }
        }
      ++*letter;
      ++*letter;
      switch (type)
      switch (type)
        {
        {
        case 0:
        case 0:
        case 3:
        case 3:
        case 4:
        case 4:
          fprintf (outfile, "%s{", p);
          fprintf (outfile, "%s{", p);
          break;
          break;
        case 1:
        case 1:
          fprintf (outfile, "%s %s{", e[0].attrib, p);
          fprintf (outfile, "%s %s{", e[0].attrib, p);
          break;
          break;
        case 2:
        case 2:
          fprintf (outfile, "%s %s{", p, e[0].attrib);
          fprintf (outfile, "%s %s{", p, e[0].attrib);
          break;
          break;
        }
        }
 
 
      for (i = 1; i <= e[0].len; )
      for (i = 1; i <= e[0].len; )
        i += subfield (e + i, letter);
        i += subfield (e + i, letter);
 
 
      switch (type)
      switch (type)
        {
        {
        case 0:
        case 0:
        case 1:
        case 1:
        case 2:
        case 2:
          fprintf (outfile, "}%s;", buf);
          fprintf (outfile, "}%s;", buf);
          break;
          break;
        case 3:
        case 3:
          fprintf (outfile, "}%s %s;", e[0].attrib, buf);
          fprintf (outfile, "}%s %s;", e[0].attrib, buf);
          break;
          break;
        case 4:
        case 4:
          fprintf (outfile, "}%s %s;", buf, e[0].attrib);
          fprintf (outfile, "}%s %s;", buf, e[0].attrib);
          break;
          break;
        }
        }
      return 1 + e[0].len;
      return 1 + e[0].len;
    case ETYPE_TYPE:
    case ETYPE_TYPE:
    case ETYPE_ARRAY:
    case ETYPE_ARRAY:
      if (e[0].etype == ETYPE_ARRAY)
      if (e[0].etype == ETYPE_ARRAY)
        {
        {
          if (e[0].arr_len == 255)
          if (e[0].arr_len == 255)
            snprintf (buf, 20, "%c[]", *letter);
            snprintf (buf, 20, "%c[]", *letter);
          else
          else
            snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len);
            snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len);
        }
        }
      else
      else
        {
        {
          buf[0] = *letter;
          buf[0] = *letter;
          buf[1] = '\0';
          buf[1] = '\0';
        }
        }
      ++*letter;
      ++*letter;
      if (e[0].attrib)
      if (e[0].attrib)
        {
        {
          /* If this is an array type, do not put aligned attributes on
          /* If this is an array type, do not put aligned attributes on
             elements.  Aligning elements to a value greater than their
             elements.  Aligning elements to a value greater than their
             size will result in a compiler error.  */
             size will result in a compiler error.  */
          if (e[0].etype == ETYPE_ARRAY
          if (e[0].etype == ETYPE_ARRAY
              && ((strncmp (e[0].attrib, "atal", 4) == 0)
              && ((strncmp (e[0].attrib, "atal", 4) == 0)
                   || strncmp (e[0].attrib, "atpaal", 6) == 0))
                   || strncmp (e[0].attrib, "atpaal", 6) == 0))
            type = 2;
            type = 2;
          else
          else
            type = generate_random () % 3;
            type = generate_random () % 3;
          switch (type)
          switch (type)
            {
            {
            case 0:
            case 0:
              fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name,
              fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name,
                       buf);
                       buf);
              break;
              break;
            case 1:
            case 1:
              fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib,
              fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib,
                       buf);
                       buf);
              break;
              break;
            case 2:
            case 2:
              fprintf (outfile, "%s %s %s;", e[0].type->name, buf,
              fprintf (outfile, "%s %s %s;", e[0].type->name, buf,
                       e[0].attrib);
                       e[0].attrib);
              break;
              break;
            }
            }
        }
        }
      else
      else
        fprintf (outfile, "%s %s;", e[0].type->name, buf);
        fprintf (outfile, "%s %s;", e[0].type->name, buf);
      return 1;
      return 1;
    case ETYPE_BITFLD:
    case ETYPE_BITFLD:
      if (e[0].len == 0)
      if (e[0].len == 0)
        {
        {
          if (e[0].attrib)
          if (e[0].attrib)
            switch (generate_random () % 3)
            switch (generate_random () % 3)
              {
              {
              case 0:
              case 0:
                fprintf (outfile, "%s %s:0;", e[0].attrib, e[0].type->name);
                fprintf (outfile, "%s %s:0;", e[0].attrib, e[0].type->name);
                break;
                break;
              case 1:
              case 1:
                fprintf (outfile, "%s %s:0;", e[0].type->name, e[0].attrib);
                fprintf (outfile, "%s %s:0;", e[0].type->name, e[0].attrib);
                break;
                break;
              case 2:
              case 2:
                fprintf (outfile, "%s:0 %s;", e[0].type->name, e[0].attrib);
                fprintf (outfile, "%s:0 %s;", e[0].type->name, e[0].attrib);
                break;
                break;
              }
              }
          else
          else
            fprintf (outfile, "%s:0;", e[0].type->name);
            fprintf (outfile, "%s:0;", e[0].type->name);
          ++*letter;
          ++*letter;
          return 1;
          return 1;
        }
        }
      snprintf (buf, 20, "%d", e[0].len);
      snprintf (buf, 20, "%d", e[0].len);
      if (e[0].attrib)
      if (e[0].attrib)
        switch (generate_random () % 3)
        switch (generate_random () % 3)
          {
          {
          case 0:
          case 0:
            fprintf (outfile, "%s %s %c:%s;", e[0].attrib, e[0].type->name,
            fprintf (outfile, "%s %s %c:%s;", e[0].attrib, e[0].type->name,
                     *letter, buf);
                     *letter, buf);
            break;
            break;
          case 1:
          case 1:
            fprintf (outfile, "%s %s %c:%s;", e[0].type->name, e[0].attrib,
            fprintf (outfile, "%s %s %c:%s;", e[0].type->name, e[0].attrib,
                     *letter, buf);
                     *letter, buf);
            break;
            break;
          case 2:
          case 2:
            fprintf (outfile, "%s %c:%s %s;", e[0].type->name, *letter,
            fprintf (outfile, "%s %c:%s %s;", e[0].type->name, *letter,
                     buf, e[0].attrib);
                     buf, e[0].attrib);
            break;
            break;
          }
          }
      else
      else
        fprintf (outfile, "%s %c:%s;", e[0].type->name, *letter, buf);
        fprintf (outfile, "%s %c:%s;", e[0].type->name, *letter, buf);
      ++*letter;
      ++*letter;
      return 1;
      return 1;
    default:
    default:
      abort ();
      abort ();
  }
  }
}
}
 
 
char namebuf[1024];
char namebuf[1024];
 
 
void
void
output_FNB (char mode, struct entry *e)
output_FNB (char mode, struct entry *e)
{
{
  unsigned long long int l1, l2, m;
  unsigned long long int l1, l2, m;
  int signs = 0;
  int signs = 0;
  const char *p, *q;
  const char *p, *q;
 
 
  if (e->type->type == TYPE_OTHER)
  if (e->type->type == TYPE_OTHER)
    {
    {
      if (mode == 'B')
      if (mode == 'B')
        abort ();
        abort ();
      fprintf (outfile, "N(%d,%s)", idx, namebuf);
      fprintf (outfile, "N(%d,%s)", idx, namebuf);
      return;
      return;
    }
    }
  fprintf (outfile, "%c(%d,%s,", mode, idx, namebuf);
  fprintf (outfile, "%c(%d,%s,", mode, idx, namebuf);
  l1 = getrandll ();
  l1 = getrandll ();
  l2 = getrandll ();
  l2 = getrandll ();
  switch (e->type->type)
  switch (e->type->type)
    {
    {
    case TYPE_INT:
    case TYPE_INT:
      signs = generate_random () & 3;
      signs = generate_random () & 3;
      m = e->type->maxval;
      m = e->type->maxval;
      if (mode == 'B')
      if (mode == 'B')
        m &= e->len > 1 ? (1ULL << (e->len - 1)) - 1 : 1;
        m &= e->len > 1 ? (1ULL << (e->len - 1)) - 1 : 1;
      l1 &= m;
      l1 &= m;
      l2 &= m;
      l2 &= m;
      fprintf (outfile, "%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s",
      fprintf (outfile, "%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s",
               (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
               (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
               (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
               (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
      break;
      break;
    case TYPE_UINT:
    case TYPE_UINT:
      m = e->type->maxval;
      m = e->type->maxval;
      if (mode == 'B')
      if (mode == 'B')
        m &= (1ULL << e->len) - 1;
        m &= (1ULL << e->len) - 1;
      l1 &= m;
      l1 &= m;
      l2 &= m;
      l2 &= m;
      fprintf (outfile,"%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s",
      fprintf (outfile,"%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s",
               l1, l1 > 4294967295U ? "LL" : "",
               l1, l1 > 4294967295U ? "LL" : "",
               l2, l2 > 4294967295U ? "LL" : "");
               l2, l2 > 4294967295U ? "LL" : "");
      break;
      break;
    case TYPE_FLOAT:
    case TYPE_FLOAT:
      l1 &= 0xffffff;
      l1 &= 0xffffff;
      l2 &= 0xffffff;
      l2 &= 0xffffff;
      signs = generate_random () & 3;
      signs = generate_random () & 3;
      fprintf (outfile, "%s%f,%s%f", (signs & 1) ? "-" : "",
      fprintf (outfile, "%s%f,%s%f", (signs & 1) ? "-" : "",
               ((double) l1) / 64, (signs & 2) ? "-" : "", ((double) l2) / 64);
               ((double) l1) / 64, (signs & 2) ? "-" : "", ((double) l2) / 64);
      break;
      break;
    case TYPE_UENUM:
    case TYPE_UENUM:
      if (e->type->maxval == 0)
      if (e->type->maxval == 0)
        fputs ("e0_0,e0_0", outfile);
        fputs ("e0_0,e0_0", outfile);
      else if (e->type->maxval == 1)
      else if (e->type->maxval == 1)
        fprintf (outfile, "e1_%" COMPAT_PRLL "d,e1_%" COMPAT_PRLL "d",
        fprintf (outfile, "e1_%" COMPAT_PRLL "d,e1_%" COMPAT_PRLL "d",
                 l1 & 1, l2 & 1);
                 l1 & 1, l2 & 1);
      else
      else
        {
        {
          p = strchr (e->type->name, '\0');
          p = strchr (e->type->name, '\0');
          while (--p >= e->type->name && *p >= '0' && *p <= '9');
          while (--p >= e->type->name && *p >= '0' && *p <= '9');
          p++;
          p++;
          l1 %= 7;
          l1 %= 7;
          l2 %= 7;
          l2 %= 7;
          if (l1 > 3)
          if (l1 > 3)
            l1 += e->type->maxval - 6;
            l1 += e->type->maxval - 6;
          if (l2 > 3)
          if (l2 > 3)
            l2 += e->type->maxval - 6;
            l2 += e->type->maxval - 6;
          fprintf (outfile, "e%s_%" COMPAT_PRLL "d,e%s_%" COMPAT_PRLL "d",
          fprintf (outfile, "e%s_%" COMPAT_PRLL "d,e%s_%" COMPAT_PRLL "d",
                   p, l1, p, l2);
                   p, l1, p, l2);
        }
        }
      break;
      break;
    case TYPE_SENUM:
    case TYPE_SENUM:
      p = strchr (e->type->name, '\0');
      p = strchr (e->type->name, '\0');
      while (--p >= e->type->name && *p >= '0' && *p <= '9');
      while (--p >= e->type->name && *p >= '0' && *p <= '9');
      p++;
      p++;
      l1 %= 7;
      l1 %= 7;
      l2 %= 7;
      l2 %= 7;
      fprintf (outfile, "e%s_%s%" COMPAT_PRLL "d,e%s_%s%" COMPAT_PRLL "d",
      fprintf (outfile, "e%s_%s%" COMPAT_PRLL "d,e%s_%s%" COMPAT_PRLL "d",
               p, l1 < 3 ? "m" : "",
               p, l1 < 3 ? "m" : "",
               l1 == 3 ? 0LL : e->type->maxval - (l1 & 3),
               l1 == 3 ? 0LL : e->type->maxval - (l1 & 3),
               p, l2 < 3 ? "m" : "",
               p, l2 < 3 ? "m" : "",
               l2 == 3 ? 0LL : e->type->maxval - (l2 & 3));
               l2 == 3 ? 0LL : e->type->maxval - (l2 & 3));
      break;
      break;
    case TYPE_PTR:
    case TYPE_PTR:
      l1 %= 256;
      l1 %= 256;
      l2 %= 256;
      l2 %= 256;
      fprintf (outfile,
      fprintf (outfile,
              "(%s)&intarray[%" COMPAT_PRLL "d], (%s)&intarray[%" COMPAT_PRLL "d]",
              "(%s)&intarray[%" COMPAT_PRLL "d], (%s)&intarray[%" COMPAT_PRLL "d]",
               e->type->name, l1, e->type->name, l2);
               e->type->name, l1, e->type->name, l2);
      break;
      break;
    case TYPE_FNPTR:
    case TYPE_FNPTR:
      l1 %= 10;
      l1 %= 10;
      l2 %= 10;
      l2 %= 10;
      fprintf (outfile,
      fprintf (outfile,
               "fn%" COMPAT_PRLL "d,fn%" COMPAT_PRLL "d", l1, l2);
               "fn%" COMPAT_PRLL "d,fn%" COMPAT_PRLL "d", l1, l2);
      break;
      break;
    default:
    default:
      abort ();
      abort ();
    }
    }
  fputs (")", outfile);
  fputs (")", outfile);
}
}
 
 
int
int
subvalues (struct entry *e, char *p, char *letter)
subvalues (struct entry *e, char *p, char *letter)
{
{
  int i, j;
  int i, j;
  char *q;
  char *q;
  if (p >= namebuf + sizeof (namebuf) - 32)
  if (p >= namebuf + sizeof (namebuf) - 32)
    abort ();
    abort ();
  p[0] = *letter;
  p[0] = *letter;
  p[1] = '\0';
  p[1] = '\0';
  q = p + 1;
  q = p + 1;
  switch (e[0].etype)
  switch (e[0].etype)
    {
    {
    case ETYPE_STRUCT_ARRAY:
    case ETYPE_STRUCT_ARRAY:
    case ETYPE_UNION_ARRAY:
    case ETYPE_UNION_ARRAY:
      if (e[0].arr_len == 0 || e[0].arr_len == 255)
      if (e[0].arr_len == 0 || e[0].arr_len == 255)
        {
        {
          *letter += 1 + e[0].len;
          *letter += 1 + e[0].len;
          return 1 + e[0].len;
          return 1 + e[0].len;
        }
        }
      i = generate_random () % e[0].arr_len;
      i = generate_random () % e[0].arr_len;
      snprintf (p, sizeof (namebuf) - (p - namebuf) - 1,
      snprintf (p, sizeof (namebuf) - (p - namebuf) - 1,
                "%c[%d]", *letter, i);
                "%c[%d]", *letter, i);
      q = strchr (p, '\0');
      q = strchr (p, '\0');
      /* FALLTHROUGH */
      /* FALLTHROUGH */
    case ETYPE_STRUCT:
    case ETYPE_STRUCT:
    case ETYPE_UNION:
    case ETYPE_UNION:
      *q++ = '.';
      *q++ = '.';
      ++*letter;
      ++*letter;
      for (i = 1; i <= e[0].len; )
      for (i = 1; i <= e[0].len; )
        {
        {
          i += subvalues (e + i, q, letter);
          i += subvalues (e + i, q, letter);
          if (e[0].etype == ETYPE_UNION || e[0].etype == ETYPE_UNION_ARRAY)
          if (e[0].etype == ETYPE_UNION || e[0].etype == ETYPE_UNION_ARRAY)
            {
            {
              *letter += e[0].len - i + 1;
              *letter += e[0].len - i + 1;
              break;
              break;
            }
            }
        }
        }
      return 1 + e[0].len;
      return 1 + e[0].len;
    case ETYPE_TYPE:
    case ETYPE_TYPE:
      ++*letter;
      ++*letter;
      output_FNB ('F', e);
      output_FNB ('F', e);
      return 1;
      return 1;
    case ETYPE_ARRAY:
    case ETYPE_ARRAY:
      if (e[0].arr_len == 0 || e[0].arr_len == 255)
      if (e[0].arr_len == 0 || e[0].arr_len == 255)
        {
        {
          ++*letter;
          ++*letter;
          return 1;
          return 1;
        }
        }
      i = generate_random () % e[0].arr_len;
      i = generate_random () % e[0].arr_len;
      snprintf (p, sizeof (namebuf) - (p - namebuf),
      snprintf (p, sizeof (namebuf) - (p - namebuf),
                "%c[%d]", *letter, i);
                "%c[%d]", *letter, i);
      output_FNB ('F', e);
      output_FNB ('F', e);
      if ((generate_random () & 7) == 0)
      if ((generate_random () & 7) == 0)
        {
        {
          j = generate_random () % e[0].arr_len;
          j = generate_random () % e[0].arr_len;
          if (i != j)
          if (i != j)
            {
            {
              snprintf (p, sizeof (namebuf) - (p - namebuf),
              snprintf (p, sizeof (namebuf) - (p - namebuf),
                        "%c[%d]", *letter, j);
                        "%c[%d]", *letter, j);
              output_FNB ('F', e);
              output_FNB ('F', e);
            }
            }
        }
        }
      ++*letter;
      ++*letter;
      return 1;
      return 1;
    case ETYPE_BITFLD:
    case ETYPE_BITFLD:
      ++*letter;
      ++*letter;
      if (e[0].len != 0)
      if (e[0].len != 0)
        output_FNB ('B', e);
        output_FNB ('B', e);
      return 1;
      return 1;
    }
    }
}
}
 
 
/* DERIVED FROM:
/* DERIVED FROM:
--------------------------------------------------------------------
--------------------------------------------------------------------
lookup2.c, by Bob Jenkins, December 1996, Public Domain.
lookup2.c, by Bob Jenkins, December 1996, Public Domain.
hash(), hash2(), hash3, and mix() are externally useful functions.
hash(), hash2(), hash3, and mix() are externally useful functions.
Routines to test the hash are included if SELF_TEST is defined.
Routines to test the hash are included if SELF_TEST is defined.
You can use this free for any purpose.  It has no warranty.
You can use this free for any purpose.  It has no warranty.
--------------------------------------------------------------------
--------------------------------------------------------------------
*/
*/
 
 
/*
/*
--------------------------------------------------------------------
--------------------------------------------------------------------
mix -- mix 3 32-bit values reversibly.
mix -- mix 3 32-bit values reversibly.
For every delta with one or two bit set, and the deltas of all three
For every delta with one or two bit set, and the deltas of all three
  high bits or all three low bits, whether the original value of a,b,c
  high bits or all three low bits, whether the original value of a,b,c
  is almost all zero or is uniformly distributed,
  is almost all zero or is uniformly distributed,
* If mix() is run forward or backward, at least 32 bits in a,b,c
* If mix() is run forward or backward, at least 32 bits in a,b,c
  have at least 1/4 probability of changing.
  have at least 1/4 probability of changing.
* If mix() is run forward, every bit of c will change between 1/3 and
* If mix() is run forward, every bit of c will change between 1/3 and
  2/3 of the time.  (Well, 22/100 and 78/100 for some 2-bit deltas.)
  2/3 of the time.  (Well, 22/100 and 78/100 for some 2-bit deltas.)
mix() was built out of 36 single-cycle latency instructions in a
mix() was built out of 36 single-cycle latency instructions in a
  structure that could supported 2x parallelism, like so:
  structure that could supported 2x parallelism, like so:
      a -= b;
      a -= b;
      a -= c; x = (c>>13);
      a -= c; x = (c>>13);
      b -= c; a ^= x;
      b -= c; a ^= x;
      b -= a; x = (a<<8);
      b -= a; x = (a<<8);
      c -= a; b ^= x;
      c -= a; b ^= x;
      c -= b; x = (b>>13);
      c -= b; x = (b>>13);
      ...
      ...
  Unfortunately, superscalar Pentiums and Sparcs can't take advantage
  Unfortunately, superscalar Pentiums and Sparcs can't take advantage
  of that parallelism.  They've also turned some of those single-cycle
  of that parallelism.  They've also turned some of those single-cycle
  latency instructions into multi-cycle latency instructions.  Still,
  latency instructions into multi-cycle latency instructions.  Still,
  this is the fastest good hash I could find.  There were about 2^^68
  this is the fastest good hash I could find.  There were about 2^^68
  to choose from.  I only looked at a billion or so.
  to choose from.  I only looked at a billion or so.
--------------------------------------------------------------------
--------------------------------------------------------------------
*/
*/
/* same, but slower, works on systems that might have 8 byte hashval_t's */
/* same, but slower, works on systems that might have 8 byte hashval_t's */
#define mix(a,b,c) \
#define mix(a,b,c) \
{ \
{ \
  a -= b; a -= c; a ^= (c>>13); \
  a -= b; a -= c; a ^= (c>>13); \
  b -= c; b -= a; b ^= (a<< 8); \
  b -= c; b -= a; b ^= (a<< 8); \
  c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \
  c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \
  a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \
  a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \
  b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \
  b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \
  c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \
  c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \
  a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \
  a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \
  b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \
  b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \
  c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \
  c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \
}
}
 
 
/*
/*
--------------------------------------------------------------------
--------------------------------------------------------------------
hash() -- hash a variable-length key into a 32-bit value
hash() -- hash a variable-length key into a 32-bit value
  k     : the key (the unaligned variable-length array of bytes)
  k     : the key (the unaligned variable-length array of bytes)
  len   : the length of the key, counting by bytes
  len   : the length of the key, counting by bytes
  level : can be any 4-byte value
  level : can be any 4-byte value
Returns a 32-bit value.  Every bit of the key affects every bit of
Returns a 32-bit value.  Every bit of the key affects every bit of
the return value.  Every 1-bit and 2-bit delta achieves avalanche.
the return value.  Every 1-bit and 2-bit delta achieves avalanche.
About 36+6len instructions.
About 36+6len instructions.
 
 
The best hash table sizes are powers of 2.  There is no need to do
The best hash table sizes are powers of 2.  There is no need to do
mod a prime (mod is sooo slow!).  If you need less than 32 bits,
mod a prime (mod is sooo slow!).  If you need less than 32 bits,
use a bitmask.  For example, if you need only 10 bits, do
use a bitmask.  For example, if you need only 10 bits, do
  h = (h & hashmask(10));
  h = (h & hashmask(10));
In which case, the hash table should have hashsize(10) elements.
In which case, the hash table should have hashsize(10) elements.
 
 
If you are hashing n strings (ub1 **)k, do it like this:
If you are hashing n strings (ub1 **)k, do it like this:
  for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
  for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
 
 
By Bob Jenkins, 1996.  bob_jenkins@burtleburtle.net.  You may use this
By Bob Jenkins, 1996.  bob_jenkins@burtleburtle.net.  You may use this
code any way you wish, private, educational, or commercial.  It's free.
code any way you wish, private, educational, or commercial.  It's free.
 
 
See http://burtleburtle.net/bob/hash/evahash.html
See http://burtleburtle.net/bob/hash/evahash.html
Use for hash table lookup, or anything where one collision in 2^32 is
Use for hash table lookup, or anything where one collision in 2^32 is
acceptable.  Do NOT use for cryptographic purposes.
acceptable.  Do NOT use for cryptographic purposes.
--------------------------------------------------------------------
--------------------------------------------------------------------
*/
*/
 
 
static hashval_t
static hashval_t
iterative_hash (const void *k_in /* the key */,
iterative_hash (const void *k_in /* the key */,
                register size_t  length /* the length of the key */,
                register size_t  length /* the length of the key */,
                register hashval_t initval /* the previous hash, or
                register hashval_t initval /* the previous hash, or
                                              an arbitrary value */)
                                              an arbitrary value */)
{
{
  register const unsigned char *k = (const unsigned char *)k_in;
  register const unsigned char *k = (const unsigned char *)k_in;
  register hashval_t a,b,c,len;
  register hashval_t a,b,c,len;
 
 
  /* Set up the internal state */
  /* Set up the internal state */
  len = length;
  len = length;
  a = b = 0x9e3779b9;  /* the golden ratio; an arbitrary value */
  a = b = 0x9e3779b9;  /* the golden ratio; an arbitrary value */
  c = initval;     /* the previous hash value */
  c = initval;     /* the previous hash value */
 
 
  /*---------------------------------------- handle most of the key */
  /*---------------------------------------- handle most of the key */
    while (len >= 12)
    while (len >= 12)
      {
      {
        a += (k[0] +((hashval_t)k[1]<<8) +((hashval_t)k[2]<<16) +((hashval_t)k[3]<<24));
        a += (k[0] +((hashval_t)k[1]<<8) +((hashval_t)k[2]<<16) +((hashval_t)k[3]<<24));
        b += (k[4] +((hashval_t)k[5]<<8) +((hashval_t)k[6]<<16) +((hashval_t)k[7]<<24));
        b += (k[4] +((hashval_t)k[5]<<8) +((hashval_t)k[6]<<16) +((hashval_t)k[7]<<24));
        c += (k[8] +((hashval_t)k[9]<<8) +((hashval_t)k[10]<<16)+((hashval_t)k[11]<<24));
        c += (k[8] +((hashval_t)k[9]<<8) +((hashval_t)k[10]<<16)+((hashval_t)k[11]<<24));
        mix(a,b,c);
        mix(a,b,c);
        k += 12; len -= 12;
        k += 12; len -= 12;
      }
      }
 
 
  /*------------------------------------- handle the last 11 bytes */
  /*------------------------------------- handle the last 11 bytes */
  c += length;
  c += length;
  switch(len)         /* all the case statements fall through */
  switch(len)         /* all the case statements fall through */
    {
    {
    case 11: c+=((hashval_t)k[10]<<24);
    case 11: c+=((hashval_t)k[10]<<24);
    case 10: c+=((hashval_t)k[9]<<16);
    case 10: c+=((hashval_t)k[9]<<16);
    case 9 : c+=((hashval_t)k[8]<<8);
    case 9 : c+=((hashval_t)k[8]<<8);
      /* the first byte of c is reserved for the length */
      /* the first byte of c is reserved for the length */
    case 8 : b+=((hashval_t)k[7]<<24);
    case 8 : b+=((hashval_t)k[7]<<24);
    case 7 : b+=((hashval_t)k[6]<<16);
    case 7 : b+=((hashval_t)k[6]<<16);
    case 6 : b+=((hashval_t)k[5]<<8);
    case 6 : b+=((hashval_t)k[5]<<8);
    case 5 : b+=k[4];
    case 5 : b+=k[4];
    case 4 : a+=((hashval_t)k[3]<<24);
    case 4 : a+=((hashval_t)k[3]<<24);
    case 3 : a+=((hashval_t)k[2]<<16);
    case 3 : a+=((hashval_t)k[2]<<16);
    case 2 : a+=((hashval_t)k[1]<<8);
    case 2 : a+=((hashval_t)k[1]<<8);
    case 1 : a+=k[0];
    case 1 : a+=k[0];
      /* case 0: nothing left to add */
      /* case 0: nothing left to add */
    }
    }
  mix(a,b,c);
  mix(a,b,c);
  /*-------------------------------------------- report the result */
  /*-------------------------------------------- report the result */
  return c;
  return c;
}
}
 
 
hashval_t
hashval_t
e_hash (const void *a)
e_hash (const void *a)
{
{
  const struct entry *e = a;
  const struct entry *e = a;
  hashval_t ret = 0;
  hashval_t ret = 0;
  int i;
  int i;
 
 
  if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION)
  if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION)
    abort ();
    abort ();
  for (i = 0; i <= e[0].len; ++i)
  for (i = 0; i <= e[0].len; ++i)
    {
    {
      int attriblen;
      int attriblen;
      ret = iterative_hash (&e[i], offsetof (struct entry, attrib), ret);
      ret = iterative_hash (&e[i], offsetof (struct entry, attrib), ret);
      attriblen = e[i].attrib ? strlen (e[i].attrib) : -1;
      attriblen = e[i].attrib ? strlen (e[i].attrib) : -1;
      ret = iterative_hash (&attriblen, sizeof (int), ret);
      ret = iterative_hash (&attriblen, sizeof (int), ret);
      if (e[i].attrib)
      if (e[i].attrib)
        ret = iterative_hash (e[i].attrib, attriblen, ret);
        ret = iterative_hash (e[i].attrib, attriblen, ret);
    }
    }
  return ret;
  return ret;
}
}
 
 
int
int
e_eq (const void *a, const void *b)
e_eq (const void *a, const void *b)
{
{
  const struct entry *ea = a, *eb = b;
  const struct entry *ea = a, *eb = b;
  int i;
  int i;
  if (ea[0].etype != ETYPE_STRUCT && ea[0].etype != ETYPE_UNION)
  if (ea[0].etype != ETYPE_STRUCT && ea[0].etype != ETYPE_UNION)
    abort ();
    abort ();
  if (ea[0].len != eb[0].len)
  if (ea[0].len != eb[0].len)
    return 0;
    return 0;
  for (i = 0; i <= ea[0].len; ++i)
  for (i = 0; i <= ea[0].len; ++i)
    {
    {
      if (ea[i].etype != eb[i].etype
      if (ea[i].etype != eb[i].etype
          || ea[i].len != eb[i].len
          || ea[i].len != eb[i].len
          || ea[i].arr_len != eb[i].arr_len
          || ea[i].arr_len != eb[i].arr_len
          || ea[i].type != eb[i].type)
          || ea[i].type != eb[i].type)
        return 0;
        return 0;
      if ((ea[i].attrib == NULL) ^ (eb[i].attrib == NULL))
      if ((ea[i].attrib == NULL) ^ (eb[i].attrib == NULL))
        return 0;
        return 0;
      if (ea[i].attrib && strcmp (ea[i].attrib, eb[i].attrib) != 0)
      if (ea[i].attrib && strcmp (ea[i].attrib, eb[i].attrib) != 0)
        return 0;
        return 0;
    }
    }
  return 1;
  return 1;
}
}
 
 
static int
static int
e_exists (const struct entry *e)
e_exists (const struct entry *e)
{
{
  struct entry *h;
  struct entry *h;
  hashval_t hval;
  hashval_t hval;
 
 
  hval = e_hash (e);
  hval = e_hash (e);
  for (h = hash_table[hval % HASH_SIZE]; h; h = h->next)
  for (h = hash_table[hval % HASH_SIZE]; h; h = h->next)
    if (e_eq (e, h))
    if (e_eq (e, h))
      return 1;
      return 1;
  return 0;
  return 0;
}
}
 
 
static void
static void
e_insert (struct entry *e)
e_insert (struct entry *e)
{
{
  hashval_t hval;
  hashval_t hval;
 
 
  hval = e_hash (e);
  hval = e_hash (e);
  e->next = hash_table[hval % HASH_SIZE];
  e->next = hash_table[hval % HASH_SIZE];
  hash_table[hval % HASH_SIZE] = e;
  hash_table[hval % HASH_SIZE] = e;
}
}
 
 
void
void
output (struct entry *e)
output (struct entry *e)
{
{
  int i;
  int i;
  char c;
  char c;
  struct entry *n;
  struct entry *n;
 
 
  if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION)
  if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION)
    abort ();
    abort ();
 
 
  if (e_exists (e))
  if (e_exists (e))
    return;
    return;
 
 
  n = (struct entry *) malloc ((e[0].len + 1) * sizeof (struct entry));
  n = (struct entry *) malloc ((e[0].len + 1) * sizeof (struct entry));
  memcpy (n, e, (e[0].len + 1) * sizeof (struct entry));
  memcpy (n, e, (e[0].len + 1) * sizeof (struct entry));
  e_insert (n);
  e_insert (n);
 
 
  if (idx == limidx)
  if (idx == limidx)
    switchfiles (e[0].len);
    switchfiles (e[0].len);
 
 
  if (e[0].etype == ETYPE_STRUCT)
  if (e[0].etype == ETYPE_STRUCT)
    fprintf (outfile, "T(%d,", idx);
    fprintf (outfile, "T(%d,", idx);
  else
  else
    fprintf (outfile, "U(%d,", idx);
    fprintf (outfile, "U(%d,", idx);
  c = 'a';
  c = 'a';
  for (i = 1; i <= e[0].len; )
  for (i = 1; i <= e[0].len; )
    i += subfield (e + i, &c);
    i += subfield (e + i, &c);
  fputs (",", outfile);
  fputs (",", outfile);
  c = 'a';
  c = 'a';
  for (i = 1; i <= e[0].len; )
  for (i = 1; i <= e[0].len; )
    {
    {
      i += subvalues (e + i, namebuf, &c);
      i += subvalues (e + i, namebuf, &c);
      if (e[0].etype == ETYPE_UNION)
      if (e[0].etype == ETYPE_UNION)
        break;
        break;
    }
    }
  fputs (")\n", outfile);
  fputs (")\n", outfile);
  if (output_one && idx == limidx)
  if (output_one && idx == limidx)
    exit (0);
    exit (0);
  ++idx;
  ++idx;
}
}
 
 
enum FEATURE
enum FEATURE
{
{
  FEATURE_VECTOR = 1,
  FEATURE_VECTOR = 1,
  FEATURE_ALIGNEDPACKED = 2,
  FEATURE_ALIGNEDPACKED = 2,
  FEATURE_ZEROARRAY = 4,
  FEATURE_ZEROARRAY = 4,
  FEATURE_ZEROBITFLD = 8,
  FEATURE_ZEROBITFLD = 8,
  ALL_FEATURES = FEATURE_VECTOR | FEATURE_ZEROARRAY
  ALL_FEATURES = FEATURE_VECTOR | FEATURE_ZEROARRAY
                 | FEATURE_ALIGNEDPACKED | FEATURE_ZEROBITFLD
                 | FEATURE_ALIGNEDPACKED | FEATURE_ZEROBITFLD
};
};
 
 
void
void
singles (enum FEATURE features)
singles (enum FEATURE features)
{
{
  struct entry e[2];
  struct entry e[2];
  int i;
  int i;
  memset (e, 0, sizeof (e));
  memset (e, 0, sizeof (e));
  e[0].etype = ETYPE_STRUCT;
  e[0].etype = ETYPE_STRUCT;
  output (e);
  output (e);
  e[0].etype = ETYPE_UNION;
  e[0].etype = ETYPE_UNION;
  output (e);
  output (e);
  e[0].len = 1;
  e[0].len = 1;
  for (i = 0; i < NTYPES2; ++i)
  for (i = 0; i < NTYPES2; ++i)
    {
    {
      e[0].etype = ETYPE_STRUCT;
      e[0].etype = ETYPE_STRUCT;
      e[1].etype = ETYPE_TYPE;
      e[1].etype = ETYPE_TYPE;
      e[1].type = &base_types[i];
      e[1].type = &base_types[i];
      output (e);
      output (e);
      e[0].etype = ETYPE_UNION;
      e[0].etype = ETYPE_UNION;
      output (e);
      output (e);
    }
    }
  if (features & FEATURE_VECTOR)
  if (features & FEATURE_VECTOR)
    for (i = 0; i < NVTYPES2; ++i)
    for (i = 0; i < NVTYPES2; ++i)
      {
      {
        e[0].etype = ETYPE_STRUCT;
        e[0].etype = ETYPE_STRUCT;
        e[1].etype = ETYPE_TYPE;
        e[1].etype = ETYPE_TYPE;
        e[1].type = &vector_types[i];
        e[1].type = &vector_types[i];
        output (e);
        output (e);
        e[0].etype = ETYPE_UNION;
        e[0].etype = ETYPE_UNION;
        output (e);
        output (e);
      }
      }
}
}
 
 
void
void
choose_type (enum FEATURE features, struct entry *e, int r, int in_array)
choose_type (enum FEATURE features, struct entry *e, int r, int in_array)
{
{
  int i;
  int i;
 
 
  i = NTYPES2 - NTYPES1;
  i = NTYPES2 - NTYPES1;
  if (features & FEATURE_VECTOR)
  if (features & FEATURE_VECTOR)
    i += NVTYPES2;
    i += NVTYPES2;
  if ((r & 3) == 0)
  if ((r & 3) == 0)
    {
    {
      if (in_array)
      if (in_array)
        i += NAATYPES2;
        i += NAATYPES2;
      else
      else
        i += NATYPES2;
        i += NATYPES2;
    }
    }
  r >>= 2;
  r >>= 2;
  r %= i;
  r %= i;
  if (r < NTYPES2 - NTYPES1)
  if (r < NTYPES2 - NTYPES1)
    e->type = &base_types[r + NTYPES1];
    e->type = &base_types[r + NTYPES1];
  r -= NTYPES2 - NTYPES1;
  r -= NTYPES2 - NTYPES1;
  if (e->type == NULL && (features & FEATURE_VECTOR))
  if (e->type == NULL && (features & FEATURE_VECTOR))
    {
    {
      if (r < NVTYPES2)
      if (r < NVTYPES2)
        e->type = &vector_types[r];
        e->type = &vector_types[r];
      r -= NVTYPES2;
      r -= NVTYPES2;
    }
    }
  if (e->type == NULL && !in_array)
  if (e->type == NULL && !in_array)
    {
    {
      if (r < NATYPES2)
      if (r < NATYPES2)
        e->type = &attrib_types[r];
        e->type = &attrib_types[r];
      r -= NATYPES2;
      r -= NATYPES2;
    }
    }
  if (e->type == NULL && in_array)
  if (e->type == NULL && in_array)
    {
    {
      if (r < NAATYPES2)
      if (r < NAATYPES2)
        e->type = &attrib_array_types[r];
        e->type = &attrib_array_types[r];
      r -= NAATYPES2;
      r -= NAATYPES2;
    }
    }
  if (e->type == NULL)
  if (e->type == NULL)
    abort ();
    abort ();
}
}
 
 
/* This is from gcc.c-torture/execute/builtin-bitops-1.c.  */
/* This is from gcc.c-torture/execute/builtin-bitops-1.c.  */
static int
static int
my_ffsll (unsigned long long x)
my_ffsll (unsigned long long x)
{
{
  int i;
  int i;
  if (x == 0)
  if (x == 0)
    return 0;
    return 0;
  /* We've tested LLONG_MAX for 64 bits so this should be safe.  */
  /* We've tested LLONG_MAX for 64 bits so this should be safe.  */
  for (i = 0; i < 64; i++)
  for (i = 0; i < 64; i++)
    if (x & (1ULL << i))
    if (x & (1ULL << i))
      break;
      break;
  return i + 1;
  return i + 1;
}
}
 
 
void
void
generate_fields (enum FEATURE features, struct entry *e, struct entry *parent,
generate_fields (enum FEATURE features, struct entry *e, struct entry *parent,
                 int len)
                 int len)
{
{
  int r, i, j, ret = 1, n, incr, sametype;
  int r, i, j, ret = 1, n, incr, sametype;
 
 
  for (n = 0; n < len; n += incr)
  for (n = 0; n < len; n += incr)
    {
    {
      r = generate_random ();
      r = generate_random ();
      /* 50% ETYPE_TYPE base_types NTYPES1
      /* 50% ETYPE_TYPE base_types NTYPES1
         12.5% ETYPE_TYPE other
         12.5% ETYPE_TYPE other
         12.5% ETYPE_ARRAY
         12.5% ETYPE_ARRAY
         12.5% ETYPE_BITFLD
         12.5% ETYPE_BITFLD
         12.5% ETYPE_STRUCT|ETYPE_UNION|ETYPE_STRUCT_ARRAY|ETYPE_UNION_ARRAY */
         12.5% ETYPE_STRUCT|ETYPE_UNION|ETYPE_STRUCT_ARRAY|ETYPE_UNION_ARRAY */
      i = (r & 7);
      i = (r & 7);
      r >>= 3;
      r >>= 3;
      incr = 1;
      incr = 1;
      switch (i)
      switch (i)
        {
        {
        case 0:
        case 0:
        case 1:
        case 1:
        case 2:
        case 2:
        case 3:
        case 3:
          e[n].etype = ETYPE_TYPE;
          e[n].etype = ETYPE_TYPE;
          e[n].type = &base_types[r % NTYPES1];
          e[n].type = &base_types[r % NTYPES1];
          break;
          break;
        case 4:
        case 4:
          e[n].etype = ETYPE_TYPE;
          e[n].etype = ETYPE_TYPE;
          choose_type (features, &e[n], r, 0);
          choose_type (features, &e[n], r, 0);
          break;
          break;
        case 5:
        case 5:
          e[n].etype = ETYPE_ARRAY;
          e[n].etype = ETYPE_ARRAY;
          i = r & 1;
          i = r & 1;
          r >>= 1;
          r >>= 1;
          if (i)
          if (i)
            e[n].type = &base_types[r % NTYPES1];
            e[n].type = &base_types[r % NTYPES1];
          else
          else
            choose_type (features, &e[n], r, 1);
            choose_type (features, &e[n], r, 1);
          r = generate_random ();
          r = generate_random ();
          if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0)
          if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0)
            {
            {
              e[n].arr_len = 0;
              e[n].arr_len = 0;
              if (n == len - 1 && (r & 4)
              if (n == len - 1 && (r & 4)
                  && (parent->etype == ETYPE_STRUCT
                  && (parent->etype == ETYPE_STRUCT
                      || parent->etype == ETYPE_STRUCT_ARRAY))
                      || parent->etype == ETYPE_STRUCT_ARRAY))
                {
                {
                  int k;
                  int k;
                  for (k = 0; k < n; ++k)
                  for (k = 0; k < n; ++k)
                    if (e[k].etype != ETYPE_BITFLD || e[k].len)
                    if (e[k].etype != ETYPE_BITFLD || e[k].len)
                      {
                      {
                        e[n].arr_len = 255;
                        e[n].arr_len = 255;
                        break;
                        break;
                      }
                      }
                }
                }
            }
            }
          else if ((r & 3) != 3)
          else if ((r & 3) != 3)
            e[n].arr_len = (r >> 2) & 7;
            e[n].arr_len = (r >> 2) & 7;
          else
          else
            e[n].arr_len = (r >> 2) & 31;
            e[n].arr_len = (r >> 2) & 31;
          break;
          break;
        case 6:
        case 6:
          sametype = 1;
          sametype = 1;
          switch (r & 7)
          switch (r & 7)
            {
            {
            case 0:
            case 0:
            case 1:
            case 1:
            case 2:
            case 2:
              break;
              break;
            case 3:
            case 3:
            case 4:
            case 4:
            case 5:
            case 5:
              incr = 1 + (r >> 3) % (len - n);
              incr = 1 + (r >> 3) % (len - n);
              break;
              break;
            case 6:
            case 6:
            case 7:
            case 7:
              sametype = 0;
              sametype = 0;
              incr = 1 + (r >> 3) % (len - n);
              incr = 1 + (r >> 3) % (len - n);
              break;
              break;
            }
            }
          for (j = n; j < n + incr; ++j)
          for (j = n; j < n + incr; ++j)
            {
            {
              int mi, ma;
              int mi, ma;
 
 
              e[j].etype = ETYPE_BITFLD;
              e[j].etype = ETYPE_BITFLD;
              if (j == n || !sametype)
              if (j == n || !sametype)
                {
                {
                  int k;
                  int k;
                  r = generate_random ();
                  r = generate_random ();
                  k = r & 3;
                  k = r & 3;
                  r >>= 2;
                  r >>= 2;
                  if (!k)
                  if (!k)
                    e[j].type
                    e[j].type
                      = &aligned_bitfld_types[r % n_aligned_bitfld_types];
                      = &aligned_bitfld_types[r % n_aligned_bitfld_types];
                  else
                  else
                    e[j].type
                    e[j].type
                      = &bitfld_types[r % n_bitfld_types];
                      = &bitfld_types[r % n_bitfld_types];
                }
                }
              else
              else
                e[j].type = e[n].type;
                e[j].type = e[n].type;
              r = generate_random ();
              r = generate_random ();
              mi = 0;
              mi = 0;
              ma = 0;
              ma = 0;
              switch (e[j].type->bitfld)
              switch (e[j].type->bitfld)
                {
                {
                case 'C': ma = 8; break;
                case 'C': ma = 8; break;
                case 'S': ma = 16; break;
                case 'S': ma = 16; break;
                case 'I': ma = 32; break;
                case 'I': ma = 32; break;
                case 'L':
                case 'L':
                case 'Q': ma = 64; break;
                case 'Q': ma = 64; break;
                case 'B': ma = 1; break;
                case 'B': ma = 1; break;
                case ' ':
                case ' ':
                  if (e[j].type->type == TYPE_UENUM)
                  if (e[j].type->type == TYPE_UENUM)
                    mi = my_ffsll (e[j].type->maxval + 1) - 1;
                    mi = my_ffsll (e[j].type->maxval + 1) - 1;
                  else if (e[j].type->type == TYPE_SENUM)
                  else if (e[j].type->type == TYPE_SENUM)
                    mi = my_ffsll (e[j].type->maxval + 1);
                    mi = my_ffsll (e[j].type->maxval + 1);
                  else
                  else
                    abort ();
                    abort ();
                  if (!mi)
                  if (!mi)
                    mi = 1;
                    mi = 1;
                  if (mi > 32)
                  if (mi > 32)
                    ma = 64;
                    ma = 64;
                  else if (mi > 16 || !short_enums)
                  else if (mi > 16 || !short_enums)
                    ma = 32;
                    ma = 32;
                  else if (mi > 8)
                  else if (mi > 8)
                    ma = 16;
                    ma = 16;
                  else
                  else
                    ma = 8;
                    ma = 8;
                  break;
                  break;
                default:
                default:
                  abort ();
                  abort ();
                }
                }
              e[j].len = ma + 1;
              e[j].len = ma + 1;
              if (sametype && (r & 3) == 0 && ma > 1)
              if (sametype && (r & 3) == 0 && ma > 1)
                {
                {
                  int sum = 0, k;
                  int sum = 0, k;
                  for (k = n; k < j; ++k)
                  for (k = n; k < j; ++k)
                    sum += e[k].len;
                    sum += e[k].len;
                  sum %= ma;
                  sum %= ma;
                  e[j].len = sum ? ma - sum : ma;
                  e[j].len = sum ? ma - sum : ma;
                }
                }
              r >>= 2;
              r >>= 2;
              if (!sametype && (r & 7) == 0)
              if (!sametype && (r & 7) == 0)
                ma *= 8;
                ma *= 8;
              r >>= 3;
              r >>= 3;
              if (! (features & FEATURE_ZEROBITFLD) && mi == 0)
              if (! (features & FEATURE_ZEROBITFLD) && mi == 0)
                mi = 1;
                mi = 1;
              if (e[j].len < mi || e[j].len > ma)
              if (e[j].len < mi || e[j].len > ma)
                e[j].len = mi + (r % (ma + 1 - mi));
                e[j].len = mi + (r % (ma + 1 - mi));
              r >>= 6;
              r >>= 6;
              if ((features & FEATURE_ZEROBITFLD) && (r & 3) == 0
              if ((features & FEATURE_ZEROBITFLD) && (r & 3) == 0
                  && mi == 0)
                  && mi == 0)
                e[j].len = 0;
                e[j].len = 0;
            }
            }
          break;
          break;
        case 7:
        case 7:
          switch (r & 7)
          switch (r & 7)
            {
            {
            case 0:
            case 0:
            case 1:
            case 1:
            case 2:
            case 2:
              e[n].etype = ETYPE_STRUCT;
              e[n].etype = ETYPE_STRUCT;
              break;
              break;
            case 3:
            case 3:
            case 4:
            case 4:
              e[n].etype = ETYPE_UNION;
              e[n].etype = ETYPE_UNION;
              break;
              break;
            case 5:
            case 5:
            case 6:
            case 6:
              e[n].etype = ETYPE_STRUCT_ARRAY;
              e[n].etype = ETYPE_STRUCT_ARRAY;
              break;
              break;
            case 7:
            case 7:
              e[n].etype = ETYPE_UNION_ARRAY;
              e[n].etype = ETYPE_UNION_ARRAY;
              break;
              break;
            }
            }
          r >>= 3;
          r >>= 3;
          e[n].len = r % (len - n);
          e[n].len = r % (len - n);
          incr = 1 + e[n].len;
          incr = 1 + e[n].len;
          generate_fields (features, &e[n + 1], &e[n], e[n].len);
          generate_fields (features, &e[n + 1], &e[n], e[n].len);
          if (e[n].etype == ETYPE_STRUCT_ARRAY
          if (e[n].etype == ETYPE_STRUCT_ARRAY
              || e[n].etype == ETYPE_UNION_ARRAY)
              || e[n].etype == ETYPE_UNION_ARRAY)
            {
            {
              r = generate_random ();
              r = generate_random ();
              if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0)
              if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0)
                {
                {
                  e[n].arr_len = 0;
                  e[n].arr_len = 0;
                  if (n + incr == len && (r & 4)
                  if (n + incr == len && (r & 4)
                      && (parent->etype == ETYPE_STRUCT
                      && (parent->etype == ETYPE_STRUCT
                          || parent->etype == ETYPE_STRUCT_ARRAY))
                          || parent->etype == ETYPE_STRUCT_ARRAY))
                    {
                    {
                      int k;
                      int k;
                      for (k = 0; k < n; ++k)
                      for (k = 0; k < n; ++k)
                        if (e[k].etype != ETYPE_BITFLD || e[k].len)
                        if (e[k].etype != ETYPE_BITFLD || e[k].len)
                          {
                          {
                            e[n].arr_len = 255;
                            e[n].arr_len = 255;
                            break;
                            break;
                          }
                          }
                    }
                    }
                }
                }
              else if ((r & 3) != 3)
              else if ((r & 3) != 3)
                e[n].arr_len = (r >> 2) & 7;
                e[n].arr_len = (r >> 2) & 7;
              else
              else
                e[n].arr_len = (r >> 2) & 31;
                e[n].arr_len = (r >> 2) & 31;
            }
            }
          break;
          break;
        }
        }
      r = generate_random ();
      r = generate_random ();
      if ((r & 7) == 0)
      if ((r & 7) == 0)
        {
        {
          r >>= 3;
          r >>= 3;
          i = (features & FEATURE_ALIGNEDPACKED) ? NATTRIBS2 : NATTRIBS1;
          i = (features & FEATURE_ALIGNEDPACKED) ? NATTRIBS2 : NATTRIBS1;
          e[n].attrib = attributes[r % i];
          e[n].attrib = attributes[r % i];
          if (! (features & FEATURE_ALIGNEDPACKED)
          if (! (features & FEATURE_ALIGNEDPACKED)
              && strcmp (e[n].attrib, "atpa") == 0
              && strcmp (e[n].attrib, "atpa") == 0
              && ((e[n].type >= &attrib_types[0]
              && ((e[n].type >= &attrib_types[0]
                   && e[n].type < &attrib_types[NATYPES2])
                   && e[n].type < &attrib_types[NATYPES2])
                  || (e[n].type >= &attrib_array_types[0]
                  || (e[n].type >= &attrib_array_types[0]
                      && e[n].type < &attrib_array_types[NAATYPES2])
                      && e[n].type < &attrib_array_types[NAATYPES2])
                  || (e[n].type >= &aligned_bitfld_types[0]
                  || (e[n].type >= &aligned_bitfld_types[0]
                      && e[n].type < &aligned_bitfld_types[n_aligned_bitfld_types])))
                      && e[n].type < &aligned_bitfld_types[n_aligned_bitfld_types])))
            e[n].attrib = NULL;
            e[n].attrib = NULL;
        }
        }
    }
    }
}
}
 
 
void
void
generate_random_tests (enum FEATURE features, int len)
generate_random_tests (enum FEATURE features, int len)
{
{
  struct entry e[len + 1];
  struct entry e[len + 1];
  int i, r;
  int i, r;
  if (len > 'z' - 'a' + 1)
  if (len > 'z' - 'a' + 1)
    abort ();
    abort ();
  memset (e, 0, sizeof (e));
  memset (e, 0, sizeof (e));
  r = generate_random ();
  r = generate_random ();
  if ((r & 7) == 0)
  if ((r & 7) == 0)
    e[0].etype = ETYPE_UNION;
    e[0].etype = ETYPE_UNION;
  else
  else
    e[0].etype = ETYPE_STRUCT;
    e[0].etype = ETYPE_STRUCT;
  r >>= 3;
  r >>= 3;
  e[0].len = len;
  e[0].len = len;
  generate_fields (features, &e[1], &e[0], len);
  generate_fields (features, &e[1], &e[0], len);
  output (e);
  output (e);
}
}
 
 
struct { const char *name; enum FEATURE f; }
struct { const char *name; enum FEATURE f; }
features[] = {
features[] = {
{ "normal", 0 },
{ "normal", 0 },
{ "vector", FEATURE_VECTOR },
{ "vector", FEATURE_VECTOR },
{ "[0] :0", FEATURE_ZEROARRAY | FEATURE_ZEROBITFLD },
{ "[0] :0", FEATURE_ZEROARRAY | FEATURE_ZEROBITFLD },
{ "vector [0]",
{ "vector [0]",
  FEATURE_VECTOR | FEATURE_ZEROARRAY },
  FEATURE_VECTOR | FEATURE_ZEROARRAY },
{ "aligned packed vector [0] :0",
{ "aligned packed vector [0] :0",
  FEATURE_VECTOR | FEATURE_ZEROARRAY
  FEATURE_VECTOR | FEATURE_ZEROARRAY
  | FEATURE_ALIGNEDPACKED | FEATURE_ZEROBITFLD },
  | FEATURE_ALIGNEDPACKED | FEATURE_ZEROBITFLD },
};
};
 
 
int
int
main (int argc, char **argv)
main (int argc, char **argv)
{
{
  int i, j, count, c, n = 3000;
  int i, j, count, c, n = 3000;
  char *optarg;
  char *optarg;
 
 
  if (sizeof (int) != 4 || sizeof (long long) != 8)
  if (sizeof (int) != 4 || sizeof (long long) != 8)
    return 1;
    return 1;
 
 
  i = 1;
  i = 1;
  while (i < argc)
  while (i < argc)
    {
    {
      c = '\0';
      c = '\0';
      if (argv[i][0] == '-' && argv[i][2] == '\0')
      if (argv[i][0] == '-' && argv[i][2] == '\0')
        c = argv[i][1];
        c = argv[i][1];
      optarg = argv[i + 1];
      optarg = argv[i + 1];
      if (!optarg)
      if (!optarg)
        goto usage;
        goto usage;
      switch (c)
      switch (c)
        {
        {
        case 'n':
        case 'n':
          n = atoi (optarg);
          n = atoi (optarg);
          break;
          break;
        case 'd':
        case 'd':
          destdir = optarg;
          destdir = optarg;
          break;
          break;
        case 's':
        case 's':
          srcdir = optarg;
          srcdir = optarg;
          break;
          break;
        case 'i':
        case 'i':
          output_one = 1;
          output_one = 1;
          limidx = atoi (optarg);
          limidx = atoi (optarg);
          break;
          break;
        case 'e':
        case 'e':
          short_enums = 1;
          short_enums = 1;
          i--;
          i--;
          break;
          break;
        default:
        default:
          fprintf (stderr, "unrecognized option %s\n", argv[i]);
          fprintf (stderr, "unrecognized option %s\n", argv[i]);
          goto usage;
          goto usage;
      }
      }
      i += 2;
      i += 2;
    }
    }
 
 
  if (output_one)
  if (output_one)
    {
    {
      outfile = fopen ("/dev/null", "w");
      outfile = fopen ("/dev/null", "w");
      if (outfile == NULL)
      if (outfile == NULL)
        {
        {
          fputs ("could not open /dev/null", stderr);
          fputs ("could not open /dev/null", stderr);
          return 1;
          return 1;
        }
        }
      n = limidx + 1;
      n = limidx + 1;
    }
    }
 
 
  if (destdir == NULL && !output_one)
  if (destdir == NULL && !output_one)
    {
    {
    usage:
    usage:
      fprintf (stderr, "Usage:\n\
      fprintf (stderr, "Usage:\n\
%s [-e] [-s srcdir -d destdir] [-n count] [-i idx]\n\
%s [-e] [-s srcdir -d destdir] [-n count] [-i idx]\n\
Either -s srcdir -d destdir or -i idx must be used\n", argv[0]);
Either -s srcdir -d destdir or -i idx must be used\n", argv[0]);
      return 1;
      return 1;
    }
    }
 
 
  if (srcdir == NULL && !output_one)
  if (srcdir == NULL && !output_one)
    goto usage;
    goto usage;
 
 
  if (srcdir != NULL)
  if (srcdir != NULL)
    {
    {
      const char *s = srcdir;
      const char *s = srcdir;
      char *ss, *t;
      char *ss, *t;
      t = ss = malloc (strlen (srcdir) + 1);
      t = ss = malloc (strlen (srcdir) + 1);
      if (!ss)
      if (!ss)
        abort ();
        abort ();
      do {
      do {
        if (*s == '\\')
        if (*s == '\\')
          *t++ = '/';
          *t++ = '/';
        else
        else
          *t++ = *s;
          *t++ = *s;
      } while (*s++);
      } while (*s++);
      srcdir_safe = ss;
      srcdir_safe = ss;
    }
    }
 
 
  for (i = 0; i < NTYPES2; ++i)
  for (i = 0; i < NTYPES2; ++i)
    if (base_types[i].bitfld)
    if (base_types[i].bitfld)
      bitfld_types[n_bitfld_types++] = base_types[i];
      bitfld_types[n_bitfld_types++] = base_types[i];
  for (i = 0; i < NATYPES2; ++i)
  for (i = 0; i < NATYPES2; ++i)
    if (attrib_types[i].bitfld)
    if (attrib_types[i].bitfld)
      aligned_bitfld_types[n_aligned_bitfld_types++] = attrib_types[i];
      aligned_bitfld_types[n_aligned_bitfld_types++] = attrib_types[i];
  for (i = 0; i < sizeof (features) / sizeof (features[0]); ++i)
  for (i = 0; i < sizeof (features) / sizeof (features[0]); ++i)
    {
    {
      int startidx = idx;
      int startidx = idx;
      if (! output_one)
      if (! output_one)
        limidx = idx;
        limidx = idx;
      if (!i)
      if (!i)
        count = 200;
        count = 200;
      else
      else
        count = 20;
        count = 20;
      for (j = 1; j <= 9; ++j)
      for (j = 1; j <= 9; ++j)
        while (idx < startidx + j * count)
        while (idx < startidx + j * count)
          generate_random_tests (features[i].f, j);
          generate_random_tests (features[i].f, j);
      while (idx < startidx + count * 10)
      while (idx < startidx + count * 10)
        generate_random_tests (features[i].f, 10 + (generate_random () % 16));
        generate_random_tests (features[i].f, 10 + (generate_random () % 16));
    }
    }
  for (i = 0; n > 3000 && i < sizeof (features) / sizeof (features[0]); ++i)
  for (i = 0; n > 3000 && i < sizeof (features) / sizeof (features[0]); ++i)
    {
    {
      int startidx;
      int startidx;
      startidx = idx;
      startidx = idx;
      if (! output_one)
      if (! output_one)
        limidx = idx;
        limidx = idx;
      singles (features[i].f);
      singles (features[i].f);
      if (!i)
      if (!i)
        {
        {
          count = 1000;
          count = 1000;
          while (idx < startidx + 1000)
          while (idx < startidx + 1000)
            generate_random_tests (features[i].f, 1);
            generate_random_tests (features[i].f, 1);
        }
        }
      else
      else
        {
        {
          startidx = idx;
          startidx = idx;
          count = 100;
          count = 100;
          while (idx < startidx + 100)
          while (idx < startidx + 100)
            generate_random_tests (features[i].f, 1);
            generate_random_tests (features[i].f, 1);
        }
        }
      startidx = idx;
      startidx = idx;
      for (j = 2; j <= 9; ++j)
      for (j = 2; j <= 9; ++j)
        while (idx < startidx + (j - 1) * count)
        while (idx < startidx + (j - 1) * count)
          generate_random_tests (features[i].f, j);
          generate_random_tests (features[i].f, j);
      while (idx < startidx + count * 9)
      while (idx < startidx + count * 9)
        generate_random_tests (features[i].f, 10 + (generate_random () % 16));
        generate_random_tests (features[i].f, 10 + (generate_random () % 16));
    }
    }
  if (! output_one)
  if (! output_one)
    limidx = idx;
    limidx = idx;
  while (idx < n)
  while (idx < n)
    generate_random_tests (ALL_FEATURES, 1 + (generate_random () % 25));
    generate_random_tests (ALL_FEATURES, 1 + (generate_random () % 25));
  fclose (outfile);
  fclose (outfile);
  return 0;
  return 0;
}
}
 
 

powered by: WebSVN 2.1.0

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