Mercurial > hg > octave-jordi > gnulib-hg
annotate lib/obstack.c @ 4020:7158a1db8695
change license to gpl.
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Mon, 25 Nov 2002 00:17:33 +0000 |
parents | 22d3032f0239 |
children | 117a6d2af03b |
rev | line source |
---|---|
334 | 1 /* obstack.c - subroutines used implicitly by object stack macros |
3966
22d3032f0239
Include gettext.h instead of <libintl.h> with #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
3552
diff
changeset
|
2 Copyright (C) 1988-1994, 1996-1999, 2000-2002 Free Software Foundation, Inc. |
4020 | 3 This program is free software; you can redistribute it and/or modify |
4 it under the terms of the GNU General Public License as published by | |
5 the Free Software Foundation; either version 2, or (at your option) | |
6 any later version. | |
334 | 7 |
4020 | 8 This program is distributed in the hope that it will be useful, |
881 | 9 but WITHOUT ANY WARRANTY; without even the implied warranty of |
4020 | 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 GNU General Public License for more details. | |
334 | 12 |
4020 | 13 You should have received a copy of the GNU General Public License along |
14 with this program; if not, write to the Free Software Foundation, | |
15 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
334 | 16 |
2475 | 17 #ifdef HAVE_CONFIG_H |
18 # include <config.h> | |
19 #endif | |
20 | |
334 | 21 #include "obstack.h" |
22 | |
779 | 23 /* NOTE BEFORE MODIFYING THIS FILE: This version number must be |
24 incremented whenever callers compiled using an old obstack.h can no | |
25 longer properly call the functions in this obstack.c. */ | |
26 #define OBSTACK_INTERFACE_VERSION 1 | |
334 | 27 |
28 /* Comment out all this code if we are using the GNU C Library, and are not | |
779 | 29 actually compiling the library itself, and the installed library |
30 supports the same library interface we do. This code is part of the GNU | |
31 C Library, but also included in many other GNU distributions. Compiling | |
334 | 32 and linking in this code is a waste when using the GNU C library |
33 (especially if it is a shared library). Rather than having every GNU | |
779 | 34 program understand `configure --with-gnu-libc' and omit the object |
35 files, it is simpler to just do this in the source for each such file. */ | |
334 | 36 |
779 | 37 #include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */ |
3362 | 38 #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1 |
2475 | 39 # include <gnu-versions.h> |
40 # if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION | |
41 # define ELIDE_CODE | |
42 # endif | |
779 | 43 #endif |
44 | |
3361 | 45 #if defined _LIBC && defined USE_IN_LIBIO |
46 # include <wchar.h> | |
47 #endif | |
779 | 48 |
49 #ifndef ELIDE_CODE | |
334 | 50 |
51 | |
3362 | 52 # if defined __STDC__ && __STDC__ |
2475 | 53 # define POINTER void * |
54 # else | |
55 # define POINTER char * | |
56 # endif | |
334 | 57 |
58 /* Determine default alignment. */ | |
59 struct fooalign {char x; double d;}; | |
2475 | 60 # define DEFAULT_ALIGNMENT \ |
881 | 61 ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0)) |
334 | 62 /* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. |
63 But in fact it might be less smart and round addresses to as much as | |
64 DEFAULT_ROUNDING. So we prepare for it to do that. */ | |
65 union fooround {long x; double d;}; | |
2475 | 66 # define DEFAULT_ROUNDING (sizeof (union fooround)) |
334 | 67 |
68 /* When we copy a long block of data, this is the unit to do it with. | |
69 On some machines, copying successive ints does not work; | |
70 in such a case, redefine COPYING_UNIT to `long' (if that works) | |
71 or `char' as a last resort. */ | |
2475 | 72 # ifndef COPYING_UNIT |
73 # define COPYING_UNIT int | |
74 # endif | |
334 | 75 |
881 | 76 |
77 /* The functions allocating more room by calling `obstack_chunk_alloc' | |
78 jump to the handler pointed to by `obstack_alloc_failed_handler'. | |
2475 | 79 This can be set to a user defined function which should either |
80 abort gracefully or use longjump - but shouldn't return. This | |
81 variable by default points to the internal function | |
881 | 82 `print_and_abort'. */ |
3362 | 83 # if defined __STDC__ && __STDC__ |
881 | 84 static void print_and_abort (void); |
85 void (*obstack_alloc_failed_handler) (void) = print_and_abort; | |
2475 | 86 # else |
881 | 87 static void print_and_abort (); |
88 void (*obstack_alloc_failed_handler) () = print_and_abort; | |
2475 | 89 # endif |
881 | 90 |
91 /* Exit value used when `print_and_abort' is used. */ | |
2475 | 92 # if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H |
93 # include <stdlib.h> | |
94 # endif | |
95 # ifndef EXIT_FAILURE | |
96 # define EXIT_FAILURE 1 | |
97 # endif | |
881 | 98 int obstack_exit_failure = EXIT_FAILURE; |
99 | |
334 | 100 /* The non-GNU-C macros copy the obstack into this global variable |
101 to avoid multiple evaluation. */ | |
102 | |
103 struct obstack *_obstack; | |
104 | |
105 /* Define a macro that either calls functions with the traditional malloc/free | |
106 calling interface, or calls functions with the mmalloc/mfree interface | |
107 (that adds an extra first argument), based on the state of use_extra_arg. | |
108 For free, do not use ?:, since some compilers, like the MIPS compilers, | |
109 do not allow (expr) ? void : void. */ | |
110 | |
3362 | 111 # if defined __STDC__ && __STDC__ |
2475 | 112 # define CALL_CHUNKFUN(h, size) \ |
881 | 113 (((h) -> use_extra_arg) \ |
114 ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ | |
115 : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size))) | |
116 | |
2475 | 117 # define CALL_FREEFUN(h, old_chunk) \ |
881 | 118 do { \ |
119 if ((h) -> use_extra_arg) \ | |
120 (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ | |
121 else \ | |
122 (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \ | |
123 } while (0) | |
2475 | 124 # else |
125 # define CALL_CHUNKFUN(h, size) \ | |
334 | 126 (((h) -> use_extra_arg) \ |
127 ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ | |
779 | 128 : (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size))) |
334 | 129 |
2475 | 130 # define CALL_FREEFUN(h, old_chunk) \ |
334 | 131 do { \ |
132 if ((h) -> use_extra_arg) \ | |
133 (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ | |
134 else \ | |
779 | 135 (*(void (*) ()) (h)->freefun) ((old_chunk)); \ |
334 | 136 } while (0) |
2475 | 137 # endif |
334 | 138 |
139 | |
140 /* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). | |
141 Objects start on multiples of ALIGNMENT (0 means use default). | |
142 CHUNKFUN is the function to use to allocate chunks, | |
143 and FREEFUN the function to free them. | |
144 | |
2475 | 145 Return nonzero if successful, calls obstack_alloc_failed_handler if |
146 allocation fails. */ | |
334 | 147 |
148 int | |
149 _obstack_begin (h, size, alignment, chunkfun, freefun) | |
150 struct obstack *h; | |
151 int size; | |
152 int alignment; | |
3362 | 153 # if defined __STDC__ && __STDC__ |
881 | 154 POINTER (*chunkfun) (long); |
155 void (*freefun) (void *); | |
2475 | 156 # else |
334 | 157 POINTER (*chunkfun) (); |
158 void (*freefun) (); | |
2475 | 159 # endif |
334 | 160 { |
881 | 161 register struct _obstack_chunk *chunk; /* points to new chunk */ |
334 | 162 |
163 if (alignment == 0) | |
2475 | 164 alignment = (int) DEFAULT_ALIGNMENT; |
334 | 165 if (size == 0) |
166 /* Default size is what GNU malloc can fit in a 4096-byte block. */ | |
167 { | |
168 /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. | |
169 Use the values for range checking, because if range checking is off, | |
170 the extra bytes won't be missed terribly, but if range checking is on | |
171 and we used a larger request, a whole extra 4096 bytes would be | |
172 allocated. | |
173 | |
174 These number are irrelevant to the new GNU malloc. I suspect it is | |
175 less sensitive to the size of the request. */ | |
176 int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) | |
177 + 4 + DEFAULT_ROUNDING - 1) | |
178 & ~(DEFAULT_ROUNDING - 1)); | |
179 size = 4096 - extra; | |
180 } | |
181 | |
3362 | 182 # if defined __STDC__ && __STDC__ |
881 | 183 h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun; |
184 h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; | |
2475 | 185 # else |
334 | 186 h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; |
187 h->freefun = freefun; | |
2475 | 188 # endif |
334 | 189 h->chunk_size = size; |
190 h->alignment_mask = alignment - 1; | |
191 h->use_extra_arg = 0; | |
192 | |
193 chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); | |
194 if (!chunk) | |
881 | 195 (*obstack_alloc_failed_handler) (); |
334 | 196 h->next_free = h->object_base = chunk->contents; |
197 h->chunk_limit = chunk->limit | |
198 = (char *) chunk + h->chunk_size; | |
199 chunk->prev = 0; | |
200 /* The initial chunk now contains no empty object. */ | |
201 h->maybe_empty_object = 0; | |
881 | 202 h->alloc_failed = 0; |
334 | 203 return 1; |
204 } | |
205 | |
206 int | |
207 _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg) | |
208 struct obstack *h; | |
209 int size; | |
210 int alignment; | |
3362 | 211 # if defined __STDC__ && __STDC__ |
881 | 212 POINTER (*chunkfun) (POINTER, long); |
213 void (*freefun) (POINTER, POINTER); | |
2475 | 214 # else |
334 | 215 POINTER (*chunkfun) (); |
216 void (*freefun) (); | |
2475 | 217 # endif |
334 | 218 POINTER arg; |
219 { | |
881 | 220 register struct _obstack_chunk *chunk; /* points to new chunk */ |
334 | 221 |
222 if (alignment == 0) | |
2475 | 223 alignment = (int) DEFAULT_ALIGNMENT; |
334 | 224 if (size == 0) |
225 /* Default size is what GNU malloc can fit in a 4096-byte block. */ | |
226 { | |
227 /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. | |
228 Use the values for range checking, because if range checking is off, | |
229 the extra bytes won't be missed terribly, but if range checking is on | |
230 and we used a larger request, a whole extra 4096 bytes would be | |
231 allocated. | |
232 | |
233 These number are irrelevant to the new GNU malloc. I suspect it is | |
234 less sensitive to the size of the request. */ | |
235 int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) | |
236 + 4 + DEFAULT_ROUNDING - 1) | |
237 & ~(DEFAULT_ROUNDING - 1)); | |
238 size = 4096 - extra; | |
239 } | |
240 | |
3362 | 241 # if defined __STDC__ && __STDC__ |
881 | 242 h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun; |
243 h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; | |
2475 | 244 # else |
334 | 245 h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; |
246 h->freefun = freefun; | |
2475 | 247 # endif |
334 | 248 h->chunk_size = size; |
249 h->alignment_mask = alignment - 1; | |
250 h->extra_arg = arg; | |
251 h->use_extra_arg = 1; | |
252 | |
253 chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); | |
254 if (!chunk) | |
881 | 255 (*obstack_alloc_failed_handler) (); |
334 | 256 h->next_free = h->object_base = chunk->contents; |
257 h->chunk_limit = chunk->limit | |
258 = (char *) chunk + h->chunk_size; | |
259 chunk->prev = 0; | |
260 /* The initial chunk now contains no empty object. */ | |
261 h->maybe_empty_object = 0; | |
881 | 262 h->alloc_failed = 0; |
334 | 263 return 1; |
264 } | |
265 | |
266 /* Allocate a new current chunk for the obstack *H | |
267 on the assumption that LENGTH bytes need to be added | |
268 to the current object, or a new object of length LENGTH allocated. | |
269 Copies any partial object from the end of the old chunk | |
270 to the beginning of the new one. */ | |
271 | |
272 void | |
273 _obstack_newchunk (h, length) | |
274 struct obstack *h; | |
275 int length; | |
276 { | |
881 | 277 register struct _obstack_chunk *old_chunk = h->chunk; |
278 register struct _obstack_chunk *new_chunk; | |
334 | 279 register long new_size; |
2475 | 280 register long obj_size = h->next_free - h->object_base; |
281 register long i; | |
282 long already; | |
2915 | 283 char *object_base; |
334 | 284 |
285 /* Compute size for new chunk. */ | |
2915 | 286 new_size = (obj_size + length) + (obj_size >> 3) + h->alignment_mask + 100; |
334 | 287 if (new_size < h->chunk_size) |
288 new_size = h->chunk_size; | |
289 | |
290 /* Allocate and initialize the new chunk. */ | |
291 new_chunk = CALL_CHUNKFUN (h, new_size); | |
292 if (!new_chunk) | |
881 | 293 (*obstack_alloc_failed_handler) (); |
334 | 294 h->chunk = new_chunk; |
295 new_chunk->prev = old_chunk; | |
296 new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; | |
297 | |
2915 | 298 /* Compute an aligned object_base in the new chunk */ |
299 object_base = | |
300 __INT_TO_PTR ((__PTR_TO_INT (new_chunk->contents) + h->alignment_mask) | |
301 & ~ (h->alignment_mask)); | |
302 | |
334 | 303 /* Move the existing object to the new chunk. |
304 Word at a time is fast and is safe if the object | |
305 is sufficiently aligned. */ | |
306 if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) | |
307 { | |
308 for (i = obj_size / sizeof (COPYING_UNIT) - 1; | |
309 i >= 0; i--) | |
2915 | 310 ((COPYING_UNIT *)object_base)[i] |
334 | 311 = ((COPYING_UNIT *)h->object_base)[i]; |
312 /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, | |
313 but that can cross a page boundary on a machine | |
314 which does not do strict alignment for COPYING_UNITS. */ | |
315 already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); | |
316 } | |
317 else | |
318 already = 0; | |
319 /* Copy remaining bytes one by one. */ | |
320 for (i = already; i < obj_size; i++) | |
2915 | 321 object_base[i] = h->object_base[i]; |
334 | 322 |
323 /* If the object just copied was the only data in OLD_CHUNK, | |
324 free that chunk and remove it from the chain. | |
325 But not if that chunk might contain an empty object. */ | |
326 if (h->object_base == old_chunk->contents && ! h->maybe_empty_object) | |
327 { | |
328 new_chunk->prev = old_chunk->prev; | |
329 CALL_FREEFUN (h, old_chunk); | |
330 } | |
331 | |
2915 | 332 h->object_base = object_base; |
334 | 333 h->next_free = h->object_base + obj_size; |
334 /* The new chunk certainly contains no empty object yet. */ | |
335 h->maybe_empty_object = 0; | |
336 } | |
337 | |
338 /* Return nonzero if object OBJ has been allocated from obstack H. | |
339 This is here for debugging. | |
340 If you use it in a program, you are probably losing. */ | |
341 | |
3362 | 342 # if defined __STDC__ && __STDC__ |
334 | 343 /* Suppress -Wmissing-prototypes warning. We don't want to declare this in |
344 obstack.h because it is just for debugging. */ | |
345 int _obstack_allocated_p (struct obstack *h, POINTER obj); | |
2475 | 346 # endif |
334 | 347 |
348 int | |
349 _obstack_allocated_p (h, obj) | |
350 struct obstack *h; | |
351 POINTER obj; | |
352 { | |
881 | 353 register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ |
354 register struct _obstack_chunk *plp; /* point to previous chunk if any */ | |
334 | 355 |
356 lp = (h)->chunk; | |
357 /* We use >= rather than > since the object cannot be exactly at | |
358 the beginning of the chunk but might be an empty object exactly | |
881 | 359 at the end of an adjacent chunk. */ |
360 while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) | |
334 | 361 { |
362 plp = lp->prev; | |
363 lp = plp; | |
364 } | |
365 return lp != 0; | |
366 } | |
367 | |
368 /* Free objects in obstack H, including OBJ and everything allocate | |
369 more recently than OBJ. If OBJ is zero, free everything in H. */ | |
370 | |
2475 | 371 # undef obstack_free |
334 | 372 |
373 /* This function has two names with identical definitions. | |
374 This is the first one, called from non-ANSI code. */ | |
375 | |
376 void | |
377 _obstack_free (h, obj) | |
378 struct obstack *h; | |
379 POINTER obj; | |
380 { | |
881 | 381 register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ |
382 register struct _obstack_chunk *plp; /* point to previous chunk if any */ | |
334 | 383 |
384 lp = h->chunk; | |
385 /* We use >= because there cannot be an object at the beginning of a chunk. | |
386 But there can be an empty object at that address | |
387 at the end of another chunk. */ | |
881 | 388 while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) |
334 | 389 { |
390 plp = lp->prev; | |
391 CALL_FREEFUN (h, lp); | |
392 lp = plp; | |
393 /* If we switch chunks, we can't tell whether the new current | |
394 chunk contains an empty object, so assume that it may. */ | |
395 h->maybe_empty_object = 1; | |
396 } | |
397 if (lp) | |
398 { | |
881 | 399 h->object_base = h->next_free = (char *) (obj); |
334 | 400 h->chunk_limit = lp->limit; |
401 h->chunk = lp; | |
402 } | |
403 else if (obj != 0) | |
404 /* obj is not in any of the chunks! */ | |
405 abort (); | |
406 } | |
407 | |
408 /* This function is used from ANSI code. */ | |
409 | |
410 void | |
411 obstack_free (h, obj) | |
412 struct obstack *h; | |
413 POINTER obj; | |
414 { | |
881 | 415 register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ |
416 register struct _obstack_chunk *plp; /* point to previous chunk if any */ | |
334 | 417 |
418 lp = h->chunk; | |
419 /* We use >= because there cannot be an object at the beginning of a chunk. | |
420 But there can be an empty object at that address | |
421 at the end of another chunk. */ | |
881 | 422 while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) |
334 | 423 { |
424 plp = lp->prev; | |
425 CALL_FREEFUN (h, lp); | |
426 lp = plp; | |
427 /* If we switch chunks, we can't tell whether the new current | |
428 chunk contains an empty object, so assume that it may. */ | |
429 h->maybe_empty_object = 1; | |
430 } | |
431 if (lp) | |
432 { | |
881 | 433 h->object_base = h->next_free = (char *) (obj); |
334 | 434 h->chunk_limit = lp->limit; |
435 h->chunk = lp; | |
436 } | |
437 else if (obj != 0) | |
438 /* obj is not in any of the chunks! */ | |
439 abort (); | |
440 } | |
441 | |
881 | 442 int |
443 _obstack_memory_used (h) | |
444 struct obstack *h; | |
445 { | |
446 register struct _obstack_chunk* lp; | |
447 register int nbytes = 0; | |
448 | |
449 for (lp = h->chunk; lp != 0; lp = lp->prev) | |
450 { | |
451 nbytes += lp->limit - (char *) lp; | |
452 } | |
453 return nbytes; | |
454 } | |
455 | |
456 /* Define the error handler. */ | |
3966
22d3032f0239
Include gettext.h instead of <libintl.h> with #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
3552
diff
changeset
|
457 # ifdef _LIBC |
22d3032f0239
Include gettext.h instead of <libintl.h> with #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
3552
diff
changeset
|
458 # include <libintl.h> |
22d3032f0239
Include gettext.h instead of <libintl.h> with #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
3552
diff
changeset
|
459 # else |
22d3032f0239
Include gettext.h instead of <libintl.h> with #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
3552
diff
changeset
|
460 # include "gettext.h" |
881 | 461 # endif |
3966
22d3032f0239
Include gettext.h instead of <libintl.h> with #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
3552
diff
changeset
|
462 # define _(msgid) gettext (msgid) |
22d3032f0239
Include gettext.h instead of <libintl.h> with #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
3552
diff
changeset
|
463 |
2475 | 464 # if defined _LIBC && defined USE_IN_LIBIO |
465 # include <libio/iolibio.h> | |
466 # define fputs(s, f) _IO_fputs (s, f) | |
467 # endif | |
881 | 468 |
3361 | 469 # ifndef __attribute__ |
3293
a3e558e29878
(__attribute__): Define it to be empty for compilers
Jim Meyering <jim@meyering.net>
parents:
3280
diff
changeset
|
470 /* This feature is available in gcc versions 2.5 and later. */ |
3361 | 471 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) |
472 # define __attribute__(Spec) /* empty */ | |
473 # endif | |
3293
a3e558e29878
(__attribute__): Define it to be empty for compilers
Jim Meyering <jim@meyering.net>
parents:
3280
diff
changeset
|
474 # endif |
a3e558e29878
(__attribute__): Define it to be empty for compilers
Jim Meyering <jim@meyering.net>
parents:
3280
diff
changeset
|
475 |
881 | 476 static void |
3280 | 477 __attribute__ ((noreturn)) |
881 | 478 print_and_abort () |
479 { | |
3361 | 480 /* Don't change any of these strings. Yes, it would be possible to add |
481 the newline to the string and use fputs or so. But this must not | |
482 happen because the "memory exhausted" message appears in other places | |
483 like this and the translation should be reused instead of creating | |
484 a very similar string which requires a separate translation. */ | |
485 # if defined _LIBC && defined USE_IN_LIBIO | |
486 if (_IO_fwide (stderr, 0) > 0) | |
487 __fwprintf (stderr, L"%s\n", _("memory exhausted")); | |
488 else | |
489 # endif | |
490 fprintf (stderr, "%s\n", _("memory exhausted")); | |
881 | 491 exit (obstack_exit_failure); |
492 } | |
493 | |
2475 | 494 # if 0 |
334 | 495 /* These are now turned off because the applications do not use it |
496 and it uses bcopy via obstack_grow, which causes trouble on sysV. */ | |
497 | |
498 /* Now define the functional versions of the obstack macros. | |
499 Define them to simply use the corresponding macros to do the job. */ | |
500 | |
3361 | 501 # if defined __STDC__ && __STDC__ |
334 | 502 /* These function definitions do not work with non-ANSI preprocessors; |
503 they won't pass through the macro names in parentheses. */ | |
504 | |
505 /* The function names appear in parentheses in order to prevent | |
506 the macro-definitions of the names from being expanded there. */ | |
507 | |
508 POINTER (obstack_base) (obstack) | |
509 struct obstack *obstack; | |
510 { | |
511 return obstack_base (obstack); | |
512 } | |
513 | |
514 POINTER (obstack_next_free) (obstack) | |
515 struct obstack *obstack; | |
516 { | |
517 return obstack_next_free (obstack); | |
518 } | |
519 | |
520 int (obstack_object_size) (obstack) | |
521 struct obstack *obstack; | |
522 { | |
523 return obstack_object_size (obstack); | |
524 } | |
525 | |
526 int (obstack_room) (obstack) | |
527 struct obstack *obstack; | |
528 { | |
529 return obstack_room (obstack); | |
530 } | |
531 | |
881 | 532 int (obstack_make_room) (obstack, length) |
533 struct obstack *obstack; | |
534 int length; | |
535 { | |
536 return obstack_make_room (obstack, length); | |
537 } | |
538 | |
2979 | 539 void (obstack_grow) (obstack, data, length) |
334 | 540 struct obstack *obstack; |
2979 | 541 const POINTER data; |
334 | 542 int length; |
543 { | |
2979 | 544 obstack_grow (obstack, data, length); |
334 | 545 } |
546 | |
2979 | 547 void (obstack_grow0) (obstack, data, length) |
334 | 548 struct obstack *obstack; |
2979 | 549 const POINTER data; |
334 | 550 int length; |
551 { | |
2979 | 552 obstack_grow0 (obstack, data, length); |
334 | 553 } |
554 | |
555 void (obstack_1grow) (obstack, character) | |
556 struct obstack *obstack; | |
557 int character; | |
558 { | |
559 obstack_1grow (obstack, character); | |
560 } | |
561 | |
562 void (obstack_blank) (obstack, length) | |
563 struct obstack *obstack; | |
564 int length; | |
565 { | |
566 obstack_blank (obstack, length); | |
567 } | |
568 | |
569 void (obstack_1grow_fast) (obstack, character) | |
570 struct obstack *obstack; | |
571 int character; | |
572 { | |
573 obstack_1grow_fast (obstack, character); | |
574 } | |
575 | |
576 void (obstack_blank_fast) (obstack, length) | |
577 struct obstack *obstack; | |
578 int length; | |
579 { | |
580 obstack_blank_fast (obstack, length); | |
581 } | |
582 | |
583 POINTER (obstack_finish) (obstack) | |
584 struct obstack *obstack; | |
585 { | |
586 return obstack_finish (obstack); | |
587 } | |
588 | |
589 POINTER (obstack_alloc) (obstack, length) | |
590 struct obstack *obstack; | |
591 int length; | |
592 { | |
593 return obstack_alloc (obstack, length); | |
594 } | |
595 | |
2979 | 596 POINTER (obstack_copy) (obstack, address, length) |
334 | 597 struct obstack *obstack; |
2979 | 598 const POINTER address; |
334 | 599 int length; |
600 { | |
2979 | 601 return obstack_copy (obstack, address, length); |
334 | 602 } |
603 | |
2979 | 604 POINTER (obstack_copy0) (obstack, address, length) |
334 | 605 struct obstack *obstack; |
2979 | 606 const POINTER address; |
334 | 607 int length; |
608 { | |
2979 | 609 return obstack_copy0 (obstack, address, length); |
334 | 610 } |
611 | |
2475 | 612 # endif /* __STDC__ */ |
334 | 613 |
2475 | 614 # endif /* 0 */ |
334 | 615 |
779 | 616 #endif /* !ELIDE_CODE */ |