1 struct obstack
2 {
3   long chunk_size;
4   struct _obstack_chunk *chunk;
5   char *object_base;
6   char *next_free;
7   char *chunk_limit;
8   int alignment_mask;
9   unsigned maybe_empty_object;
10 };
11 
12 struct objfile
13   {
14     struct objfile *next;
15     struct obstack type_obstack;
16   };
17 
18 struct type
19   {
20     unsigned length;
21     struct objfile *objfile;
22     short nfields;
23     struct field
24       {
25         union field_location
26           {
27             int bitpos;
28             unsigned long physaddr;
29             char *physname;
30           }
31         loc;
32         int bitsize;
33         struct type *type;
34         char *name;
35       }
36      *fields;
37   };
38 
39 struct type *alloc_type (void);
40 void * xmalloc (unsigned int z);
41 void _obstack_newchunk (struct obstack *o, int i);
42 void get_discrete_bounds (long long *lowp, long long *highp);
43 
44 extern void *memset(void *, int, __SIZE_TYPE__);
45 
46 struct type *
create_array_type(struct type * result_type,struct type * element_type)47 create_array_type (struct type *result_type, struct type *element_type)
48 {
49   long long low_bound, high_bound;
50   if (result_type == ((void *)0))
51     {
52       result_type = alloc_type ();
53     }
54   get_discrete_bounds (&low_bound, &high_bound);
55   (result_type)->length =
56     (element_type)->length * (high_bound - low_bound + 1);
57   (result_type)->nfields = 1;
58   (result_type)->fields =
59     (struct field *) ((result_type)->objfile != ((void *)0)
60 		      ? (
61 		      {
62 			struct obstack *__h =
63 			  (&(result_type)->objfile -> type_obstack);
64 			{
65 			  struct obstack *__o = (__h);
66 			  int __len = ((sizeof (struct field)));
67 			  if (__o->chunk_limit - __o->next_free < __len)
68 			    _obstack_newchunk (__o, __len);
69 			  __o->next_free += __len; (void) 0;
70 			};
71 			({
72 			  struct obstack *__o1 = (__h);
73 			  void *value;
74 			  value = (void *) __o1->object_base;
75 			  if (__o1->next_free == value)
76 			    __o1->maybe_empty_object = 1;
77 			  __o1->next_free = (((((__o1->next_free) - (char *) 0)
78 					       +__o1->alignment_mask)
79 					      & ~ (__o1->alignment_mask))
80 					     + (char *) 0);
81 			  if (__o1->next_free - (char *)__o1->chunk
82 			      > __o1->chunk_limit - (char *)__o1->chunk)
83 			    __o1->next_free = __o1->chunk_limit;
84 			  __o1->object_base = __o1->next_free;
85 			  value;
86 			});
87 		      }) : xmalloc (sizeof (struct field)));
88   return (result_type);
89 }
90 
91 struct type *
alloc_type(void)92 alloc_type (void)
93 {
94   abort ();
95 }
xmalloc(unsigned int z)96 void * xmalloc (unsigned int z)
97 {
98   return 0;
99 }
_obstack_newchunk(struct obstack * o,int i)100 void _obstack_newchunk (struct obstack *o, int i)
101 {
102   abort ();
103 }
104 void
get_discrete_bounds(long long * lowp,long long * highp)105 get_discrete_bounds (long long *lowp, long long *highp)
106 {
107   *lowp = 0;
108   *highp = 2;
109 }
110 
main(void)111 int main(void)
112 {
113   struct type element_type;
114   struct type result_type;
115 
116   memset (&element_type, 0, sizeof (struct type));
117   memset (&result_type, 0, sizeof (struct type));
118   element_type.length = 4;
119   create_array_type (&result_type, &element_type);
120   if (result_type.length != 12)
121     abort ();
122   exit (0);
123 }
124