1*946379e7Schristos /* obstack.c - subroutines used implicitly by object stack macros
2*946379e7Schristos
3*946379e7Schristos Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
4*946379e7Schristos 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
5*946379e7Schristos Foundation, Inc.
6*946379e7Schristos
7*946379e7Schristos This program is free software; you can redistribute it and/or modify
8*946379e7Schristos it under the terms of the GNU General Public License as published by
9*946379e7Schristos the Free Software Foundation; either version 2, or (at your option)
10*946379e7Schristos any later version.
11*946379e7Schristos
12*946379e7Schristos This program is distributed in the hope that it will be useful,
13*946379e7Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
14*946379e7Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15*946379e7Schristos GNU General Public License for more details.
16*946379e7Schristos
17*946379e7Schristos You should have received a copy of the GNU General Public License along
18*946379e7Schristos with this program; if not, write to the Free Software Foundation,
19*946379e7Schristos Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20*946379e7Schristos
21*946379e7Schristos #ifdef _LIBC
22*946379e7Schristos # include <obstack.h>
23*946379e7Schristos # include <shlib-compat.h>
24*946379e7Schristos #else
25*946379e7Schristos # include <config.h>
26*946379e7Schristos # include "obstack.h"
27*946379e7Schristos #endif
28*946379e7Schristos
29*946379e7Schristos /* NOTE BEFORE MODIFYING THIS FILE: This version number must be
30*946379e7Schristos incremented whenever callers compiled using an old obstack.h can no
31*946379e7Schristos longer properly call the functions in this obstack.c. */
32*946379e7Schristos #define OBSTACK_INTERFACE_VERSION 1
33*946379e7Schristos
34*946379e7Schristos /* Comment out all this code if we are using the GNU C Library, and are not
35*946379e7Schristos actually compiling the library itself, and the installed library
36*946379e7Schristos supports the same library interface we do. This code is part of the GNU
37*946379e7Schristos C Library, but also included in many other GNU distributions. Compiling
38*946379e7Schristos and linking in this code is a waste when using the GNU C library
39*946379e7Schristos (especially if it is a shared library). Rather than having every GNU
40*946379e7Schristos program understand `configure --with-gnu-libc' and omit the object
41*946379e7Schristos files, it is simpler to just do this in the source for each such file. */
42*946379e7Schristos
43*946379e7Schristos #include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
44*946379e7Schristos #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
45*946379e7Schristos # include <gnu-versions.h>
46*946379e7Schristos # if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
47*946379e7Schristos # define ELIDE_CODE
48*946379e7Schristos # endif
49*946379e7Schristos #endif
50*946379e7Schristos
51*946379e7Schristos #include <stddef.h>
52*946379e7Schristos
53*946379e7Schristos #ifndef ELIDE_CODE
54*946379e7Schristos
55*946379e7Schristos # include <stdint.h>
56*946379e7Schristos
57*946379e7Schristos /* Determine default alignment. */
58*946379e7Schristos union fooround
59*946379e7Schristos {
60*946379e7Schristos uintmax_t i;
61*946379e7Schristos long double d;
62*946379e7Schristos void *p;
63*946379e7Schristos };
64*946379e7Schristos struct fooalign
65*946379e7Schristos {
66*946379e7Schristos char c;
67*946379e7Schristos union fooround u;
68*946379e7Schristos };
69*946379e7Schristos /* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
70*946379e7Schristos But in fact it might be less smart and round addresses to as much as
71*946379e7Schristos DEFAULT_ROUNDING. So we prepare for it to do that. */
72*946379e7Schristos enum
73*946379e7Schristos {
74*946379e7Schristos DEFAULT_ALIGNMENT = offsetof (struct fooalign, u),
75*946379e7Schristos DEFAULT_ROUNDING = sizeof (union fooround)
76*946379e7Schristos };
77*946379e7Schristos
78*946379e7Schristos /* When we copy a long block of data, this is the unit to do it with.
79*946379e7Schristos On some machines, copying successive ints does not work;
80*946379e7Schristos in such a case, redefine COPYING_UNIT to `long' (if that works)
81*946379e7Schristos or `char' as a last resort. */
82*946379e7Schristos # ifndef COPYING_UNIT
83*946379e7Schristos # define COPYING_UNIT int
84*946379e7Schristos # endif
85*946379e7Schristos
86*946379e7Schristos
87*946379e7Schristos /* The functions allocating more room by calling `obstack_chunk_alloc'
88*946379e7Schristos jump to the handler pointed to by `obstack_alloc_failed_handler'.
89*946379e7Schristos This can be set to a user defined function which should either
90*946379e7Schristos abort gracefully or use longjump - but shouldn't return. This
91*946379e7Schristos variable by default points to the internal function
92*946379e7Schristos `print_and_abort'. */
93*946379e7Schristos static void print_and_abort (void);
94*946379e7Schristos void (*obstack_alloc_failed_handler) (void) = print_and_abort;
95*946379e7Schristos
96*946379e7Schristos /* Exit value used when `print_and_abort' is used. */
97*946379e7Schristos # include <stdlib.h>
98*946379e7Schristos # ifdef _LIBC
99*946379e7Schristos int obstack_exit_failure = EXIT_FAILURE;
100*946379e7Schristos # else
101*946379e7Schristos # include "exitfail.h"
102*946379e7Schristos # define obstack_exit_failure exit_failure
103*946379e7Schristos # endif
104*946379e7Schristos
105*946379e7Schristos # ifdef _LIBC
106*946379e7Schristos # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
107*946379e7Schristos /* A looong time ago (before 1994, anyway; we're not sure) this global variable
108*946379e7Schristos was used by non-GNU-C macros to avoid multiple evaluation. The GNU C
109*946379e7Schristos library still exports it because somebody might use it. */
110*946379e7Schristos struct obstack *_obstack_compat;
111*946379e7Schristos compat_symbol (libc, _obstack_compat, _obstack, GLIBC_2_0);
112*946379e7Schristos # endif
113*946379e7Schristos # endif
114*946379e7Schristos
115*946379e7Schristos /* Define a macro that either calls functions with the traditional malloc/free
116*946379e7Schristos calling interface, or calls functions with the mmalloc/mfree interface
117*946379e7Schristos (that adds an extra first argument), based on the state of use_extra_arg.
118*946379e7Schristos For free, do not use ?:, since some compilers, like the MIPS compilers,
119*946379e7Schristos do not allow (expr) ? void : void. */
120*946379e7Schristos
121*946379e7Schristos # define CALL_CHUNKFUN(h, size) \
122*946379e7Schristos (((h) -> use_extra_arg) \
123*946379e7Schristos ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
124*946379e7Schristos : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
125*946379e7Schristos
126*946379e7Schristos # define CALL_FREEFUN(h, old_chunk) \
127*946379e7Schristos do { \
128*946379e7Schristos if ((h) -> use_extra_arg) \
129*946379e7Schristos (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
130*946379e7Schristos else \
131*946379e7Schristos (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
132*946379e7Schristos } while (0)
133*946379e7Schristos
134*946379e7Schristos
135*946379e7Schristos /* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
136*946379e7Schristos Objects start on multiples of ALIGNMENT (0 means use default).
137*946379e7Schristos CHUNKFUN is the function to use to allocate chunks,
138*946379e7Schristos and FREEFUN the function to free them.
139*946379e7Schristos
140*946379e7Schristos Return nonzero if successful, calls obstack_alloc_failed_handler if
141*946379e7Schristos allocation fails. */
142*946379e7Schristos
143*946379e7Schristos int
_obstack_begin(struct obstack * h,int size,int alignment,void * (* chunkfun)(long),void (* freefun)(void *))144*946379e7Schristos _obstack_begin (struct obstack *h,
145*946379e7Schristos int size, int alignment,
146*946379e7Schristos void *(*chunkfun) (long),
147*946379e7Schristos void (*freefun) (void *))
148*946379e7Schristos {
149*946379e7Schristos register struct _obstack_chunk *chunk; /* points to new chunk */
150*946379e7Schristos
151*946379e7Schristos if (alignment == 0)
152*946379e7Schristos alignment = DEFAULT_ALIGNMENT;
153*946379e7Schristos if (size == 0)
154*946379e7Schristos /* Default size is what GNU malloc can fit in a 4096-byte block. */
155*946379e7Schristos {
156*946379e7Schristos /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
157*946379e7Schristos Use the values for range checking, because if range checking is off,
158*946379e7Schristos the extra bytes won't be missed terribly, but if range checking is on
159*946379e7Schristos and we used a larger request, a whole extra 4096 bytes would be
160*946379e7Schristos allocated.
161*946379e7Schristos
162*946379e7Schristos These number are irrelevant to the new GNU malloc. I suspect it is
163*946379e7Schristos less sensitive to the size of the request. */
164*946379e7Schristos int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
165*946379e7Schristos + 4 + DEFAULT_ROUNDING - 1)
166*946379e7Schristos & ~(DEFAULT_ROUNDING - 1));
167*946379e7Schristos size = 4096 - extra;
168*946379e7Schristos }
169*946379e7Schristos
170*946379e7Schristos h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
171*946379e7Schristos h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
172*946379e7Schristos h->chunk_size = size;
173*946379e7Schristos h->alignment_mask = alignment - 1;
174*946379e7Schristos h->use_extra_arg = 0;
175*946379e7Schristos
176*946379e7Schristos chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
177*946379e7Schristos if (!chunk)
178*946379e7Schristos (*obstack_alloc_failed_handler) ();
179*946379e7Schristos h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
180*946379e7Schristos alignment - 1);
181*946379e7Schristos h->chunk_limit = chunk->limit
182*946379e7Schristos = (char *) chunk + h->chunk_size;
183*946379e7Schristos chunk->prev = 0;
184*946379e7Schristos /* The initial chunk now contains no empty object. */
185*946379e7Schristos h->maybe_empty_object = 0;
186*946379e7Schristos h->alloc_failed = 0;
187*946379e7Schristos return 1;
188*946379e7Schristos }
189*946379e7Schristos
190*946379e7Schristos int
_obstack_begin_1(struct obstack * h,int size,int alignment,void * (* chunkfun)(void *,long),void (* freefun)(void *,void *),void * arg)191*946379e7Schristos _obstack_begin_1 (struct obstack *h, int size, int alignment,
192*946379e7Schristos void *(*chunkfun) (void *, long),
193*946379e7Schristos void (*freefun) (void *, void *),
194*946379e7Schristos void *arg)
195*946379e7Schristos {
196*946379e7Schristos register struct _obstack_chunk *chunk; /* points to new chunk */
197*946379e7Schristos
198*946379e7Schristos if (alignment == 0)
199*946379e7Schristos alignment = DEFAULT_ALIGNMENT;
200*946379e7Schristos if (size == 0)
201*946379e7Schristos /* Default size is what GNU malloc can fit in a 4096-byte block. */
202*946379e7Schristos {
203*946379e7Schristos /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
204*946379e7Schristos Use the values for range checking, because if range checking is off,
205*946379e7Schristos the extra bytes won't be missed terribly, but if range checking is on
206*946379e7Schristos and we used a larger request, a whole extra 4096 bytes would be
207*946379e7Schristos allocated.
208*946379e7Schristos
209*946379e7Schristos These number are irrelevant to the new GNU malloc. I suspect it is
210*946379e7Schristos less sensitive to the size of the request. */
211*946379e7Schristos int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
212*946379e7Schristos + 4 + DEFAULT_ROUNDING - 1)
213*946379e7Schristos & ~(DEFAULT_ROUNDING - 1));
214*946379e7Schristos size = 4096 - extra;
215*946379e7Schristos }
216*946379e7Schristos
217*946379e7Schristos h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
218*946379e7Schristos h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
219*946379e7Schristos h->chunk_size = size;
220*946379e7Schristos h->alignment_mask = alignment - 1;
221*946379e7Schristos h->extra_arg = arg;
222*946379e7Schristos h->use_extra_arg = 1;
223*946379e7Schristos
224*946379e7Schristos chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
225*946379e7Schristos if (!chunk)
226*946379e7Schristos (*obstack_alloc_failed_handler) ();
227*946379e7Schristos h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
228*946379e7Schristos alignment - 1);
229*946379e7Schristos h->chunk_limit = chunk->limit
230*946379e7Schristos = (char *) chunk + h->chunk_size;
231*946379e7Schristos chunk->prev = 0;
232*946379e7Schristos /* The initial chunk now contains no empty object. */
233*946379e7Schristos h->maybe_empty_object = 0;
234*946379e7Schristos h->alloc_failed = 0;
235*946379e7Schristos return 1;
236*946379e7Schristos }
237*946379e7Schristos
238*946379e7Schristos /* Allocate a new current chunk for the obstack *H
239*946379e7Schristos on the assumption that LENGTH bytes need to be added
240*946379e7Schristos to the current object, or a new object of length LENGTH allocated.
241*946379e7Schristos Copies any partial object from the end of the old chunk
242*946379e7Schristos to the beginning of the new one. */
243*946379e7Schristos
244*946379e7Schristos void
_obstack_newchunk(struct obstack * h,int length)245*946379e7Schristos _obstack_newchunk (struct obstack *h, int length)
246*946379e7Schristos {
247*946379e7Schristos register struct _obstack_chunk *old_chunk = h->chunk;
248*946379e7Schristos register struct _obstack_chunk *new_chunk;
249*946379e7Schristos register long new_size;
250*946379e7Schristos register long obj_size = h->next_free - h->object_base;
251*946379e7Schristos register long i;
252*946379e7Schristos long already;
253*946379e7Schristos char *object_base;
254*946379e7Schristos
255*946379e7Schristos /* Compute size for new chunk. */
256*946379e7Schristos new_size = (obj_size + length) + (obj_size >> 3) + h->alignment_mask + 100;
257*946379e7Schristos if (new_size < h->chunk_size)
258*946379e7Schristos new_size = h->chunk_size;
259*946379e7Schristos
260*946379e7Schristos /* Allocate and initialize the new chunk. */
261*946379e7Schristos new_chunk = CALL_CHUNKFUN (h, new_size);
262*946379e7Schristos if (!new_chunk)
263*946379e7Schristos (*obstack_alloc_failed_handler) ();
264*946379e7Schristos h->chunk = new_chunk;
265*946379e7Schristos new_chunk->prev = old_chunk;
266*946379e7Schristos new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
267*946379e7Schristos
268*946379e7Schristos /* Compute an aligned object_base in the new chunk */
269*946379e7Schristos object_base =
270*946379e7Schristos __PTR_ALIGN ((char *) new_chunk, new_chunk->contents, h->alignment_mask);
271*946379e7Schristos
272*946379e7Schristos /* Move the existing object to the new chunk.
273*946379e7Schristos Word at a time is fast and is safe if the object
274*946379e7Schristos is sufficiently aligned. */
275*946379e7Schristos if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
276*946379e7Schristos {
277*946379e7Schristos for (i = obj_size / sizeof (COPYING_UNIT) - 1;
278*946379e7Schristos i >= 0; i--)
279*946379e7Schristos ((COPYING_UNIT *)object_base)[i]
280*946379e7Schristos = ((COPYING_UNIT *)h->object_base)[i];
281*946379e7Schristos /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
282*946379e7Schristos but that can cross a page boundary on a machine
283*946379e7Schristos which does not do strict alignment for COPYING_UNITS. */
284*946379e7Schristos already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
285*946379e7Schristos }
286*946379e7Schristos else
287*946379e7Schristos already = 0;
288*946379e7Schristos /* Copy remaining bytes one by one. */
289*946379e7Schristos for (i = already; i < obj_size; i++)
290*946379e7Schristos object_base[i] = h->object_base[i];
291*946379e7Schristos
292*946379e7Schristos /* If the object just copied was the only data in OLD_CHUNK,
293*946379e7Schristos free that chunk and remove it from the chain.
294*946379e7Schristos But not if that chunk might contain an empty object. */
295*946379e7Schristos if (! h->maybe_empty_object
296*946379e7Schristos && (h->object_base
297*946379e7Schristos == __PTR_ALIGN ((char *) old_chunk, old_chunk->contents,
298*946379e7Schristos h->alignment_mask)))
299*946379e7Schristos {
300*946379e7Schristos new_chunk->prev = old_chunk->prev;
301*946379e7Schristos CALL_FREEFUN (h, old_chunk);
302*946379e7Schristos }
303*946379e7Schristos
304*946379e7Schristos h->object_base = object_base;
305*946379e7Schristos h->next_free = h->object_base + obj_size;
306*946379e7Schristos /* The new chunk certainly contains no empty object yet. */
307*946379e7Schristos h->maybe_empty_object = 0;
308*946379e7Schristos }
309*946379e7Schristos # ifdef _LIBC
310*946379e7Schristos libc_hidden_def (_obstack_newchunk)
311*946379e7Schristos # endif
312*946379e7Schristos
313*946379e7Schristos /* Return nonzero if object OBJ has been allocated from obstack H.
314*946379e7Schristos This is here for debugging.
315*946379e7Schristos If you use it in a program, you are probably losing. */
316*946379e7Schristos
317*946379e7Schristos /* Suppress -Wmissing-prototypes warning. We don't want to declare this in
318*946379e7Schristos obstack.h because it is just for debugging. */
319*946379e7Schristos int _obstack_allocated_p (struct obstack *h, void *obj);
320*946379e7Schristos
321*946379e7Schristos int
_obstack_allocated_p(struct obstack * h,void * obj)322*946379e7Schristos _obstack_allocated_p (struct obstack *h, void *obj)
323*946379e7Schristos {
324*946379e7Schristos register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
325*946379e7Schristos register struct _obstack_chunk *plp; /* point to previous chunk if any */
326*946379e7Schristos
327*946379e7Schristos lp = (h)->chunk;
328*946379e7Schristos /* We use >= rather than > since the object cannot be exactly at
329*946379e7Schristos the beginning of the chunk but might be an empty object exactly
330*946379e7Schristos at the end of an adjacent chunk. */
331*946379e7Schristos while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj))
332*946379e7Schristos {
333*946379e7Schristos plp = lp->prev;
334*946379e7Schristos lp = plp;
335*946379e7Schristos }
336*946379e7Schristos return lp != 0;
337*946379e7Schristos }
338*946379e7Schristos
339*946379e7Schristos /* Free objects in obstack H, including OBJ and everything allocate
340*946379e7Schristos more recently than OBJ. If OBJ is zero, free everything in H. */
341*946379e7Schristos
342*946379e7Schristos # undef obstack_free
343*946379e7Schristos
344*946379e7Schristos void
__obstack_free(struct obstack * h,void * obj)345*946379e7Schristos __obstack_free (struct obstack *h, void *obj)
346*946379e7Schristos {
347*946379e7Schristos register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
348*946379e7Schristos register struct _obstack_chunk *plp; /* point to previous chunk if any */
349*946379e7Schristos
350*946379e7Schristos lp = h->chunk;
351*946379e7Schristos /* We use >= because there cannot be an object at the beginning of a chunk.
352*946379e7Schristos But there can be an empty object at that address
353*946379e7Schristos at the end of another chunk. */
354*946379e7Schristos while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj))
355*946379e7Schristos {
356*946379e7Schristos plp = lp->prev;
357*946379e7Schristos CALL_FREEFUN (h, lp);
358*946379e7Schristos lp = plp;
359*946379e7Schristos /* If we switch chunks, we can't tell whether the new current
360*946379e7Schristos chunk contains an empty object, so assume that it may. */
361*946379e7Schristos h->maybe_empty_object = 1;
362*946379e7Schristos }
363*946379e7Schristos if (lp)
364*946379e7Schristos {
365*946379e7Schristos h->object_base = h->next_free = (char *) (obj);
366*946379e7Schristos h->chunk_limit = lp->limit;
367*946379e7Schristos h->chunk = lp;
368*946379e7Schristos }
369*946379e7Schristos else if (obj != 0)
370*946379e7Schristos /* obj is not in any of the chunks! */
371*946379e7Schristos abort ();
372*946379e7Schristos }
373*946379e7Schristos
374*946379e7Schristos # ifdef _LIBC
375*946379e7Schristos /* Older versions of libc used a function _obstack_free intended to be
376*946379e7Schristos called by non-GCC compilers. */
strong_alias(obstack_free,_obstack_free)377*946379e7Schristos strong_alias (obstack_free, _obstack_free)
378*946379e7Schristos # endif
379*946379e7Schristos
380*946379e7Schristos int
381*946379e7Schristos _obstack_memory_used (struct obstack *h)
382*946379e7Schristos {
383*946379e7Schristos register struct _obstack_chunk* lp;
384*946379e7Schristos register int nbytes = 0;
385*946379e7Schristos
386*946379e7Schristos for (lp = h->chunk; lp != 0; lp = lp->prev)
387*946379e7Schristos {
388*946379e7Schristos nbytes += lp->limit - (char *) lp;
389*946379e7Schristos }
390*946379e7Schristos return nbytes;
391*946379e7Schristos }
392*946379e7Schristos
393*946379e7Schristos /* Define the error handler. */
394*946379e7Schristos # ifdef _LIBC
395*946379e7Schristos # include <libintl.h>
396*946379e7Schristos # else
397*946379e7Schristos # include "gettext.h"
398*946379e7Schristos # endif
399*946379e7Schristos # ifndef _
400*946379e7Schristos # define _(msgid) gettext (msgid)
401*946379e7Schristos # endif
402*946379e7Schristos
403*946379e7Schristos # ifdef _LIBC
404*946379e7Schristos # include <libio/iolibio.h>
405*946379e7Schristos # endif
406*946379e7Schristos
407*946379e7Schristos # ifndef __attribute__
408*946379e7Schristos /* This feature is available in gcc versions 2.5 and later. */
409*946379e7Schristos # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
410*946379e7Schristos # define __attribute__(Spec) /* empty */
411*946379e7Schristos # endif
412*946379e7Schristos # endif
413*946379e7Schristos
414*946379e7Schristos static void
415*946379e7Schristos __attribute__ ((noreturn))
print_and_abort(void)416*946379e7Schristos print_and_abort (void)
417*946379e7Schristos {
418*946379e7Schristos /* Don't change any of these strings. Yes, it would be possible to add
419*946379e7Schristos the newline to the string and use fputs or so. But this must not
420*946379e7Schristos happen because the "memory exhausted" message appears in other places
421*946379e7Schristos like this and the translation should be reused instead of creating
422*946379e7Schristos a very similar string which requires a separate translation. */
423*946379e7Schristos # ifdef _LIBC
424*946379e7Schristos (void) __fxprintf (NULL, "%s\n", _("memory exhausted"));
425*946379e7Schristos # else
426*946379e7Schristos fprintf (stderr, "%s\n", _("memory exhausted"));
427*946379e7Schristos # endif
428*946379e7Schristos exit (obstack_exit_failure);
429*946379e7Schristos }
430*946379e7Schristos
431*946379e7Schristos #endif /* !ELIDE_CODE */
432