Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

obstack.h

Go to the documentation of this file.
00001 /* obstack.h - object stack macros
00002    Copyright (C) 1988,89,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
00003 
00004 
00005    NOTE: The canonical source of this file is maintained with the GNU C Library.
00006    Bugs can be reported to bug-glibc@gnu.org.
00007 
00008    This program is free software; you can redistribute it and/or modify it
00009    under the terms of the GNU General Public License as published by the
00010    Free Software Foundation; either version 2, or (at your option) any
00011    later version.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00021    USA.  */
00022 
00023 /* Summary:
00024 
00025 All the apparent functions defined here are macros. The idea
00026 is that you would use these pre-tested macros to solve a
00027 very specific set of problems, and they would run fast.
00028 Caution: no side-effects in arguments please!! They may be
00029 evaluated MANY times!!
00030 
00031 These macros operate a stack of objects.  Each object starts life
00032 small, and may grow to maturity.  (Consider building a word syllable
00033 by syllable.)  An object can move while it is growing.  Once it has
00034 been "finished" it never changes address again.  So the "top of the
00035 stack" is typically an immature growing object, while the rest of the
00036 stack is of mature, fixed size and fixed address objects.
00037 
00038 These routines grab large chunks of memory, using a function you
00039 supply, called `obstack_chunk_alloc'.  On occasion, they free chunks,
00040 by calling `obstack_chunk_free'.  You must define them and declare
00041 them before using any obstack macros.
00042 
00043 Each independent stack is represented by a `struct obstack'.
00044 Each of the obstack macros expects a pointer to such a structure
00045 as the first argument.
00046 
00047 One motivation for this package is the problem of growing char strings
00048 in symbol tables.  Unless you are "fascist pig with a read-only mind"
00049 --Gosper's immortal quote from HAKMEM item 154, out of context--you
00050 would not like to put any arbitrary upper limit on the length of your
00051 symbols.
00052 
00053 In practice this often means you will build many short symbols and a
00054 few long symbols.  At the time you are reading a symbol you don't know
00055 how long it is.  One traditional method is to read a symbol into a
00056 buffer, realloc()ating the buffer every time you try to read a symbol
00057 that is longer than the buffer.  This is beaut, but you still will
00058 want to copy the symbol from the buffer to a more permanent
00059 symbol-table entry say about half the time.
00060 
00061 With obstacks, you can work differently.  Use one obstack for all symbol
00062 names.  As you read a symbol, grow the name in the obstack gradually.
00063 When the name is complete, finalize it.  Then, if the symbol exists already,
00064 free the newly read name.
00065 
00066 The way we do this is to take a large chunk, allocating memory from
00067 low addresses.  When you want to build a symbol in the chunk you just
00068 add chars above the current "high water mark" in the chunk.  When you
00069 have finished adding chars, because you got to the end of the symbol,
00070 you know how long the chars are, and you can create a new object.
00071 Mostly the chars will not burst over the highest address of the chunk,
00072 because you would typically expect a chunk to be (say) 100 times as
00073 long as an average object.
00074 
00075 In case that isn't clear, when we have enough chars to make up
00076 the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
00077 so we just point to it where it lies.  No moving of chars is
00078 needed and this is the second win: potentially long strings need
00079 never be explicitly shuffled. Once an object is formed, it does not
00080 change its address during its lifetime.
00081 
00082 When the chars burst over a chunk boundary, we allocate a larger
00083 chunk, and then copy the partly formed object from the end of the old
00084 chunk to the beginning of the new larger chunk.  We then carry on
00085 accreting characters to the end of the object as we normally would.
00086 
00087 A special macro is provided to add a single char at a time to a
00088 growing object.  This allows the use of register variables, which
00089 break the ordinary 'growth' macro.
00090 
00091 Summary:
00092         We allocate large chunks.
00093         We carve out one object at a time from the current chunk.
00094         Once carved, an object never moves.
00095         We are free to append data of any size to the currently
00096           growing object.
00097         Exactly one object is growing in an obstack at any one time.
00098         You can run one obstack per control block.
00099         You may have as many control blocks as you dare.
00100         Because of the way we do it, you can `unwind' an obstack
00101           back to a previous state. (You may remove objects much
00102           as you would with a stack.)
00103 */
00104 
00105 
00106 /* Don't do the contents of this file more than once.  */
00107 
00108 #ifndef _OBSTACK_H
00109 #define _OBSTACK_H 1
00110 
00111 #ifdef __cplusplus
00112 extern "C" {
00113 #endif
00114 
00115 /* We use subtraction of (char *) 0 instead of casting to int
00116    because on word-addressable machines a simple cast to int
00117    may ignore the byte-within-word field of the pointer.  */
00118 
00119 #ifndef __PTR_TO_INT
00120 # define __PTR_TO_INT(P) ((P) - (char *) 0)
00121 #endif
00122 
00123 #ifndef __INT_TO_PTR
00124 # define __INT_TO_PTR(P) ((P) + (char *) 0)
00125 #endif
00126 
00127 /* We need the type of the resulting object.  If __PTRDIFF_TYPE__ is
00128    defined, as with GNU C, use that; that way we don't pollute the
00129    namespace with <stddef.h>'s symbols.  Otherwise, if <stddef.h> is
00130    available, include it and use ptrdiff_t.  In traditional C, long is
00131    the best that we can do.  */
00132 
00133 #ifdef __PTRDIFF_TYPE__
00134 # define PTR_INT_TYPE __PTRDIFF_TYPE__
00135 #else
00136 # ifdef HAVE_STDDEF_H
00137 #  include <stddef.h>
00138 #  define PTR_INT_TYPE ptrdiff_t
00139 # else
00140 #  define PTR_INT_TYPE long
00141 # endif
00142 #endif
00143 
00144 #if defined _LIBC || defined HAVE_STRING_H
00145 # include <string.h>
00146 # define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
00147 #else
00148 # ifdef memcpy
00149 #  define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
00150 # else
00151 #  define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N))
00152 # endif
00153 #endif
00154 
00155 struct _obstack_chunk           /* Lives at front of each chunk. */
00156 {
00157   char  *limit;                 /* 1 past end of this chunk */
00158   struct _obstack_chunk *prev;  /* address of prior chunk or NULL */
00159   char  contents[4];            /* objects begin here */
00160 };
00161 
00162 struct obstack          /* control current object in current chunk */
00163 {
00164   long  chunk_size;             /* preferred size to allocate chunks in */
00165   struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */
00166   char  *object_base;           /* address of object we are building */
00167   char  *next_free;             /* where to add next char to current object */
00168   char  *chunk_limit;           /* address of char after current chunk */
00169   PTR_INT_TYPE temp;            /* Temporary for some macros.  */
00170   int   alignment_mask;         /* Mask of alignment for each object. */
00171 #if defined(__STDC__)
00172   /* These prototypes vary based on `use_extra_arg', and we use
00173      casts to the prototypeless function type in all assignments,
00174      but having prototypes here quiets -Wstrict-prototypes.  */
00175   struct _obstack_chunk *(*chunkfun) (void *, long);
00176   void (*freefun) (void *, struct _obstack_chunk *);
00177   void *extra_arg;              /* first arg for chunk alloc/dealloc funcs */
00178 #else
00179   struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk.  */
00180   void (*freefun) ();           /* User's function to free a chunk.  */
00181   char *extra_arg;              /* first arg for chunk alloc/dealloc funcs */
00182 #endif
00183   unsigned use_extra_arg:1;     /* chunk alloc/dealloc funcs take extra arg */
00184   unsigned maybe_empty_object:1;/* There is a possibility that the current
00185                                    chunk contains a zero-length object.  This
00186                                    prevents freeing the chunk if we allocate
00187                                    a bigger chunk to replace it. */
00188   unsigned alloc_failed:1;      /* No longer used, as we now call the failed
00189                                    handler on error, but retained for binary
00190                                    compatibility.  */
00191 };
00192 
00193 /* Declare the external functions we use; they are in obstack.c.  */
00194 
00195 #if defined(__STDC__)
00196 extern void _obstack_newchunk (struct obstack *, int);
00197 extern void _obstack_free (struct obstack *, void *);
00198 extern int _obstack_begin (struct obstack *, int, int,
00199                             void *(*) (long), void (*) (void *));
00200 extern int _obstack_begin_1 (struct obstack *, int, int,
00201                              void *(*) (void *, long),
00202                              void (*) (void *, void *), void *);
00203 extern int _obstack_memory_used (struct obstack *);
00204 #else
00205 #error can not be in this trunc
00206 extern void _obstack_newchunk ();
00207 extern void _obstack_free ();
00208 extern int _obstack_begin ();
00209 extern int _obstack_begin_1 ();
00210 extern int _obstack_memory_used ();
00211 #endif
00212 
00213 #if defined(__STDC__)
00214 
00215 /* Do the function-declarations after the structs
00216    but before defining the macros.  */
00217 
00218 void obstack_init (struct obstack *obstack);
00219 
00220 void * obstack_alloc (struct obstack *obstack, int size);
00221 
00222 void * obstack_copy (struct obstack *obstack, void *address, int size);
00223 void * obstack_copy0 (struct obstack *obstack, void *address, int size);
00224 
00225 void obstack_free (struct obstack *obstack, void *block);
00226 
00227 void obstack_blank (struct obstack *obstack, int size);
00228 
00229 void obstack_grow (struct obstack *obstack, void *data, int size);
00230 void obstack_grow0 (struct obstack *obstack, void *data, int size);
00231 
00232 void obstack_1grow (struct obstack *obstack, int data_char);
00233 void obstack_ptr_grow (struct obstack *obstack, void *data);
00234 void obstack_int_grow (struct obstack *obstack, int data);
00235 
00236 void * obstack_finish (struct obstack *obstack);
00237 
00238 int obstack_object_size (struct obstack *obstack);
00239 
00240 int obstack_room (struct obstack *obstack);
00241 void obstack_make_room (struct obstack *obstack, int size);
00242 void obstack_1grow_fast (struct obstack *obstack, int data_char);
00243 void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
00244 void obstack_int_grow_fast (struct obstack *obstack, int data);
00245 void obstack_blank_fast (struct obstack *obstack, int size);
00246 
00247 void * obstack_base (struct obstack *obstack);
00248 void * obstack_next_free (struct obstack *obstack);
00249 int obstack_alignment_mask (struct obstack *obstack);
00250 int obstack_chunk_size (struct obstack *obstack);
00251 int obstack_memory_used (struct obstack *obstack);
00252 
00253 #endif /* __STDC__ */
00254 
00255 /* Non-ANSI C cannot really support alternative functions for these macros,
00256    so we do not declare them.  */
00257 
00258 /* Error handler called when `obstack_chunk_alloc' failed to allocate
00259    more memory.  This can be set to a user defined function.  The
00260    default action is to print a message and abort.  */
00261 #if defined(__STDC__)
00262 extern void (*obstack_alloc_failed_handler) (void);
00263 #else
00264 extern void (*obstack_alloc_failed_handler) ();
00265 #endif
00266 
00267 /* Exit value used when `print_and_abort' is used.  */
00268 extern int obstack_exit_failure;
00269 
00270 /* Pointer to beginning of object being allocated or to be allocated next.
00271    Note that this might not be the final address of the object
00272    because a new chunk might be needed to hold the final size.  */
00273 
00274 #define obstack_base(h) ((h)->object_base)
00275 
00276 /* Size for allocating ordinary chunks.  */
00277 
00278 #define obstack_chunk_size(h) ((h)->chunk_size)
00279 
00280 /* Pointer to next byte not yet allocated in current chunk.  */
00281 
00282 #define obstack_next_free(h)    ((h)->next_free)
00283 
00284 /* Mask specifying low bits that should be clear in address of an object.  */
00285 
00286 #define obstack_alignment_mask(h) ((h)->alignment_mask)
00287 
00288 /* To prevent prototype warnings provide complete argument list in
00289    standard C version.  */
00290 #if defined(__STDC__)
00291 
00292 # define obstack_init(h) \
00293   _obstack_begin ((h), 0, 0, \
00294                   (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
00295 
00296 # define obstack_begin(h, size) \
00297   _obstack_begin ((h), (size), 0, \
00298                   (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
00299 
00300 # define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
00301   _obstack_begin ((h), (size), (alignment), \
00302                     (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun))
00303 
00304 # define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
00305   _obstack_begin_1 ((h), (size), (alignment), \
00306                     (void *(*) (void *, long)) (chunkfun), \
00307                     (void (*) (void *, void *)) (freefun), (arg))
00308 
00309 # define obstack_chunkfun(h, newchunkfun) \
00310   ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
00311 
00312 # define obstack_freefun(h, newfreefun) \
00313   ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
00314 
00315 #else
00316 
00317 # define obstack_init(h) \
00318   _obstack_begin ((h), 0, 0, \
00319                   (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
00320 
00321 # define obstack_begin(h, size) \
00322   _obstack_begin ((h), (size), 0, \
00323                   (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
00324 
00325 # define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
00326   _obstack_begin ((h), (size), (alignment), \
00327                     (void *(*) ()) (chunkfun), (void (*) ()) (freefun))
00328 
00329 # define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
00330   _obstack_begin_1 ((h), (size), (alignment), \
00331                     (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg))
00332 
00333 # define obstack_chunkfun(h, newchunkfun) \
00334   ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
00335 
00336 # define obstack_freefun(h, newfreefun) \
00337   ((h) -> freefun = (void (*)()) (newfreefun))
00338 
00339 #endif
00340 
00341 #define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
00342 
00343 #define obstack_blank_fast(h,n) ((h)->next_free += (n))
00344 
00345 #define obstack_memory_used(h) _obstack_memory_used (h)
00346 
00347 #if defined(__GNUC__) && defined(__STDC__)
00348 /* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
00349    does not implement __extension__.  But that compiler doesn't define
00350    __GNUC_MINOR__.  */
00351 # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
00352 #  define __extension__
00353 # endif
00354 
00355 /* For GNU C, if not -traditional,
00356    we can define these macros to compute all args only once
00357    without using a global variable.
00358    Also, we can avoid using the `temp' slot, to make faster code.  */
00359 
00360 # define obstack_object_size(OBSTACK)                                   \
00361   __extension__                                                         \
00362   ({ struct obstack *__o = (OBSTACK);                                   \
00363      (unsigned) (__o->next_free - __o->object_base); })
00364 
00365 # define obstack_room(OBSTACK)                                          \
00366   __extension__                                                         \
00367   ({ struct obstack *__o = (OBSTACK);                                   \
00368      (unsigned) (__o->chunk_limit - __o->next_free); })
00369 
00370 # define obstack_make_room(OBSTACK,length)                              \
00371 __extension__                                                           \
00372 ({ struct obstack *__o = (OBSTACK);                                     \
00373    int __len = (length);                                                \
00374    if (__o->chunk_limit - __o->next_free < __len)                       \
00375      _obstack_newchunk (__o, __len);                                    \
00376    (void) 0; })
00377 
00378 # define obstack_empty_p(OBSTACK)                                       \
00379   __extension__                                                         \
00380   ({ struct obstack *__o = (OBSTACK);                                   \
00381      (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
00382 
00383 # define obstack_grow(OBSTACK,where,length)                             \
00384 __extension__                                                           \
00385 ({ struct obstack *__o = (OBSTACK);                                     \
00386    int __len = (length);                                                \
00387    if (__o->next_free + __len > __o->chunk_limit)                       \
00388      _obstack_newchunk (__o, __len);                                    \
00389    _obstack_memcpy (__o->next_free, (char *) (where), __len);           \
00390    __o->next_free += __len;                                             \
00391    (void) 0; })
00392 
00393 # define obstack_grow0(OBSTACK,where,length)                            \
00394 __extension__                                                           \
00395 ({ struct obstack *__o = (OBSTACK);                                     \
00396    int __len = (length);                                                \
00397    if (__o->next_free + __len + 1 > __o->chunk_limit)                   \
00398      _obstack_newchunk (__o, __len + 1);                                \
00399    _obstack_memcpy (__o->next_free, (char *) (where), __len);           \
00400    __o->next_free += __len;                                             \
00401    *(__o->next_free)++ = 0;                                             \
00402    (void) 0; })
00403 
00404 # define obstack_1grow(OBSTACK,datum)                                   \
00405 __extension__                                                           \
00406 ({ struct obstack *__o = (OBSTACK);                                     \
00407    if (__o->next_free + 1 > __o->chunk_limit)                           \
00408      _obstack_newchunk (__o, 1);                                        \
00409    *(__o->next_free)++ = (datum);                                       \
00410    (void) 0; })
00411 
00412 /* These assume that the obstack alignment is good enough for pointers or ints,
00413    and that the data added so far to the current object
00414    shares that much alignment.  */
00415 
00416 # define obstack_ptr_grow(OBSTACK,datum)                                \
00417 __extension__                                                           \
00418 ({ struct obstack *__o = (OBSTACK);                                     \
00419    if (__o->next_free + sizeof (void *) > __o->chunk_limit)             \
00420      _obstack_newchunk (__o, sizeof (void *));                          \
00421    *((void **)__o->next_free)++ = ((void *)datum);                      \
00422    (void) 0; })
00423 
00424 # define obstack_int_grow(OBSTACK,datum)                                \
00425 __extension__                                                           \
00426 ({ struct obstack *__o = (OBSTACK);                                     \
00427    if (__o->next_free + sizeof (int) > __o->chunk_limit)                \
00428      _obstack_newchunk (__o, sizeof (int));                             \
00429    *((int *)__o->next_free)++ = ((int)datum);                           \
00430    (void) 0; })
00431 
00432 # define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)
00433 # define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
00434 
00435 # define obstack_blank(OBSTACK,length)                                  \
00436 __extension__                                                           \
00437 ({ struct obstack *__o = (OBSTACK);                                     \
00438    int __len = (length);                                                \
00439    if (__o->chunk_limit - __o->next_free < __len)                       \
00440      _obstack_newchunk (__o, __len);                                    \
00441    __o->next_free += __len;                                             \
00442    (void) 0; })
00443 
00444 # define obstack_alloc(OBSTACK,length)                                  \
00445 __extension__                                                           \
00446 ({ struct obstack *__h = (OBSTACK);                                     \
00447    obstack_blank (__h, (length));                                       \
00448    obstack_finish (__h); })
00449 
00450 # define obstack_copy(OBSTACK,where,length)                             \
00451 __extension__                                                           \
00452 ({ struct obstack *__h = (OBSTACK);                                     \
00453    obstack_grow (__h, (where), (length));                               \
00454    obstack_finish (__h); })
00455 
00456 # define obstack_copy0(OBSTACK,where,length)                            \
00457 __extension__                                                           \
00458 ({ struct obstack *__h = (OBSTACK);                                     \
00459    obstack_grow0 (__h, (where), (length));                              \
00460    obstack_finish (__h); })
00461 
00462 /* The local variable is named __o1 to avoid a name conflict
00463    when obstack_blank is called.  */
00464 # define obstack_finish(OBSTACK)                                        \
00465 __extension__                                                           \
00466 ({ struct obstack *__o1 = (OBSTACK);                                    \
00467    void *value;                                                         \
00468    value = (void *) __o1->object_base;                                  \
00469    if (__o1->next_free == value)                                        \
00470      __o1->maybe_empty_object = 1;                                      \
00471    __o1->next_free                                                      \
00472      = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
00473                      & ~ (__o1->alignment_mask));                       \
00474    if (__o1->next_free - (char *)__o1->chunk                            \
00475        > __o1->chunk_limit - (char *)__o1->chunk)                       \
00476      __o1->next_free = __o1->chunk_limit;                               \
00477    __o1->object_base = __o1->next_free;                                 \
00478    value; })
00479 
00480 # define obstack_free(OBSTACK, OBJ)                                     \
00481 __extension__                                                           \
00482 ({ struct obstack *__o = (OBSTACK);                                     \
00483    void *__obj = (OBJ);                                                 \
00484    if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit)  \
00485      __o->next_free = __o->object_base = __obj;                         \
00486    else (obstack_free) (__o, __obj); })
00487 
00488 #else /* not __GNUC__ or not __STDC__ */
00489 
00490 # define obstack_object_size(h) \
00491  (unsigned) ((h)->next_free - (h)->object_base)
00492 
00493 # define obstack_room(h)                \
00494  (unsigned) ((h)->chunk_limit - (h)->next_free)
00495 
00496 # define obstack_empty_p(h) \
00497  ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
00498 
00499 /* Note that the call to _obstack_newchunk is enclosed in (..., 0)
00500    so that we can avoid having void expressions
00501    in the arms of the conditional expression.
00502    Casting the third operand to void was tried before,
00503    but some compilers won't accept it.  */
00504 
00505 # define obstack_make_room(h,length)                                    \
00506 ( (h)->temp = (length),                                                 \
00507   (((h)->next_free + (h)->temp > (h)->chunk_limit)                      \
00508    ? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
00509 
00510 # define obstack_grow(h,where,length)                                   \
00511 ( (h)->temp = (length),                                                 \
00512   (((h)->next_free + (h)->temp > (h)->chunk_limit)                      \
00513    ? (_obstack_newchunk ((h), (h)->temp), 0) : 0),                      \
00514   _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp),        \
00515   (h)->next_free += (h)->temp)
00516 
00517 # define obstack_grow0(h,where,length)                                  \
00518 ( (h)->temp = (length),                                                 \
00519   (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit)                  \
00520    ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0),                  \
00521   _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp),        \
00522   (h)->next_free += (h)->temp,                                          \
00523   *((h)->next_free)++ = 0)
00524 
00525 # define obstack_1grow(h,datum)                                         \
00526 ( (((h)->next_free + 1 > (h)->chunk_limit)                              \
00527    ? (_obstack_newchunk ((h), 1), 0) : 0),                              \
00528   (*((h)->next_free)++ = (datum)))
00529 
00530 # define obstack_ptr_grow(h,datum)                                      \
00531 ( (((h)->next_free + sizeof (char *) > (h)->chunk_limit)                \
00532    ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0),                \
00533   (*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum)))
00534 
00535 # define obstack_int_grow(h,datum)                                      \
00536 ( (((h)->next_free + sizeof (int) > (h)->chunk_limit)                   \
00537    ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0),                   \
00538   (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum)))
00539 
00540 # define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr)
00541 # define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
00542 
00543 # define obstack_blank(h,length)                                        \
00544 ( (h)->temp = (length),                                                 \
00545   (((h)->chunk_limit - (h)->next_free < (h)->temp)                      \
00546    ? (_obstack_newchunk ((h), (h)->temp), 0) : 0),                      \
00547   ((h)->next_free += (h)->temp))
00548 
00549 # define obstack_alloc(h,length)                                        \
00550  (obstack_blank ((h), (length)), obstack_finish ((h)))
00551 
00552 # define obstack_copy(h,where,length)                                   \
00553  (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
00554 
00555 # define obstack_copy0(h,where,length)                                  \
00556  (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
00557 
00558 # define obstack_finish(h)                                              \
00559 ( ((h)->next_free == (h)->object_base                                   \
00560    ? (((h)->maybe_empty_object = 1), 0)                                 \
00561    : 0),                                                                \
00562   (h)->temp = __PTR_TO_INT ((h)->object_base),                          \
00563   (h)->next_free                                                        \
00564     = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
00565                     & ~ ((h)->alignment_mask)),                         \
00566   (((h)->next_free - (char *) (h)->chunk                                \
00567     > (h)->chunk_limit - (char *) (h)->chunk)                           \
00568    ? ((h)->next_free = (h)->chunk_limit) : 0),                          \
00569   (h)->object_base = (h)->next_free,                                    \
00570   __INT_TO_PTR ((h)->temp))
00571 
00572 #if defined(__STDC__)
00573 #  define obstack_free(h,obj)                                           \
00574 ( (h)->temp = (char *) (obj) - (char *) (h)->chunk,                     \
00575   (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
00576    ? (int) ((h)->next_free = (h)->object_base                           \
00577             = (h)->temp + (char *) (h)->chunk)                          \
00578    : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
00579 # else
00580 #  define obstack_free(h,obj)                                           \
00581 ( (h)->temp = (char *) (obj) - (char *) (h)->chunk,                     \
00582   (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
00583    ? (int) ((h)->next_free = (h)->object_base                           \
00584             = (h)->temp + (char *) (h)->chunk)                          \
00585    : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
00586 # endif
00587 
00588 #endif /* not __GNUC__ or not __STDC__ */
00589 
00590 #ifdef __cplusplus
00591 }       /* C++ */
00592 #endif
00593 
00594 #endif /* obstack.h */

Generated on Sat Mar 23 18:58:40 2002 for Komssys-mkauto by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002