Subversion Repositories Kolibri OS

Rev

Rev 5191 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5191 Rev 6324
Line 1... Line 1...
1
/* obstack.h - object stack macros
1
/* obstack.h - object stack macros
2
   Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998,
2
   Copyright (C) 1988-2015 Free Software Foundation, Inc.
3
   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
-
 
4
   Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
Line -... Line 4...
-
 
4
 
-
 
5
   The GNU C Library is free software; you can redistribute it and/or
-
 
6
   modify it under the terms of the GNU Lesser General Public
-
 
7
   License as published by the Free Software Foundation; either
Line 5... Line -...
5
 
-
 
6
 
-
 
7
   NOTE: The canonical source of this file is maintained with the GNU C Library.
-
 
8
   Bugs can be reported to bug-glibc@gnu.org.
-
 
9
 
-
 
10
   This program is free software; you can redistribute it and/or modify it
-
 
11
   under the terms of the GNU General Public License as published by the
-
 
12
   Free Software Foundation; either version 2, or (at your option) any
-
 
13
   later version.
8
   version 2.1 of the License, or (at your option) any later version.
14
 
9
 
15
   This program is distributed in the hope that it will be useful,
10
   The GNU C Library is distributed in the hope that it will be useful,
16
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Line 17... Line 12...
17
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
   GNU General Public License for more details.
13
   Lesser General Public License for more details.
19
 
14
 
20
   You should have received a copy of the GNU General Public License
-
 
Line 21... Line 15...
21
   along with this program; if not, write to the Free Software
15
   You should have received a copy of the GNU Lesser General Public
Line 22... Line 16...
22
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
16
   License along with the GNU C Library; if not, see
23
   USA.  */
17
   .  */
Line 36... Line 30...
36
been "finished" it never changes address again.  So the "top of the
30
   been "finished" it never changes address again.  So the "top of the
37
stack" is typically an immature growing object, while the rest of the
31
   stack" is typically an immature growing object, while the rest of the
38
stack is of mature, fixed size and fixed address objects.
32
   stack is of mature, fixed size and fixed address objects.
Line 39... Line 33...
39
 
33
 
40
These routines grab large chunks of memory, using a function you
34
   These routines grab large chunks of memory, using a function you
41
supply, called `obstack_chunk_alloc'.  On occasion, they free chunks,
35
   supply, called 'obstack_chunk_alloc'.  On occasion, they free chunks,
42
by calling `obstack_chunk_free'.  You must define them and declare
36
   by calling 'obstack_chunk_free'.  You must define them and declare
Line 43... Line 37...
43
them before using any obstack macros.
37
   them before using any obstack macros.
44
 
38
 
45
Each independent stack is represented by a `struct obstack'.
39
   Each independent stack is represented by a 'struct obstack'.
Line 46... Line 40...
46
Each of the obstack macros expects a pointer to such a structure
40
   Each of the obstack macros expects a pointer to such a structure
47
as the first argument.
41
   as the first argument.
Line 97... Line 91...
97
	We are free to append data of any size to the currently
91
        We are free to append data of any size to the currently
98
	  growing object.
92
          growing object.
99
	Exactly one object is growing in an obstack at any one time.
93
        Exactly one object is growing in an obstack at any one time.
100
	You can run one obstack per control block.
94
        You can run one obstack per control block.
101
	You may have as many control blocks as you dare.
95
        You may have as many control blocks as you dare.
102
	Because of the way we do it, you can `unwind' an obstack
96
        Because of the way we do it, you can "unwind" an obstack
103
	  back to a previous state. (You may remove objects much
97
          back to a previous state. (You may remove objects much
104
	  as you would with a stack.)
98
          as you would with a stack.)
105
*/
99
 */
Line 106... Line 100...
106
 
100
 
Line 107... Line 101...
107
 
101
 
108
/* Don't do the contents of this file more than once.  */
102
/* Don't do the contents of this file more than once.  */
Line 109... Line 103...
109
 
103
 
110
#ifndef _OBSTACK_H
104
#ifndef _OBSTACK_H
111
#define _OBSTACK_H 1
105
#define _OBSTACK_H 1
112
 
106
 
113
#ifdef __cplusplus
107
#ifndef _OBSTACK_INTERFACE_VERSION
114
extern "C" {
-
 
115
#endif
108
# define _OBSTACK_INTERFACE_VERSION 2
Line 116... Line 109...
116

109
#endif
-
 
110
 
-
 
111
#include              /* For size_t and ptrdiff_t.  */
-
 
112
#include              /* For __GNU_LIBRARY__, and memcpy.  */
-
 
113
 
117
/* We use subtraction of (char *) 0 instead of casting to int
114
#if _OBSTACK_INTERFACE_VERSION == 1
118
   because on word-addressable machines a simple cast to int
115
/* For binary compatibility with obstack version 1, which used "int"
119
   may ignore the byte-within-word field of the pointer.  */
-
 
-
 
116
   and "long" for these two types.  */
-
 
117
# define _OBSTACK_SIZE_T unsigned int
120
 
118
# define _CHUNK_SIZE_T unsigned long
121
#ifndef __PTR_TO_INT
119
# define _OBSTACK_CAST(type, expr) ((type) (expr))
122
# define __PTR_TO_INT(P) ((P) - (char *) 0)
120
#else
Line 123... Line 121...
123
#endif
121
/* Version 2 with sane types, especially for 64-bit hosts.  */
124
 
122
# define _OBSTACK_SIZE_T size_t
-
 
123
# define _CHUNK_SIZE_T size_t
-
 
124
# define _OBSTACK_CAST(type, expr) (expr)
-
 
125
#endif
-
 
126
 
-
 
127
/* If B is the base of an object addressed by P, return the result of
125
#ifndef __INT_TO_PTR
128
   aligning P to the next multiple of A + 1.  B and P must be of type
126
# define __INT_TO_PTR(P) ((P) + (char *) 0)
129
   char *.  A + 1 must be a power of 2.  */
-
 
130
 
-
 
131
#define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A)))
127
#endif
132
 
128
 
133
/* Similar to __BPTR_ALIGN (B, P, A), except optimize the common case
129
/* We need the type of the resulting object.  If __PTRDIFF_TYPE__ is
134
   where pointers can be converted to integers, aligned as integers,
-
 
135
   and converted back again.  If ptrdiff_t is narrower than a
130
   defined, as with GNU C, use that; that way we don't pollute the
136
   pointer (e.g., the AS/400), play it safe and compute the alignment
131
   namespace with 's symbols.  Otherwise, if  is
137
   relative to B.  Otherwise, use the faster strategy of computing the
132
   available, include it and use ptrdiff_t.  In traditional C, long is
138
   alignment relative to 0.  */
133
   the best that we can do.  */
139
 
134
 
140
#define __PTR_ALIGN(B, P, A)						      \
135
#ifdef __PTRDIFF_TYPE__
141
  __BPTR_ALIGN (sizeof (ptrdiff_t) < sizeof (void *) ? (B) : (char *) 0,      \
136
# define PTR_INT_TYPE __PTRDIFF_TYPE__
142
                P, A)
137
#else
143
 
138
# ifdef HAVE_STDDEF_H
144
#ifndef __attribute_pure__
Line 139... Line -...
139
#  include 
-
 
140
#  define PTR_INT_TYPE ptrdiff_t
-
 
141
# else
-
 
142
#  define PTR_INT_TYPE long
-
 
143
# endif
145
# if defined __GNUC_MINOR__ && __GNUC__ * 1000 + __GNUC_MINOR__ >= 2096
144
#endif
-
 
145
 
-
 
146
#if defined _LIBC || defined HAVE_STRING_H
-
 
147
# include 
146
#  define __attribute_pure__ __attribute__ ((__pure__))
148
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
147
# else
Line 149... Line 148...
149
#else
148
#  define __attribute_pure__
150
# ifdef memcpy
149
# endif
151
#  define _obstack_memcpy(To, From, N) memcpy ((To), (char *)(From), (N))
150
#endif
Line 161... Line 160...
161
  char	contents[4];		/* objects begin here */
160
  char contents[4];             /* objects begin here */
162
};
161
};
Line 163... Line 162...
163
 
162
 
164
struct obstack		/* control current object in current chunk */
163
struct obstack          /* control current object in current chunk */
165
{
164
{
166
  long	chunk_size;		/* preferred size to allocate chunks in */
165
  _CHUNK_SIZE_T chunk_size;     /* preferred size to allocate chunks in */
167
  struct _obstack_chunk *chunk;	/* address of current struct obstack_chunk */
166
  struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */
168
  char	*object_base;		/* address of object we are building */
167
  char *object_base;            /* address of object we are building */
169
  char	*next_free;		/* where to add next char to current object */
168
  char *next_free;              /* where to add next char to current object */
-
 
169
  char *chunk_limit;            /* address of char after current chunk */
-
 
170
  union
-
 
171
  {
-
 
172
    _OBSTACK_SIZE_T i;
170
  char	*chunk_limit;		/* address of char after current chunk */
173
    void *p;
171
  PTR_INT_TYPE temp;		/* Temporary for some macros.  */
174
  } temp;                       /* Temporary for some macros.  */
-
 
175
  _OBSTACK_SIZE_T alignment_mask;  /* Mask of alignment for each object. */
172
  int   alignment_mask;		/* Mask of alignment for each object. */
176
 
-
 
177
  /* These prototypes vary based on 'use_extra_arg'.  */
-
 
178
  union
173
  /* These prototypes vary based on `use_extra_arg', and we use
179
  {
174
     casts to the prototypeless function type in all assignments,
180
    void *(*plain) (size_t);
-
 
181
    void *(*extra) (void *, size_t);
-
 
182
  } chunkfun;
-
 
183
  union
175
     but having prototypes here quiets -Wstrict-prototypes.  */
184
  {
176
  struct _obstack_chunk *(*chunkfun) (void *, long);
185
    void (*plain) (void *);
-
 
186
    void (*extra) (void *, void *);
-
 
187
  } freefun;
177
  void (*freefun) (void *, struct _obstack_chunk *);
188
 
178
  void *extra_arg;		/* first arg for chunk alloc/dealloc funcs */
189
  void *extra_arg;              /* first arg for chunk alloc/dealloc funcs */
179
  unsigned use_extra_arg:1;	/* chunk alloc/dealloc funcs take extra arg */
190
  unsigned use_extra_arg : 1;     /* chunk alloc/dealloc funcs take extra arg */
180
  unsigned maybe_empty_object:1;/* There is a possibility that the current
191
  unsigned maybe_empty_object : 1; /* There is a possibility that the current
181
				   chunk contains a zero-length object.  This
192
                                      chunk contains a zero-length object.  This
Line 186... Line 197...
186
				   compatibility.  */
197
                                     compatibility.  */
187
};
198
};
Line 188... Line 199...
188
 
199
 
Line 189... Line 200...
189
/* Declare the external functions we use; they are in obstack.c.  */
200
/* Declare the external functions we use; they are in obstack.c.  */
190
 
201
 
191
extern void _obstack_newchunk (struct obstack *, int);
202
extern void _obstack_newchunk (struct obstack *, _OBSTACK_SIZE_T);
-
 
203
extern void _obstack_free (struct obstack *, void *);
192
extern void _obstack_free (struct obstack *, void *);
204
extern int _obstack_begin (struct obstack *,
193
extern int _obstack_begin (struct obstack *, int, int,
205
                           _OBSTACK_SIZE_T, _OBSTACK_SIZE_T,
-
 
206
                           void *(*) (size_t), void (*) (void *));
194
			    void *(*) (long), void (*) (void *));
207
extern int _obstack_begin_1 (struct obstack *,
195
extern int _obstack_begin_1 (struct obstack *, int, int,
208
                             _OBSTACK_SIZE_T, _OBSTACK_SIZE_T,
196
			     void *(*) (void *, long),
209
                             void *(*) (void *, size_t),
197
			     void (*) (void *, void *), void *);
-
 
198
extern int _obstack_memory_used (struct obstack *);
-
 
199

210
                             void (*) (void *, void *), void *);
200
/* Do the function-declarations after the structs
-
 
201
   but before defining the macros.  */
-
 
202
 
-
 
203
void obstack_init (struct obstack *obstack);
-
 
204
 
-
 
205
void * obstack_alloc (struct obstack *obstack, int size);
-
 
206
 
-
 
207
void * obstack_copy (struct obstack *obstack, void *address, int size);
-
 
208
void * obstack_copy0 (struct obstack *obstack, void *address, int size);
-
 
209
 
-
 
210
void obstack_free (struct obstack *obstack, void *block);
-
 
211
 
-
 
212
void obstack_blank (struct obstack *obstack, int size);
-
 
213
 
-
 
214
void obstack_grow (struct obstack *obstack, void *data, int size);
-
 
215
void obstack_grow0 (struct obstack *obstack, void *data, int size);
-
 
216
 
-
 
217
void obstack_1grow (struct obstack *obstack, int data_char);
-
 
Line 218... Line -...
218
void obstack_ptr_grow (struct obstack *obstack, void *data);
-
 
Line 219... Line -...
219
void obstack_int_grow (struct obstack *obstack, int data);
-
 
220
 
-
 
221
void * obstack_finish (struct obstack *obstack);
-
 
222
 
-
 
223
int obstack_object_size (struct obstack *obstack);
-
 
224
 
-
 
225
int obstack_room (struct obstack *obstack);
-
 
226
void obstack_make_room (struct obstack *obstack, int size);
-
 
227
void obstack_1grow_fast (struct obstack *obstack, int data_char);
-
 
228
void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
-
 
229
void obstack_int_grow_fast (struct obstack *obstack, int data);
-
 
230
void obstack_blank_fast (struct obstack *obstack, int size);
-
 
231
 
-
 
232
void * obstack_base (struct obstack *obstack);
-
 
233
void * obstack_next_free (struct obstack *obstack);
-
 
234
int obstack_alignment_mask (struct obstack *obstack);
211
extern _OBSTACK_SIZE_T _obstack_memory_used (struct obstack *)
235
int obstack_chunk_size (struct obstack *obstack);
212
  __attribute_pure__;
-
 
213
 
236
int obstack_memory_used (struct obstack *obstack);
214
 
237
 
215
/* Error handler called when 'obstack_chunk_alloc' failed to allocate
Line 238... Line 216...
238
/* Error handler called when `obstack_chunk_alloc' failed to allocate
216
   more memory.  This can be set to a user defined function which
239
   more memory.  This can be set to a user defined function.  The
217
   should either abort gracefully or use longjump - but shouldn't
240
   default action is to print a message and abort.  */
218
   return.  The default action is to print a message and abort.  */
241
extern void (*obstack_alloc_failed_handler) (void);
219
extern void (*obstack_alloc_failed_handler) (void);
242
 
220
 
243
/* Exit value used when `print_and_abort' is used.  */
221
/* Exit value used when 'print_and_abort' is used.  */
Line 244... Line 222...
244
extern int obstack_exit_failure;
222
extern int obstack_exit_failure;
Line 245... Line 223...
245

223
 
Line 246... Line 224...
246
/* Pointer to beginning of object being allocated or to be allocated next.
224
/* Pointer to beginning of object being allocated or to be allocated next.
Line 247... Line 225...
247
   Note that this might not be the final address of the object
225
   Note that this might not be the final address of the object
Line 248... Line 226...
248
   because a new chunk might be needed to hold the final size.  */
226
   because a new chunk might be needed to hold the final size.  */
Line 249... Line 227...
249
 
227
 
Line 250... Line 228...
250
#define obstack_base(h) ((h)->object_base)
228
#define obstack_base(h) ((void *) (h)->object_base)
Line 251... Line 229...
251
 
229
 
252
/* Size for allocating ordinary chunks.  */
-
 
253
 
230
/* Size for allocating ordinary chunks.  */
254
#define obstack_chunk_size(h) ((h)->chunk_size)
231
 
-
 
232
#define obstack_chunk_size(h) ((h)->chunk_size)
255
 
233
 
Line 256... Line 234...
256
/* Pointer to next byte not yet allocated in current chunk.  */
234
/* Pointer to next byte not yet allocated in current chunk.  */
257
 
235
 
-
 
236
#define obstack_next_free(h) ((void *) (h)->next_free)
258
#define obstack_next_free(h)	((h)->next_free)
237
 
Line 259... Line 238...
259
 
238
/* Mask specifying low bits that should be clear in address of an object.  */
260
/* Mask specifying low bits that should be clear in address of an object.  */
239
 
-
 
240
#define obstack_alignment_mask(h) ((h)->alignment_mask)
261
 
241
 
Line 262... Line 242...
262
#define obstack_alignment_mask(h) ((h)->alignment_mask)
242
/* To prevent prototype warnings provide complete argument list.  */
263
 
243
#define obstack_init(h)							      \
264
/* To prevent prototype warnings provide complete argument list in
244
  _obstack_begin ((h), 0, 0,						      \
265
   standard C version.  */
245
                  _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc),    \
Line 266... Line 246...
266
# define obstack_init(h) \
246
                  _OBSTACK_CAST (void (*) (void *), obstack_chunk_free))
267
  _obstack_begin ((h), 0, 0, \
247
 
Line 268... Line 248...
268
		  (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
248
#define obstack_begin(h, size)						      \
269
 
249
  _obstack_begin ((h), (size), 0,					      \
Line 270... Line 250...
270
# define obstack_begin(h, size) \
250
                  _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc), \
Line 271... Line 251...
271
  _obstack_begin ((h), (size), 0, \
251
                  _OBSTACK_CAST (void (*) (void *), obstack_chunk_free))
Line 272... Line 252...
272
		  (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
252
 
273
 
253
#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun)     \
274
# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
254
  _obstack_begin ((h), (size), (alignment),				      \
275
  _obstack_begin ((h), (size), (alignment), \
-
 
276
		    (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun))
-
 
277
 
-
 
278
# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
255
                  _OBSTACK_CAST (void *(*) (size_t), chunkfun),		      \
279
  _obstack_begin_1 ((h), (size), (alignment), \
256
                  _OBSTACK_CAST (void (*) (void *), freefun))
280
		    (void *(*) (void *, long)) (chunkfun), \
257
 
Line 281... Line 258...
281
		    (void (*) (void *, void *)) (freefun), (arg))
258
#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
282
 
259
  _obstack_begin_1 ((h), (size), (alignment),				      \
283
# define obstack_chunkfun(h, newchunkfun) \
260
                    _OBSTACK_CAST (void *(*) (void *, size_t), chunkfun),     \
284
  ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
261
                    _OBSTACK_CAST (void (*) (void *, void *), freefun), arg)
Line 285... Line 262...
285
 
262
 
286
# define obstack_freefun(h, newfreefun) \
263
#define obstack_chunkfun(h, newchunkfun)				      \
287
  ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
264
  ((void) ((h)->chunkfun.extra = (void *(*) (void *, size_t)) (newchunkfun)))
288
 
265
 
Line -... Line 266...
-
 
266
#define obstack_freefun(h, newfreefun)					      \
-
 
267
  ((void) ((h)->freefun.extra = (void *(*) (void *, void *)) (newfreefun)))
289
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar))
268
 
290
 
269
#define obstack_1grow_fast(h, achar) ((void) (*((h)->next_free)++ = (achar)))
291
#define obstack_blank_fast(h,n) ((h)->next_free += (n))
270
 
292
 
271
#define obstack_blank_fast(h, n) ((void) ((h)->next_free += (n)))
Line 293... Line 272...
293
#define obstack_memory_used(h) _obstack_memory_used (h)
272
 
294

273
#define obstack_memory_used(h) _obstack_memory_used (h)
295
#if defined __GNUC__ && defined __STDC__ && __STDC__
274
 
296
/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
275
#if defined __GNUC__
297
   does not implement __extension__.  But that compiler doesn't define
276
# if !defined __GNUC_MINOR__ || __GNUC__ * 1000 + __GNUC_MINOR__ < 2008
298
   __GNUC_MINOR__.  */
277
#  define __extension__
299
# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
278
# endif
Line 300... Line 279...
300
#  define __extension__
279
 
301
# endif
280
/* For GNU C, if not -traditional,
302
 
281
   we can define these macros to compute all args only once
-
 
282
   without using a global variable.
-
 
283
   Also, we can avoid using the 'temp' slot, to make faster code.  */
303
/* For GNU C, if not -traditional,
284
 
-
 
285
# define obstack_object_size(OBSTACK)					      \
Line 304... Line 286...
304
   we can define these macros to compute all args only once
286
  __extension__								      \
305
   without using a global variable.
287
    ({ struct obstack const *__o = (OBSTACK);				      \
306
   Also, we can avoid using the `temp' slot, to make faster code.  */
288
       (_OBSTACK_SIZE_T) (__o->next_free - __o->object_base); })
307
 
289
 
308
# define obstack_object_size(OBSTACK)					\
290
/* The local variable is named __o1 to avoid a shadowed variable
309
  __extension__								\
291
   warning when invoked from other obstack macros.  */
310
  ({ struct obstack *__o = (OBSTACK);					\
292
# define obstack_room(OBSTACK)						      \
311
     (unsigned) (__o->next_free - __o->object_base); })
293
  __extension__								      \
312
 
294
    ({ struct obstack const *__o1 = (OBSTACK);				      \
Line 313... Line 295...
313
# define obstack_room(OBSTACK)						\
295
       (_OBSTACK_SIZE_T) (__o1->chunk_limit - __o1->next_free); })
314
  __extension__								\
296
 
315
  ({ struct obstack *__o = (OBSTACK);					\
297
# define obstack_make_room(OBSTACK, length)				      \
316
     (unsigned) (__o->chunk_limit - __o->next_free); })
298
  __extension__								      \
317
 
299
    ({ struct obstack *__o = (OBSTACK);					      \
318
# define obstack_make_room(OBSTACK,length)				\
300
       _OBSTACK_SIZE_T __len = (length);				      \
319
__extension__								\
301
       if (obstack_room (__o) < __len)					      \
320
({ struct obstack *__o = (OBSTACK);					\
302
         _obstack_newchunk (__o, __len);				      \
321
   int __len = (length);						\
303
       (void) 0; })
322
   if (__o->chunk_limit - __o->next_free < __len)			\
304
 
Line 323... Line 305...
323
     _obstack_newchunk (__o, __len);					\
305
# define obstack_empty_p(OBSTACK)					      \
324
   (void) 0; })
306
  __extension__								      \
325
 
307
    ({ struct obstack const *__o = (OBSTACK);				      \
326
# define obstack_empty_p(OBSTACK)					\
308
       (__o->chunk->prev == 0						      \
327
  __extension__								\
309
        && __o->next_free == __PTR_ALIGN ((char *) __o->chunk,		      \
328
  ({ struct obstack *__o = (OBSTACK);					\
310
                                          __o->chunk->contents,		      \
329
     (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
-
 
Line 330... Line 311...
330
 
311
                                          __o->alignment_mask)); })
331
# define obstack_grow(OBSTACK,where,length)				\
312
 
332
__extension__								\
313
# define obstack_grow(OBSTACK, where, length)				      \
Line 333... Line 314...
333
({ struct obstack *__o = (OBSTACK);					\
314
  __extension__								      \
334
   int __len = (length);						\
315
    ({ struct obstack *__o = (OBSTACK);					      \
335
   if (__o->next_free + __len > __o->chunk_limit)			\
316
       _OBSTACK_SIZE_T __len = (length);				      \
336
     _obstack_newchunk (__o, __len);					\
317
       if (obstack_room (__o) < __len)					      \
337
   _obstack_memcpy (__o->next_free, (where), __len);			\
318
         _obstack_newchunk (__o, __len);				      \
338
   __o->next_free += __len;						\
319
       memcpy (__o->next_free, where, __len);				      \
Line 339... Line 320...
339
   (void) 0; })
320
       __o->next_free += __len;						      \
340
 
321
       (void) 0; })
341
# define obstack_grow0(OBSTACK,where,length)				\
322
 
342
__extension__								\
323
# define obstack_grow0(OBSTACK, where, length)				      \
343
({ struct obstack *__o = (OBSTACK);					\
324
  __extension__								      \
344
   int __len = (length);						\
325
    ({ struct obstack *__o = (OBSTACK);					      \
Line 345... Line 326...
345
   if (__o->next_free + __len + 1 > __o->chunk_limit)			\
326
       _OBSTACK_SIZE_T __len = (length);				      \
346
     _obstack_newchunk (__o, __len + 1);				\
327
       if (obstack_room (__o) < __len + 1)				      \
347
   _obstack_memcpy (__o->next_free, (where), __len);			\
328
         _obstack_newchunk (__o, __len + 1);				      \
-
 
329
       memcpy (__o->next_free, where, __len);				      \
348
   __o->next_free += __len;						\
330
       __o->next_free += __len;						      \
349
   *(__o->next_free)++ = 0;						\
331
       *(__o->next_free)++ = 0;						      \
350
   (void) 0; })
332
       (void) 0; })
Line 351... Line 333...
351
 
333
 
352
# define obstack_1grow(OBSTACK,datum)					\
334
# define obstack_1grow(OBSTACK, datum)					      \
353
__extension__								\
335
  __extension__								      \
-
 
336
    ({ struct obstack *__o = (OBSTACK);					      \
354
({ struct obstack *__o = (OBSTACK);					\
337
       if (obstack_room (__o) < 1)					      \
355
   if (__o->next_free + 1 > __o->chunk_limit)				\
338
         _obstack_newchunk (__o, 1);					      \
356
     _obstack_newchunk (__o, 1);					\
339
       obstack_1grow_fast (__o, datum); })
Line 357... Line 340...
357
   obstack_1grow_fast (__o, datum);					\
340
 
358
   (void) 0; })
341
/* These assume that the obstack alignment is good enough for pointers
359
 
342
   or ints, and that the data added so far to the current object
360
/* These assume that the obstack alignment is good enough for pointers or ints,
343
   shares that much alignment.  */
361
   and that the data added so far to the current object
344
 
362
   shares that much alignment.  */
345
# define obstack_ptr_grow(OBSTACK, datum)				      \
363
 
346
  __extension__								      \
364
# define obstack_ptr_grow(OBSTACK,datum)				\
-
 
Line 365... Line 347...
365
__extension__								\
347
    ({ struct obstack *__o = (OBSTACK);					      \
366
({ struct obstack *__o = (OBSTACK);					\
348
       if (obstack_room (__o) < sizeof (void *))			      \
367
   if (__o->next_free + sizeof (void *) > __o->chunk_limit)		\
349
         _obstack_newchunk (__o, sizeof (void *));			      \
368
     _obstack_newchunk (__o, sizeof (void *));				\
350
       obstack_ptr_grow_fast (__o, datum); })
Line 414... Line 396...
414
__extension__								\
396
  __extension__								      \
415
({ struct obstack *__h = (OBSTACK);					\
397
    ({ struct obstack *__h = (OBSTACK);					      \
416
   obstack_grow0 (__h, (where), (length));				\
398
       obstack_grow0 (__h, (where), (length));				      \
417
   obstack_finish (__h); })
399
       obstack_finish (__h); })
Line 418... Line 400...
418
 
400
 
419
/* The local variable is named __o1 to avoid a name conflict
401
/* The local variable is named __o1 to avoid a shadowed variable
420
   when obstack_blank is called.  */
402
   warning when invoked from other obstack macros, typically obstack_free.  */
421
# define obstack_finish(OBSTACK)  					\
403
# define obstack_finish(OBSTACK)					      \
422
__extension__								\
404
  __extension__								      \
423
({ struct obstack *__o1 = (OBSTACK);					\
-
 
424
   void *value;								\
405
    ({ struct obstack *__o1 = (OBSTACK);				      \
425
   value = (void *) __o1->object_base;					\
406
       void *__value = (void *) __o1->object_base;			      \
426
   if (__o1->next_free == value)					\
407
       if (__o1->next_free == __value)					      \
427
     __o1->maybe_empty_object = 1;					\
408
         __o1->maybe_empty_object = 1;					      \
428
   __o1->next_free							\
409
       __o1->next_free							      \
429
     = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
410
         = __PTR_ALIGN (__o1->object_base, __o1->next_free,		      \
430
		     & ~ (__o1->alignment_mask));			\
411
                        __o1->alignment_mask);				      \
431
   if (__o1->next_free - (char *)__o1->chunk				\
412
       if ((size_t) (__o1->next_free - (char *) __o1->chunk)		      \
432
       > __o1->chunk_limit - (char *)__o1->chunk)			\
413
           > (size_t) (__o1->chunk_limit - (char *) __o1->chunk))	      \
433
     __o1->next_free = __o1->chunk_limit;				\
414
         __o1->next_free = __o1->chunk_limit;				      \
434
   __o1->object_base = __o1->next_free;					\
415
       __o1->object_base = __o1->next_free;				      \
Line 435... Line 416...
435
   value; })
416
       __value; })
436
 
417
 
437
# define obstack_free(OBSTACK, OBJ)					\
418
# define obstack_free(OBSTACK, OBJ)					      \
438
__extension__								\
419
  __extension__								      \
439
({ struct obstack *__o = (OBSTACK);					\
420
    ({ struct obstack *__o = (OBSTACK);					      \
440
   void *__obj = (void *) (OBJ);					\
421
       void *__obj = (void *) (OBJ);					      \
-
 
422
       if (__obj > (void *) __o->chunk && __obj < (void *) __o->chunk_limit)  \
441
   if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit)  \
423
         __o->next_free = __o->object_base = (char *) __obj;		      \
442
     __o->next_free = __o->object_base = (char *) __obj;		\
424
       else								      \
443
   else (obstack_free) (__o, __obj); })
425
         _obstack_free (__o, __obj); })
Line 444... Line 426...
444

426
 
445
#else /* not __GNUC__ or not __STDC__ */
427
#else /* not __GNUC__ */
Line 446... Line 428...
446
 
428
 
447
# define obstack_object_size(h) \
429
# define obstack_object_size(h)						      \
Line 448... Line 430...
448
 (unsigned) ((h)->next_free - (h)->object_base)
430
  ((_OBSTACK_SIZE_T) ((h)->next_free - (h)->object_base))
-
 
431
 
-
 
432
# define obstack_room(h)						      \
449
 
433
  ((_OBSTACK_SIZE_T) ((h)->chunk_limit - (h)->next_free))
-
 
434
 
Line 450... Line 435...
450
# define obstack_room(h)		\
435
# define obstack_empty_p(h)						      \
451
 (unsigned) ((h)->chunk_limit - (h)->next_free)
436
  ((h)->chunk->prev == 0						      \
452
 
437
   && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk,		      \
453
# define obstack_empty_p(h) \
438
                                     (h)->chunk->contents,		      \
454
 ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
439
                                     (h)->alignment_mask))
Line 455... Line 440...
455
 
440
 
456
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
441
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
457
   so that we can avoid having void expressions
442
   so that we can avoid having void expressions
458
   in the arms of the conditional expression.
443
   in the arms of the conditional expression.
-
 
444
   Casting the third operand to void was tried before,
Line 459... Line 445...
459
   Casting the third operand to void was tried before,
445
   but some compilers won't accept it.  */
460
   but some compilers won't accept it.  */
446
 
461
 
447
# define obstack_make_room(h, length)					      \
462
# define obstack_make_room(h,length)					\
448
  ((h)->temp.i = (length),						      \
463
( (h)->temp = (length),							\
449
   ((obstack_room (h) < (h)->temp.i)					      \
464
  (((h)->next_free + (h)->temp > (h)->chunk_limit)			\
450
    ? (_obstack_newchunk (h, (h)->temp.i), 0) : 0),			      \
-
 
451
   (void) 0)
Line 465... Line 452...
465
   ? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
452
 
466
 
453
# define obstack_grow(h, where, length)					      \
467
# define obstack_grow(h,where,length)					\
454
  ((h)->temp.i = (length),						      \
468
( (h)->temp = (length),							\
455
   ((obstack_room (h) < (h)->temp.i)					      \
469
  (((h)->next_free + (h)->temp > (h)->chunk_limit)			\
456
   ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0),			      \
470
   ? (_obstack_newchunk ((h), (h)->temp), 0) : 0),			\
457
   memcpy ((h)->next_free, where, (h)->temp.i),				      \
471
  _obstack_memcpy ((h)->next_free, (where), (h)->temp),			\
458
   (h)->next_free += (h)->temp.i,					      \
-
 
459
   (void) 0)
Line 472... Line 460...
472
  (h)->next_free += (h)->temp)
460
 
473
 
461
# define obstack_grow0(h, where, length)				      \
474
# define obstack_grow0(h,where,length)					\
462
  ((h)->temp.i = (length),						      \
475
( (h)->temp = (length),							\
463
   ((obstack_room (h) < (h)->temp.i + 1)				      \
Line 476... Line 464...
476
  (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit)			\
464
   ? (_obstack_newchunk ((h), (h)->temp.i + 1), 0) : 0),		      \
477
   ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0),			\
465
   memcpy ((h)->next_free, where, (h)->temp.i),				      \
478
  _obstack_memcpy ((h)->next_free, (where), (h)->temp),			\
466
   (h)->next_free += (h)->temp.i,					      \
479
  (h)->next_free += (h)->temp,						\
467
   *((h)->next_free)++ = 0,						      \
Line 480... Line 468...
480
  *((h)->next_free)++ = 0)
468
   (void) 0)
481
 
469
 
482
# define obstack_1grow(h,datum)						\
470
# define obstack_1grow(h, datum)					      \
483
( (((h)->next_free + 1 > (h)->chunk_limit)				\
471
  (((obstack_room (h) < 1)						      \
Line 484... Line 472...
484
   ? (_obstack_newchunk ((h), 1), 0) : 0),				\
472
    ? (_obstack_newchunk ((h), 1), 0) : 0),				      \
485
  obstack_1grow_fast (h, datum))
473
   obstack_1grow_fast (h, datum))
-
 
474
 
Line 486... Line 475...
486
 
475
# define obstack_ptr_grow(h, datum)					      \
487
# define obstack_ptr_grow(h,datum)					\
476
  (((obstack_room (h) < sizeof (char *))				      \
-
 
477
    ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0),		      \
Line 488... Line 478...
488
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit)		\
478
   obstack_ptr_grow_fast (h, datum))
489
   ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0),		\
479
 
490
  obstack_ptr_grow_fast (h, datum))
480
# define obstack_int_grow(h, datum)					      \
491
 
481
  (((obstack_room (h) < sizeof (int))					      \
492
# define obstack_int_grow(h,datum)					\
482
    ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0),			      \
Line 493... Line 483...
493
( (((h)->next_free + sizeof (int) > (h)->chunk_limit)			\
483
   obstack_int_grow_fast (h, datum))
494
   ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0),			\
484
 
Line 495... Line 485...
495
  obstack_int_grow_fast (h, datum))
485
# define obstack_ptr_grow_fast(h, aptr)					      \
Line 517... Line 507...
517
 
507
 
518
# define obstack_finish(h)  						\
508
# define obstack_finish(h)						      \
519
( ((h)->next_free == (h)->object_base					\
509
  (((h)->next_free == (h)->object_base					      \
520
   ? (((h)->maybe_empty_object = 1), 0)					\
510
    ? (((h)->maybe_empty_object = 1), 0)				      \
521
   : 0),								\
511
    : 0),								      \
522
  (h)->temp = __PTR_TO_INT ((h)->object_base),				\
512
   (h)->temp.p = (h)->object_base,					      \
523
  (h)->next_free							\
513
   (h)->next_free							      \
524
    = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask)	\
514
     = __PTR_ALIGN ((h)->object_base, (h)->next_free,			      \
525
		    & ~ ((h)->alignment_mask)),				\
515
                    (h)->alignment_mask),				      \
526
  (((h)->next_free - (char *) (h)->chunk				\
516
   (((size_t) ((h)->next_free - (char *) (h)->chunk)			      \
527
    > (h)->chunk_limit - (char *) (h)->chunk)				\
517
     > (size_t) ((h)->chunk_limit - (char *) (h)->chunk))		      \
528
   ? ((h)->next_free = (h)->chunk_limit) : 0),				\
518
   ? ((h)->next_free = (h)->chunk_limit) : 0),				      \
529
  (h)->object_base = (h)->next_free,					\
519
   (h)->object_base = (h)->next_free,					      \
Line 530... Line 520...
530
  (void *) __INT_TO_PTR ((h)->temp))
520
   (h)->temp.p)
531
 
521
 
532
# define obstack_free(h,obj)						\
522
# define obstack_free(h, obj)						      \
533
( (h)->temp = (char *) (obj) - (char *) (h)->chunk,			\
523
  ((h)->temp.p = (void *) (obj),					      \
534
  (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
524
   (((h)->temp.p > (void *) (h)->chunk					      \
535
   ? (((h)->next_free = (h)->object_base				\
525
     && (h)->temp.p < (void *) (h)->chunk_limit)			      \
Line 536... Line 526...
536
	    = (h)->temp + (char *) (h)->chunk), 0)			\
526
    ? (void) ((h)->next_free = (h)->object_base = (char *) (h)->temp.p)       \
Line 537... Line 527...
537
   : ((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0)))
527
    : _obstack_free ((h), (h)->temp.p)))
538
 
528
 
539
#endif /* not __GNUC__ or not __STDC__ */
529
#endif /* not __GNUC__ */
Line 540... Line 530...
540
 
530