annotate include/obstack.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* obstack.h - object stack macros
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 1988-2020 Free Software Foundation, Inc.
111
kono
parents: 0
diff changeset
3 This file is part of the GNU C Library.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
111
kono
parents: 0
diff changeset
5 The GNU C Library is free software; you can redistribute it and/or
kono
parents: 0
diff changeset
6 modify it under the terms of the GNU Lesser General Public
kono
parents: 0
diff changeset
7 License as published by the Free Software Foundation; either
kono
parents: 0
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
111
kono
parents: 0
diff changeset
10 The GNU C Library is distributed in the hope that it will be useful,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
111
kono
parents: 0
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
kono
parents: 0
diff changeset
13 Lesser General Public License for more details.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
111
kono
parents: 0
diff changeset
15 You should have received a copy of the GNU Lesser General Public
kono
parents: 0
diff changeset
16 License along with the GNU C Library; if not, see
kono
parents: 0
diff changeset
17 <http://www.gnu.org/licenses/>. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 /* Summary:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
111
kono
parents: 0
diff changeset
21 All the apparent functions defined here are macros. The idea
kono
parents: 0
diff changeset
22 is that you would use these pre-tested macros to solve a
kono
parents: 0
diff changeset
23 very specific set of problems, and they would run fast.
kono
parents: 0
diff changeset
24 Caution: no side-effects in arguments please!! They may be
kono
parents: 0
diff changeset
25 evaluated MANY times!!
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
111
kono
parents: 0
diff changeset
27 These macros operate a stack of objects. Each object starts life
kono
parents: 0
diff changeset
28 small, and may grow to maturity. (Consider building a word syllable
kono
parents: 0
diff changeset
29 by syllable.) An object can move while it is growing. Once it has
kono
parents: 0
diff changeset
30 been "finished" it never changes address again. So the "top of the
kono
parents: 0
diff changeset
31 stack" is typically an immature growing object, while the rest of the
kono
parents: 0
diff changeset
32 stack is of mature, fixed size and fixed address objects.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
111
kono
parents: 0
diff changeset
34 These routines grab large chunks of memory, using a function you
kono
parents: 0
diff changeset
35 supply, called 'obstack_chunk_alloc'. On occasion, they free chunks,
kono
parents: 0
diff changeset
36 by calling 'obstack_chunk_free'. You must define them and declare
kono
parents: 0
diff changeset
37 them before using any obstack macros.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
111
kono
parents: 0
diff changeset
39 Each independent stack is represented by a 'struct obstack'.
kono
parents: 0
diff changeset
40 Each of the obstack macros expects a pointer to such a structure
kono
parents: 0
diff changeset
41 as the first argument.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
111
kono
parents: 0
diff changeset
43 One motivation for this package is the problem of growing char strings
kono
parents: 0
diff changeset
44 in symbol tables. Unless you are "fascist pig with a read-only mind"
kono
parents: 0
diff changeset
45 --Gosper's immortal quote from HAKMEM item 154, out of context--you
kono
parents: 0
diff changeset
46 would not like to put any arbitrary upper limit on the length of your
kono
parents: 0
diff changeset
47 symbols.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
111
kono
parents: 0
diff changeset
49 In practice this often means you will build many short symbols and a
kono
parents: 0
diff changeset
50 few long symbols. At the time you are reading a symbol you don't know
kono
parents: 0
diff changeset
51 how long it is. One traditional method is to read a symbol into a
kono
parents: 0
diff changeset
52 buffer, realloc()ating the buffer every time you try to read a symbol
kono
parents: 0
diff changeset
53 that is longer than the buffer. This is beaut, but you still will
kono
parents: 0
diff changeset
54 want to copy the symbol from the buffer to a more permanent
kono
parents: 0
diff changeset
55 symbol-table entry say about half the time.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
111
kono
parents: 0
diff changeset
57 With obstacks, you can work differently. Use one obstack for all symbol
kono
parents: 0
diff changeset
58 names. As you read a symbol, grow the name in the obstack gradually.
kono
parents: 0
diff changeset
59 When the name is complete, finalize it. Then, if the symbol exists already,
kono
parents: 0
diff changeset
60 free the newly read name.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
111
kono
parents: 0
diff changeset
62 The way we do this is to take a large chunk, allocating memory from
kono
parents: 0
diff changeset
63 low addresses. When you want to build a symbol in the chunk you just
kono
parents: 0
diff changeset
64 add chars above the current "high water mark" in the chunk. When you
kono
parents: 0
diff changeset
65 have finished adding chars, because you got to the end of the symbol,
kono
parents: 0
diff changeset
66 you know how long the chars are, and you can create a new object.
kono
parents: 0
diff changeset
67 Mostly the chars will not burst over the highest address of the chunk,
kono
parents: 0
diff changeset
68 because you would typically expect a chunk to be (say) 100 times as
kono
parents: 0
diff changeset
69 long as an average object.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
111
kono
parents: 0
diff changeset
71 In case that isn't clear, when we have enough chars to make up
kono
parents: 0
diff changeset
72 the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
kono
parents: 0
diff changeset
73 so we just point to it where it lies. No moving of chars is
kono
parents: 0
diff changeset
74 needed and this is the second win: potentially long strings need
kono
parents: 0
diff changeset
75 never be explicitly shuffled. Once an object is formed, it does not
kono
parents: 0
diff changeset
76 change its address during its lifetime.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
111
kono
parents: 0
diff changeset
78 When the chars burst over a chunk boundary, we allocate a larger
kono
parents: 0
diff changeset
79 chunk, and then copy the partly formed object from the end of the old
kono
parents: 0
diff changeset
80 chunk to the beginning of the new larger chunk. We then carry on
kono
parents: 0
diff changeset
81 accreting characters to the end of the object as we normally would.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
111
kono
parents: 0
diff changeset
83 A special macro is provided to add a single char at a time to a
kono
parents: 0
diff changeset
84 growing object. This allows the use of register variables, which
kono
parents: 0
diff changeset
85 break the ordinary 'growth' macro.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
111
kono
parents: 0
diff changeset
87 Summary:
kono
parents: 0
diff changeset
88 We allocate large chunks.
kono
parents: 0
diff changeset
89 We carve out one object at a time from the current chunk.
kono
parents: 0
diff changeset
90 Once carved, an object never moves.
kono
parents: 0
diff changeset
91 We are free to append data of any size to the currently
kono
parents: 0
diff changeset
92 growing object.
kono
parents: 0
diff changeset
93 Exactly one object is growing in an obstack at any one time.
kono
parents: 0
diff changeset
94 You can run one obstack per control block.
kono
parents: 0
diff changeset
95 You may have as many control blocks as you dare.
kono
parents: 0
diff changeset
96 Because of the way we do it, you can "unwind" an obstack
kono
parents: 0
diff changeset
97 back to a previous state. (You may remove objects much
kono
parents: 0
diff changeset
98 as you would with a stack.)
kono
parents: 0
diff changeset
99 */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 /* Don't do the contents of this file more than once. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 #ifndef _OBSTACK_H
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 #define _OBSTACK_H 1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
111
kono
parents: 0
diff changeset
107 #ifndef _OBSTACK_INTERFACE_VERSION
kono
parents: 0
diff changeset
108 # define _OBSTACK_INTERFACE_VERSION 2
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 #endif
111
kono
parents: 0
diff changeset
110
kono
parents: 0
diff changeset
111 #include <stddef.h> /* For size_t and ptrdiff_t. */
kono
parents: 0
diff changeset
112 #include <string.h> /* For __GNU_LIBRARY__, and memcpy. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
111
kono
parents: 0
diff changeset
114 #if _OBSTACK_INTERFACE_VERSION == 1
kono
parents: 0
diff changeset
115 /* For binary compatibility with obstack version 1, which used "int"
kono
parents: 0
diff changeset
116 and "long" for these two types. */
kono
parents: 0
diff changeset
117 # define _OBSTACK_SIZE_T unsigned int
kono
parents: 0
diff changeset
118 # define _CHUNK_SIZE_T unsigned long
kono
parents: 0
diff changeset
119 # define _OBSTACK_CAST(type, expr) ((type) (expr))
kono
parents: 0
diff changeset
120 #else
kono
parents: 0
diff changeset
121 /* Version 2 with sane types, especially for 64-bit hosts. */
kono
parents: 0
diff changeset
122 # define _OBSTACK_SIZE_T size_t
kono
parents: 0
diff changeset
123 # define _CHUNK_SIZE_T size_t
kono
parents: 0
diff changeset
124 # define _OBSTACK_CAST(type, expr) (expr)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
111
kono
parents: 0
diff changeset
127 /* If B is the base of an object addressed by P, return the result of
kono
parents: 0
diff changeset
128 aligning P to the next multiple of A + 1. B and P must be of type
kono
parents: 0
diff changeset
129 char *. A + 1 must be a power of 2. */
kono
parents: 0
diff changeset
130
kono
parents: 0
diff changeset
131 #define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132
111
kono
parents: 0
diff changeset
133 /* Similar to __BPTR_ALIGN (B, P, A), except optimize the common case
kono
parents: 0
diff changeset
134 where pointers can be converted to integers, aligned as integers,
kono
parents: 0
diff changeset
135 and converted back again. If ptrdiff_t is narrower than a
kono
parents: 0
diff changeset
136 pointer (e.g., the AS/400), play it safe and compute the alignment
kono
parents: 0
diff changeset
137 relative to B. Otherwise, use the faster strategy of computing the
kono
parents: 0
diff changeset
138 alignment relative to 0. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139
111
kono
parents: 0
diff changeset
140 #define __PTR_ALIGN(B, P, A) \
kono
parents: 0
diff changeset
141 __BPTR_ALIGN (sizeof (ptrdiff_t) < sizeof (void *) ? (B) : (char *) 0, \
kono
parents: 0
diff changeset
142 P, A)
kono
parents: 0
diff changeset
143
kono
parents: 0
diff changeset
144 #ifndef __attribute_pure__
kono
parents: 0
diff changeset
145 # if defined __GNUC_MINOR__ && __GNUC__ * 1000 + __GNUC_MINOR__ >= 2096
kono
parents: 0
diff changeset
146 # define __attribute_pure__ __attribute__ ((__pure__))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 # else
111
kono
parents: 0
diff changeset
148 # define __attribute_pure__
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 # endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151
111
kono
parents: 0
diff changeset
152 #ifdef __cplusplus
kono
parents: 0
diff changeset
153 extern "C" {
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155
111
kono
parents: 0
diff changeset
156 struct _obstack_chunk /* Lives at front of each chunk. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 {
111
kono
parents: 0
diff changeset
158 char *limit; /* 1 past end of this chunk */
kono
parents: 0
diff changeset
159 struct _obstack_chunk *prev; /* address of prior chunk or NULL */
kono
parents: 0
diff changeset
160 char contents[4]; /* objects begin here */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162
111
kono
parents: 0
diff changeset
163 struct obstack /* control current object in current chunk */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 {
111
kono
parents: 0
diff changeset
165 _CHUNK_SIZE_T chunk_size; /* preferred size to allocate chunks in */
kono
parents: 0
diff changeset
166 struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */
kono
parents: 0
diff changeset
167 char *object_base; /* address of object we are building */
kono
parents: 0
diff changeset
168 char *next_free; /* where to add next char to current object */
kono
parents: 0
diff changeset
169 char *chunk_limit; /* address of char after current chunk */
kono
parents: 0
diff changeset
170 union
kono
parents: 0
diff changeset
171 {
kono
parents: 0
diff changeset
172 _OBSTACK_SIZE_T i;
kono
parents: 0
diff changeset
173 void *p;
kono
parents: 0
diff changeset
174 } temp; /* Temporary for some macros. */
kono
parents: 0
diff changeset
175 _OBSTACK_SIZE_T alignment_mask; /* Mask of alignment for each object. */
kono
parents: 0
diff changeset
176
kono
parents: 0
diff changeset
177 /* These prototypes vary based on 'use_extra_arg'. */
kono
parents: 0
diff changeset
178 union
kono
parents: 0
diff changeset
179 {
kono
parents: 0
diff changeset
180 void *(*plain) (size_t);
kono
parents: 0
diff changeset
181 void *(*extra) (void *, size_t);
kono
parents: 0
diff changeset
182 } chunkfun;
kono
parents: 0
diff changeset
183 union
kono
parents: 0
diff changeset
184 {
kono
parents: 0
diff changeset
185 void (*plain) (void *);
kono
parents: 0
diff changeset
186 void (*extra) (void *, void *);
kono
parents: 0
diff changeset
187 } freefun;
kono
parents: 0
diff changeset
188
kono
parents: 0
diff changeset
189 void *extra_arg; /* first arg for chunk alloc/dealloc funcs */
kono
parents: 0
diff changeset
190 unsigned use_extra_arg : 1; /* chunk alloc/dealloc funcs take extra arg */
kono
parents: 0
diff changeset
191 unsigned maybe_empty_object : 1; /* There is a possibility that the current
kono
parents: 0
diff changeset
192 chunk contains a zero-length object. This
kono
parents: 0
diff changeset
193 prevents freeing the chunk if we allocate
kono
parents: 0
diff changeset
194 a bigger chunk to replace it. */
kono
parents: 0
diff changeset
195 unsigned alloc_failed : 1; /* No longer used, as we now call the failed
kono
parents: 0
diff changeset
196 handler on error, but retained for binary
kono
parents: 0
diff changeset
197 compatibility. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 /* Declare the external functions we use; they are in obstack.c. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
111
kono
parents: 0
diff changeset
202 extern void _obstack_newchunk (struct obstack *, _OBSTACK_SIZE_T);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 extern void _obstack_free (struct obstack *, void *);
111
kono
parents: 0
diff changeset
204 extern int _obstack_begin (struct obstack *,
kono
parents: 0
diff changeset
205 _OBSTACK_SIZE_T, _OBSTACK_SIZE_T,
kono
parents: 0
diff changeset
206 void *(*) (size_t), void (*) (void *));
kono
parents: 0
diff changeset
207 extern int _obstack_begin_1 (struct obstack *,
kono
parents: 0
diff changeset
208 _OBSTACK_SIZE_T, _OBSTACK_SIZE_T,
kono
parents: 0
diff changeset
209 void *(*) (void *, size_t),
kono
parents: 0
diff changeset
210 void (*) (void *, void *), void *);
kono
parents: 0
diff changeset
211 extern _OBSTACK_SIZE_T _obstack_memory_used (struct obstack *)
kono
parents: 0
diff changeset
212 __attribute_pure__;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
111
kono
parents: 0
diff changeset
215 /* Error handler called when 'obstack_chunk_alloc' failed to allocate
kono
parents: 0
diff changeset
216 more memory. This can be set to a user defined function which
kono
parents: 0
diff changeset
217 should either abort gracefully or use longjump - but shouldn't
kono
parents: 0
diff changeset
218 return. The default action is to print a message and abort. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 extern void (*obstack_alloc_failed_handler) (void);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220
111
kono
parents: 0
diff changeset
221 /* Exit value used when 'print_and_abort' is used. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 extern int obstack_exit_failure;
111
kono
parents: 0
diff changeset
223
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 /* Pointer to beginning of object being allocated or to be allocated next.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 Note that this might not be the final address of the object
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 because a new chunk might be needed to hold the final size. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227
111
kono
parents: 0
diff changeset
228 #define obstack_base(h) ((void *) (h)->object_base)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 /* Size for allocating ordinary chunks. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 #define obstack_chunk_size(h) ((h)->chunk_size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 /* Pointer to next byte not yet allocated in current chunk. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235
111
kono
parents: 0
diff changeset
236 #define obstack_next_free(h) ((void *) (h)->next_free)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 /* Mask specifying low bits that should be clear in address of an object. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 #define obstack_alignment_mask(h) ((h)->alignment_mask)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241
111
kono
parents: 0
diff changeset
242 /* To prevent prototype warnings provide complete argument list. */
kono
parents: 0
diff changeset
243 #define obstack_init(h) \
kono
parents: 0
diff changeset
244 _obstack_begin ((h), 0, 0, \
kono
parents: 0
diff changeset
245 _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc), \
kono
parents: 0
diff changeset
246 _OBSTACK_CAST (void (*) (void *), obstack_chunk_free))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247
111
kono
parents: 0
diff changeset
248 #define obstack_begin(h, size) \
kono
parents: 0
diff changeset
249 _obstack_begin ((h), (size), 0, \
kono
parents: 0
diff changeset
250 _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc), \
kono
parents: 0
diff changeset
251 _OBSTACK_CAST (void (*) (void *), obstack_chunk_free))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252
111
kono
parents: 0
diff changeset
253 #define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
kono
parents: 0
diff changeset
254 _obstack_begin ((h), (size), (alignment), \
kono
parents: 0
diff changeset
255 _OBSTACK_CAST (void *(*) (size_t), chunkfun), \
kono
parents: 0
diff changeset
256 _OBSTACK_CAST (void (*) (void *), freefun))
kono
parents: 0
diff changeset
257
kono
parents: 0
diff changeset
258 #define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
kono
parents: 0
diff changeset
259 _obstack_begin_1 ((h), (size), (alignment), \
kono
parents: 0
diff changeset
260 _OBSTACK_CAST (void *(*) (void *, size_t), chunkfun), \
kono
parents: 0
diff changeset
261 _OBSTACK_CAST (void (*) (void *, void *), freefun), arg)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262
111
kono
parents: 0
diff changeset
263 #define obstack_chunkfun(h, newchunkfun) \
kono
parents: 0
diff changeset
264 ((void) ((h)->chunkfun.extra = (void *(*) (void *, size_t)) (newchunkfun)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265
111
kono
parents: 0
diff changeset
266 #define obstack_freefun(h, newfreefun) \
kono
parents: 0
diff changeset
267 ((void) ((h)->freefun.extra = (void *(*) (void *, void *)) (newfreefun)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268
111
kono
parents: 0
diff changeset
269 #define obstack_1grow_fast(h, achar) ((void) (*((h)->next_free)++ = (achar)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270
111
kono
parents: 0
diff changeset
271 #define obstack_blank_fast(h, n) ((void) ((h)->next_free += (n)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 #define obstack_memory_used(h) _obstack_memory_used (h)
111
kono
parents: 0
diff changeset
274
kono
parents: 0
diff changeset
275 #if defined __GNUC__
kono
parents: 0
diff changeset
276 # if !defined __GNUC_MINOR__ || __GNUC__ * 1000 + __GNUC_MINOR__ < 2008
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 # define __extension__
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 # endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 /* For GNU C, if not -traditional,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 we can define these macros to compute all args only once
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 without using a global variable.
111
kono
parents: 0
diff changeset
283 Also, we can avoid using the 'temp' slot, to make faster code. */
kono
parents: 0
diff changeset
284
kono
parents: 0
diff changeset
285 # define obstack_object_size(OBSTACK) \
kono
parents: 0
diff changeset
286 __extension__ \
kono
parents: 0
diff changeset
287 ({ struct obstack const *__o = (OBSTACK); \
kono
parents: 0
diff changeset
288 (_OBSTACK_SIZE_T) (__o->next_free - __o->object_base); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289
111
kono
parents: 0
diff changeset
290 /* The local variable is named __o1 to avoid a shadowed variable
kono
parents: 0
diff changeset
291 warning when invoked from other obstack macros. */
kono
parents: 0
diff changeset
292 # define obstack_room(OBSTACK) \
kono
parents: 0
diff changeset
293 __extension__ \
kono
parents: 0
diff changeset
294 ({ struct obstack const *__o1 = (OBSTACK); \
kono
parents: 0
diff changeset
295 (_OBSTACK_SIZE_T) (__o1->chunk_limit - __o1->next_free); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296
111
kono
parents: 0
diff changeset
297 # define obstack_make_room(OBSTACK, length) \
kono
parents: 0
diff changeset
298 __extension__ \
kono
parents: 0
diff changeset
299 ({ struct obstack *__o = (OBSTACK); \
kono
parents: 0
diff changeset
300 _OBSTACK_SIZE_T __len = (length); \
kono
parents: 0
diff changeset
301 if (obstack_room (__o) < __len) \
kono
parents: 0
diff changeset
302 _obstack_newchunk (__o, __len); \
kono
parents: 0
diff changeset
303 (void) 0; })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304
111
kono
parents: 0
diff changeset
305 # define obstack_empty_p(OBSTACK) \
kono
parents: 0
diff changeset
306 __extension__ \
kono
parents: 0
diff changeset
307 ({ struct obstack const *__o = (OBSTACK); \
kono
parents: 0
diff changeset
308 (__o->chunk->prev == 0 \
kono
parents: 0
diff changeset
309 && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \
kono
parents: 0
diff changeset
310 __o->chunk->contents, \
kono
parents: 0
diff changeset
311 __o->alignment_mask)); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312
111
kono
parents: 0
diff changeset
313 # define obstack_grow(OBSTACK, where, length) \
kono
parents: 0
diff changeset
314 __extension__ \
kono
parents: 0
diff changeset
315 ({ struct obstack *__o = (OBSTACK); \
kono
parents: 0
diff changeset
316 _OBSTACK_SIZE_T __len = (length); \
kono
parents: 0
diff changeset
317 if (obstack_room (__o) < __len) \
kono
parents: 0
diff changeset
318 _obstack_newchunk (__o, __len); \
kono
parents: 0
diff changeset
319 memcpy (__o->next_free, where, __len); \
kono
parents: 0
diff changeset
320 __o->next_free += __len; \
kono
parents: 0
diff changeset
321 (void) 0; })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322
111
kono
parents: 0
diff changeset
323 # define obstack_grow0(OBSTACK, where, length) \
kono
parents: 0
diff changeset
324 __extension__ \
kono
parents: 0
diff changeset
325 ({ struct obstack *__o = (OBSTACK); \
kono
parents: 0
diff changeset
326 _OBSTACK_SIZE_T __len = (length); \
kono
parents: 0
diff changeset
327 if (obstack_room (__o) < __len + 1) \
kono
parents: 0
diff changeset
328 _obstack_newchunk (__o, __len + 1); \
kono
parents: 0
diff changeset
329 memcpy (__o->next_free, where, __len); \
kono
parents: 0
diff changeset
330 __o->next_free += __len; \
kono
parents: 0
diff changeset
331 *(__o->next_free)++ = 0; \
kono
parents: 0
diff changeset
332 (void) 0; })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333
111
kono
parents: 0
diff changeset
334 # define obstack_1grow(OBSTACK, datum) \
kono
parents: 0
diff changeset
335 __extension__ \
kono
parents: 0
diff changeset
336 ({ struct obstack *__o = (OBSTACK); \
kono
parents: 0
diff changeset
337 if (obstack_room (__o) < 1) \
kono
parents: 0
diff changeset
338 _obstack_newchunk (__o, 1); \
kono
parents: 0
diff changeset
339 obstack_1grow_fast (__o, datum); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340
111
kono
parents: 0
diff changeset
341 /* These assume that the obstack alignment is good enough for pointers
kono
parents: 0
diff changeset
342 or ints, and that the data added so far to the current object
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 shares that much alignment. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344
111
kono
parents: 0
diff changeset
345 # define obstack_ptr_grow(OBSTACK, datum) \
kono
parents: 0
diff changeset
346 __extension__ \
kono
parents: 0
diff changeset
347 ({ struct obstack *__o = (OBSTACK); \
kono
parents: 0
diff changeset
348 if (obstack_room (__o) < sizeof (void *)) \
kono
parents: 0
diff changeset
349 _obstack_newchunk (__o, sizeof (void *)); \
kono
parents: 0
diff changeset
350 obstack_ptr_grow_fast (__o, datum); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351
111
kono
parents: 0
diff changeset
352 # define obstack_int_grow(OBSTACK, datum) \
kono
parents: 0
diff changeset
353 __extension__ \
kono
parents: 0
diff changeset
354 ({ struct obstack *__o = (OBSTACK); \
kono
parents: 0
diff changeset
355 if (obstack_room (__o) < sizeof (int)) \
kono
parents: 0
diff changeset
356 _obstack_newchunk (__o, sizeof (int)); \
kono
parents: 0
diff changeset
357 obstack_int_grow_fast (__o, datum); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358
111
kono
parents: 0
diff changeset
359 # define obstack_ptr_grow_fast(OBSTACK, aptr) \
kono
parents: 0
diff changeset
360 __extension__ \
kono
parents: 0
diff changeset
361 ({ struct obstack *__o1 = (OBSTACK); \
kono
parents: 0
diff changeset
362 void *__p1 = __o1->next_free; \
kono
parents: 0
diff changeset
363 *(const void **) __p1 = (aptr); \
kono
parents: 0
diff changeset
364 __o1->next_free += sizeof (const void *); \
kono
parents: 0
diff changeset
365 (void) 0; })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366
111
kono
parents: 0
diff changeset
367 # define obstack_int_grow_fast(OBSTACK, aint) \
kono
parents: 0
diff changeset
368 __extension__ \
kono
parents: 0
diff changeset
369 ({ struct obstack *__o1 = (OBSTACK); \
kono
parents: 0
diff changeset
370 void *__p1 = __o1->next_free; \
kono
parents: 0
diff changeset
371 *(int *) __p1 = (aint); \
kono
parents: 0
diff changeset
372 __o1->next_free += sizeof (int); \
kono
parents: 0
diff changeset
373 (void) 0; })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374
111
kono
parents: 0
diff changeset
375 # define obstack_blank(OBSTACK, length) \
kono
parents: 0
diff changeset
376 __extension__ \
kono
parents: 0
diff changeset
377 ({ struct obstack *__o = (OBSTACK); \
kono
parents: 0
diff changeset
378 _OBSTACK_SIZE_T __len = (length); \
kono
parents: 0
diff changeset
379 if (obstack_room (__o) < __len) \
kono
parents: 0
diff changeset
380 _obstack_newchunk (__o, __len); \
kono
parents: 0
diff changeset
381 obstack_blank_fast (__o, __len); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382
111
kono
parents: 0
diff changeset
383 # define obstack_alloc(OBSTACK, length) \
kono
parents: 0
diff changeset
384 __extension__ \
kono
parents: 0
diff changeset
385 ({ struct obstack *__h = (OBSTACK); \
kono
parents: 0
diff changeset
386 obstack_blank (__h, (length)); \
kono
parents: 0
diff changeset
387 obstack_finish (__h); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388
111
kono
parents: 0
diff changeset
389 # define obstack_copy(OBSTACK, where, length) \
kono
parents: 0
diff changeset
390 __extension__ \
kono
parents: 0
diff changeset
391 ({ struct obstack *__h = (OBSTACK); \
kono
parents: 0
diff changeset
392 obstack_grow (__h, (where), (length)); \
kono
parents: 0
diff changeset
393 obstack_finish (__h); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394
111
kono
parents: 0
diff changeset
395 # define obstack_copy0(OBSTACK, where, length) \
kono
parents: 0
diff changeset
396 __extension__ \
kono
parents: 0
diff changeset
397 ({ struct obstack *__h = (OBSTACK); \
kono
parents: 0
diff changeset
398 obstack_grow0 (__h, (where), (length)); \
kono
parents: 0
diff changeset
399 obstack_finish (__h); })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400
111
kono
parents: 0
diff changeset
401 /* The local variable is named __o1 to avoid a shadowed variable
kono
parents: 0
diff changeset
402 warning when invoked from other obstack macros, typically obstack_free. */
kono
parents: 0
diff changeset
403 # define obstack_finish(OBSTACK) \
kono
parents: 0
diff changeset
404 __extension__ \
kono
parents: 0
diff changeset
405 ({ struct obstack *__o1 = (OBSTACK); \
kono
parents: 0
diff changeset
406 void *__value = (void *) __o1->object_base; \
kono
parents: 0
diff changeset
407 if (__o1->next_free == __value) \
kono
parents: 0
diff changeset
408 __o1->maybe_empty_object = 1; \
kono
parents: 0
diff changeset
409 __o1->next_free \
kono
parents: 0
diff changeset
410 = __PTR_ALIGN (__o1->object_base, __o1->next_free, \
kono
parents: 0
diff changeset
411 __o1->alignment_mask); \
kono
parents: 0
diff changeset
412 if ((size_t) (__o1->next_free - (char *) __o1->chunk) \
kono
parents: 0
diff changeset
413 > (size_t) (__o1->chunk_limit - (char *) __o1->chunk)) \
kono
parents: 0
diff changeset
414 __o1->next_free = __o1->chunk_limit; \
kono
parents: 0
diff changeset
415 __o1->object_base = __o1->next_free; \
kono
parents: 0
diff changeset
416 __value; })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417
111
kono
parents: 0
diff changeset
418 # define obstack_free(OBSTACK, OBJ) \
kono
parents: 0
diff changeset
419 __extension__ \
kono
parents: 0
diff changeset
420 ({ struct obstack *__o = (OBSTACK); \
kono
parents: 0
diff changeset
421 void *__obj = (void *) (OBJ); \
kono
parents: 0
diff changeset
422 if (__obj > (void *) __o->chunk && __obj < (void *) __o->chunk_limit) \
kono
parents: 0
diff changeset
423 __o->next_free = __o->object_base = (char *) __obj; \
kono
parents: 0
diff changeset
424 else \
kono
parents: 0
diff changeset
425 _obstack_free (__o, __obj); })
kono
parents: 0
diff changeset
426
kono
parents: 0
diff changeset
427 #else /* not __GNUC__ */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428
111
kono
parents: 0
diff changeset
429 # define obstack_object_size(h) \
kono
parents: 0
diff changeset
430 ((_OBSTACK_SIZE_T) ((h)->next_free - (h)->object_base))
kono
parents: 0
diff changeset
431
kono
parents: 0
diff changeset
432 # define obstack_room(h) \
kono
parents: 0
diff changeset
433 ((_OBSTACK_SIZE_T) ((h)->chunk_limit - (h)->next_free))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434
111
kono
parents: 0
diff changeset
435 # define obstack_empty_p(h) \
kono
parents: 0
diff changeset
436 ((h)->chunk->prev == 0 \
kono
parents: 0
diff changeset
437 && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \
kono
parents: 0
diff changeset
438 (h)->chunk->contents, \
kono
parents: 0
diff changeset
439 (h)->alignment_mask))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 /* Note that the call to _obstack_newchunk is enclosed in (..., 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 so that we can avoid having void expressions
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 in the arms of the conditional expression.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 Casting the third operand to void was tried before,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 but some compilers won't accept it. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
446
111
kono
parents: 0
diff changeset
447 # define obstack_make_room(h, length) \
kono
parents: 0
diff changeset
448 ((h)->temp.i = (length), \
kono
parents: 0
diff changeset
449 ((obstack_room (h) < (h)->temp.i) \
kono
parents: 0
diff changeset
450 ? (_obstack_newchunk (h, (h)->temp.i), 0) : 0), \
kono
parents: 0
diff changeset
451 (void) 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
452
111
kono
parents: 0
diff changeset
453 # define obstack_grow(h, where, length) \
kono
parents: 0
diff changeset
454 ((h)->temp.i = (length), \
kono
parents: 0
diff changeset
455 ((obstack_room (h) < (h)->temp.i) \
kono
parents: 0
diff changeset
456 ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \
kono
parents: 0
diff changeset
457 memcpy ((h)->next_free, where, (h)->temp.i), \
kono
parents: 0
diff changeset
458 (h)->next_free += (h)->temp.i, \
kono
parents: 0
diff changeset
459 (void) 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460
111
kono
parents: 0
diff changeset
461 # define obstack_grow0(h, where, length) \
kono
parents: 0
diff changeset
462 ((h)->temp.i = (length), \
kono
parents: 0
diff changeset
463 ((obstack_room (h) < (h)->temp.i + 1) \
kono
parents: 0
diff changeset
464 ? (_obstack_newchunk ((h), (h)->temp.i + 1), 0) : 0), \
kono
parents: 0
diff changeset
465 memcpy ((h)->next_free, where, (h)->temp.i), \
kono
parents: 0
diff changeset
466 (h)->next_free += (h)->temp.i, \
kono
parents: 0
diff changeset
467 *((h)->next_free)++ = 0, \
kono
parents: 0
diff changeset
468 (void) 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
469
111
kono
parents: 0
diff changeset
470 # define obstack_1grow(h, datum) \
kono
parents: 0
diff changeset
471 (((obstack_room (h) < 1) \
kono
parents: 0
diff changeset
472 ? (_obstack_newchunk ((h), 1), 0) : 0), \
kono
parents: 0
diff changeset
473 obstack_1grow_fast (h, datum))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
474
111
kono
parents: 0
diff changeset
475 # define obstack_ptr_grow(h, datum) \
kono
parents: 0
diff changeset
476 (((obstack_room (h) < sizeof (char *)) \
kono
parents: 0
diff changeset
477 ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
kono
parents: 0
diff changeset
478 obstack_ptr_grow_fast (h, datum))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479
111
kono
parents: 0
diff changeset
480 # define obstack_int_grow(h, datum) \
kono
parents: 0
diff changeset
481 (((obstack_room (h) < sizeof (int)) \
kono
parents: 0
diff changeset
482 ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
kono
parents: 0
diff changeset
483 obstack_int_grow_fast (h, datum))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484
111
kono
parents: 0
diff changeset
485 # define obstack_ptr_grow_fast(h, aptr) \
kono
parents: 0
diff changeset
486 (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr), \
kono
parents: 0
diff changeset
487 (void) 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488
111
kono
parents: 0
diff changeset
489 # define obstack_int_grow_fast(h, aint) \
kono
parents: 0
diff changeset
490 (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint), \
kono
parents: 0
diff changeset
491 (void) 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492
111
kono
parents: 0
diff changeset
493 # define obstack_blank(h, length) \
kono
parents: 0
diff changeset
494 ((h)->temp.i = (length), \
kono
parents: 0
diff changeset
495 ((obstack_room (h) < (h)->temp.i) \
kono
parents: 0
diff changeset
496 ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \
kono
parents: 0
diff changeset
497 obstack_blank_fast (h, (h)->temp.i))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498
111
kono
parents: 0
diff changeset
499 # define obstack_alloc(h, length) \
kono
parents: 0
diff changeset
500 (obstack_blank ((h), (length)), obstack_finish ((h)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501
111
kono
parents: 0
diff changeset
502 # define obstack_copy(h, where, length) \
kono
parents: 0
diff changeset
503 (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
kono
parents: 0
diff changeset
504
kono
parents: 0
diff changeset
505 # define obstack_copy0(h, where, length) \
kono
parents: 0
diff changeset
506 (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507
111
kono
parents: 0
diff changeset
508 # define obstack_finish(h) \
kono
parents: 0
diff changeset
509 (((h)->next_free == (h)->object_base \
kono
parents: 0
diff changeset
510 ? (((h)->maybe_empty_object = 1), 0) \
kono
parents: 0
diff changeset
511 : 0), \
kono
parents: 0
diff changeset
512 (h)->temp.p = (h)->object_base, \
kono
parents: 0
diff changeset
513 (h)->next_free \
kono
parents: 0
diff changeset
514 = __PTR_ALIGN ((h)->object_base, (h)->next_free, \
kono
parents: 0
diff changeset
515 (h)->alignment_mask), \
kono
parents: 0
diff changeset
516 (((size_t) ((h)->next_free - (char *) (h)->chunk) \
kono
parents: 0
diff changeset
517 > (size_t) ((h)->chunk_limit - (char *) (h)->chunk)) \
kono
parents: 0
diff changeset
518 ? ((h)->next_free = (h)->chunk_limit) : 0), \
kono
parents: 0
diff changeset
519 (h)->object_base = (h)->next_free, \
kono
parents: 0
diff changeset
520 (h)->temp.p)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521
111
kono
parents: 0
diff changeset
522 # define obstack_free(h, obj) \
kono
parents: 0
diff changeset
523 ((h)->temp.p = (void *) (obj), \
kono
parents: 0
diff changeset
524 (((h)->temp.p > (void *) (h)->chunk \
kono
parents: 0
diff changeset
525 && (h)->temp.p < (void *) (h)->chunk_limit) \
kono
parents: 0
diff changeset
526 ? (void) ((h)->next_free = (h)->object_base = (char *) (h)->temp.p) \
kono
parents: 0
diff changeset
527 : _obstack_free ((h), (h)->temp.p)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528
111
kono
parents: 0
diff changeset
529 #endif /* not __GNUC__ */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 #ifdef __cplusplus
111
kono
parents: 0
diff changeset
532 } /* C++ */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534
111
kono
parents: 0
diff changeset
535 #endif /* _OBSTACK_H */