1 /* This testcase derives from gnu obstack.c/obstack.h and failed with
2 -O3 -funroll-all-loops, or -O1 -frename-registers -funroll-loops on
5 Copyright (C) 2001 Free Software Foundation. */
7 # define PTR_INT_TYPE __PTRDIFF_TYPE__
12 struct _obstack_chunk
*prev
;
19 struct _obstack_chunk
*chunk
;
25 struct _obstack_chunk
*(*chunkfun
) (void *, long);
26 void (*freefun
) (void *, struct _obstack_chunk
*);
28 unsigned use_extra_arg
:1;
29 unsigned maybe_empty_object
:1;
30 unsigned alloc_failed
:1;
33 extern void _obstack_newchunk (struct obstack
*, int);
35 struct fooalign
{char x
; double d
;};
36 #define DEFAULT_ALIGNMENT \
37 ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
38 union fooround
{long x
; double d
;};
39 #define DEFAULT_ROUNDING (sizeof (union fooround))
42 #define COPYING_UNIT int
45 #define CALL_CHUNKFUN(h, size) \
46 (((h) -> use_extra_arg) \
47 ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
48 : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
50 #define CALL_FREEFUN(h, old_chunk) \
52 if ((h) -> use_extra_arg) \
53 (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
55 (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
59 _obstack_newchunk (h
, length
)
63 register struct _obstack_chunk
*old_chunk
= h
->chunk
;
64 register struct _obstack_chunk
*new_chunk
;
65 register long new_size
;
66 register long obj_size
= h
->next_free
- h
->object_base
;
70 new_size
= (obj_size
+ length
) + (obj_size
>> 3) + 100;
71 if (new_size
< h
->chunk_size
)
72 new_size
= h
->chunk_size
;
74 new_chunk
= CALL_CHUNKFUN (h
, new_size
);
76 new_chunk
->prev
= old_chunk
;
77 new_chunk
->limit
= h
->chunk_limit
= (char *) new_chunk
+ new_size
;
79 if (h
->alignment_mask
+ 1 >= DEFAULT_ALIGNMENT
)
81 for (i
= obj_size
/ sizeof (COPYING_UNIT
) - 1;
83 ((COPYING_UNIT
*)new_chunk
->contents
)[i
]
84 = ((COPYING_UNIT
*)h
->object_base
)[i
];
85 already
= obj_size
/ sizeof (COPYING_UNIT
) * sizeof (COPYING_UNIT
);
89 for (i
= already
; i
< obj_size
; i
++)
90 new_chunk
->contents
[i
] = h
->object_base
[i
];
92 if (h
->object_base
== old_chunk
->contents
&& ! h
->maybe_empty_object
)
94 new_chunk
->prev
= old_chunk
->prev
;
95 CALL_FREEFUN (h
, old_chunk
);
98 h
->object_base
= new_chunk
->contents
;
99 h
->next_free
= h
->object_base
+ obj_size
;
100 h
->maybe_empty_object
= 0;