Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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