obstack.h 22 KB

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