1 |
/* obstack.h - object stack macros |
/* obstack.h - object stack macros |
2 |
Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc. |
|
3 |
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, |
4 |
|
1998, 1999, 2002 Free Software Foundation, Inc. |
5 |
|
|
6 |
This file is part of the GNU C Library. Its master source is NOT part of |
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. |
the C library, however. The master source lives in /gd/gnu/lib. |
9 |
NOTE: The canonical source of this file is maintained with the GNU C Library. |
NOTE: The canonical source of this file is maintained with the GNU C Library. |
10 |
Bugs can be reported to bug-glibc@gnu.org. |
Bugs can be reported to bug-glibc@gnu.org. |
11 |
|
|
12 |
This program is free software; you can redistribute it and/or modify it |
This program is free software; you can redistribute it and/or modify |
13 |
under the terms of the GNU General Public License as published by the |
it under the terms of the GNU General Public License as published by |
14 |
Free Software Foundation; either version 2, or (at your option) any |
the Free Software Foundation; either version 2, or (at your option) |
15 |
later version. |
any later version. |
16 |
|
|
17 |
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
18 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 |
Library General Public License for more details. |
GNU General Public License for more details. |
21 |
|
|
22 |
You should have received a copy of the GNU Library General Public |
You should have received a copy of the GNU General Public License |
23 |
License along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software Foundation, |
24 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
|
USA. */ |
|
25 |
|
|
26 |
/* Summary: |
/* Summary: |
27 |
|
|
124 |
#endif |
#endif |
125 |
|
|
126 |
#ifndef __INT_TO_PTR |
#ifndef __INT_TO_PTR |
127 |
# define __INT_TO_PTR(P) ((P) + (char *) 0) |
# ifdef __STDC__ |
128 |
|
# define __INT_TO_PTR(P) ((void *) ((P) + (char *) 0)) |
129 |
|
# else |
130 |
|
# define __INT_TO_PTR(P) ((P) + (char *) 0) |
131 |
|
# endif |
132 |
#endif |
#endif |
133 |
|
|
134 |
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is |
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is |
175 |
char *chunk_limit; /* address of char after current chunk */ |
char *chunk_limit; /* address of char after current chunk */ |
176 |
PTR_INT_TYPE temp; /* Temporary for some macros. */ |
PTR_INT_TYPE temp; /* Temporary for some macros. */ |
177 |
int alignment_mask; /* Mask of alignment for each object. */ |
int alignment_mask; /* Mask of alignment for each object. */ |
178 |
#if defined __STDC__ && __STDC__ |
#if PROTOTYPES || (defined __STDC__ && __STDC__) |
179 |
/* These prototypes vary based on `use_extra_arg', and we use |
/* These prototypes vary based on `use_extra_arg', and we use |
180 |
casts to the prototypeless function type in all assignments, |
casts to the prototypeless function type in all assignments, |
181 |
but having prototypes here quiets -Wstrict-prototypes. */ |
but having prototypes here quiets -Wstrict-prototypes. */ |
199 |
|
|
200 |
/* Declare the external functions we use; they are in obstack.c. */ |
/* Declare the external functions we use; they are in obstack.c. */ |
201 |
|
|
202 |
#if defined __STDC__ && __STDC__ |
#if PROTOTYPES || (defined __STDC__ && __STDC__) |
203 |
extern void _obstack_newchunk (struct obstack *, int); |
extern void _obstack_newchunk (struct obstack *, int); |
204 |
extern void _obstack_free (struct obstack *, void *); |
extern void _obstack_free (struct obstack *, void *); |
205 |
extern int _obstack_begin (struct obstack *, int, int, |
extern int _obstack_begin (struct obstack *, int, int, |
216 |
extern int _obstack_memory_used (); |
extern int _obstack_memory_used (); |
217 |
#endif |
#endif |
218 |
|
|
219 |
#if defined __STDC__ && __STDC__ |
#if PROTOTYPES || (defined __STDC__ && __STDC__) |
220 |
|
|
221 |
/* Do the function-declarations after the structs |
/* Do the function-declarations after the structs |
222 |
but before defining the macros. */ |
but before defining the macros. */ |
256 |
int obstack_chunk_size (struct obstack *obstack); |
int obstack_chunk_size (struct obstack *obstack); |
257 |
int obstack_memory_used (struct obstack *obstack); |
int obstack_memory_used (struct obstack *obstack); |
258 |
|
|
259 |
#endif /* __STDC__ */ |
#endif /* PROTOTYPES || (defined __STDC__ && __STDC__) */ |
260 |
|
|
261 |
/* Non-ANSI C cannot really support alternative functions for these macros, |
/* Non-ANSI C cannot really support alternative functions for these macros, |
262 |
so we do not declare them. */ |
so we do not declare them. */ |
265 |
more memory. This can be set to a user defined function which |
more memory. This can be set to a user defined function which |
266 |
should either abort gracefully or use longjump - but shouldn't |
should either abort gracefully or use longjump - but shouldn't |
267 |
return. The default action is to print a message and abort. */ |
return. The default action is to print a message and abort. */ |
268 |
#if defined __STDC__ && __STDC__ |
#if PROTOTYPES || (defined __STDC__ && __STDC__) |
269 |
extern void (*obstack_alloc_failed_handler) (void); |
extern void (*obstack_alloc_failed_handler) (void); |
270 |
#else |
#else |
271 |
extern void (*obstack_alloc_failed_handler) (); |
extern void (*obstack_alloc_failed_handler) (); |
294 |
|
|
295 |
/* To prevent prototype warnings provide complete argument list in |
/* To prevent prototype warnings provide complete argument list in |
296 |
standard C version. */ |
standard C version. */ |
297 |
#if defined __STDC__ && __STDC__ |
#if PROTOYPES || (defined __STDC__ && __STDC__) |
298 |
|
|
299 |
# define obstack_init(h) \ |
# define obstack_init(h) \ |
300 |
_obstack_begin ((h), 0, 0, \ |
_obstack_begin ((h), 0, 0, \ |
589 |
(h)->object_base = (h)->next_free, \ |
(h)->object_base = (h)->next_free, \ |
590 |
__INT_TO_PTR ((h)->temp)) |
__INT_TO_PTR ((h)->temp)) |
591 |
|
|
592 |
# if defined __STDC__ && __STDC__ |
# if PROTOTYPES || (defined __STDC__ && __STDC__) |
593 |
# define obstack_free(h,obj) \ |
# define obstack_free(h,obj) \ |
594 |
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ |
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ |
595 |
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ |
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ |