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