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