1 |
/* obstack.c - subroutines used implicitly by object stack macros |
/* obstack.c - subroutines used implicitly by object stack macros |
2 |
Copyright (C) 1988-1994,96,97,98,99,2000,2001 Free Software Foundation, Inc. |
|
3 |
|
Copyright (C) 1988-1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002 |
4 |
|
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. |
8 |
|
|
9 |
The GNU C Library is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or modify |
10 |
modify it under the terms of the GNU Lesser General Public |
it under the terms of the GNU General Public License as published by |
11 |
License as published by the Free Software Foundation; either |
the Free Software Foundation; either version 2, or (at your option) |
12 |
version 2.1 of the License, or (at your option) any later version. |
any later version. |
13 |
|
|
14 |
The GNU C Library is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
Lesser General Public License for more details. |
GNU General Public License for more details. |
18 |
|
|
19 |
You should have received a copy of the GNU Lesser General Public |
You should have received a copy of the GNU General Public License |
20 |
License along with the GNU C Library; if not, write to the Free |
along with this program; if not, write to the Free Software Foundation, |
21 |
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
|
02111-1307 USA. */ |
|
22 |
|
|
23 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
24 |
# include <config.h> |
# include <config.h> |
55 |
#ifndef ELIDE_CODE |
#ifndef ELIDE_CODE |
56 |
|
|
57 |
|
|
58 |
# if defined __STDC__ && __STDC__ |
# ifdef __STDC__ |
59 |
# define POINTER void * |
# define POINTER void * |
60 |
# else |
# else |
61 |
# define POINTER char * |
# define POINTER char * |
86 |
abort gracefully or use longjump - but shouldn't return. This |
abort gracefully or use longjump - but shouldn't return. This |
87 |
variable by default points to the internal function |
variable by default points to the internal function |
88 |
`print_and_abort'. */ |
`print_and_abort'. */ |
89 |
# if defined __STDC__ && __STDC__ |
# if PROTOTYPES || (defined __STDC__ && __STDC__) |
90 |
static void print_and_abort (void); |
static void print_and_abort (void); |
91 |
void (*obstack_alloc_failed_handler) (void) = print_and_abort; |
void (*obstack_alloc_failed_handler) (void) = print_and_abort; |
92 |
# else |
# else |
114 |
For free, do not use ?:, since some compilers, like the MIPS compilers, |
For free, do not use ?:, since some compilers, like the MIPS compilers, |
115 |
do not allow (expr) ? void : void. */ |
do not allow (expr) ? void : void. */ |
116 |
|
|
117 |
# if defined __STDC__ && __STDC__ |
# if PROTOTYPES || (defined __STDC__ && __STDC__) |
118 |
# define CALL_CHUNKFUN(h, size) \ |
# define CALL_CHUNKFUN(h, size) \ |
119 |
(((h) -> use_extra_arg) \ |
(((h) -> use_extra_arg) \ |
120 |
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ |
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ |
156 |
struct obstack *h; |
struct obstack *h; |
157 |
int size; |
int size; |
158 |
int alignment; |
int alignment; |
159 |
# if defined __STDC__ && __STDC__ |
# if PROTOTYPES || (defined __STDC__ && __STDC__) |
160 |
POINTER (*chunkfun) (long); |
POINTER (*chunkfun) (long); |
161 |
void (*freefun) (void *); |
void (*freefun) (void *); |
162 |
# else |
# else |
185 |
size = 4096 - extra; |
size = 4096 - extra; |
186 |
} |
} |
187 |
|
|
188 |
# if defined __STDC__ && __STDC__ |
# if PROTOTYPES || (defined __STDC__ && __STDC__) |
189 |
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun; |
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun; |
190 |
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; |
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; |
191 |
# else |
# else |
214 |
struct obstack *h; |
struct obstack *h; |
215 |
int size; |
int size; |
216 |
int alignment; |
int alignment; |
217 |
# if defined __STDC__ && __STDC__ |
# if PROTOTYPES || (defined __STDC__ && __STDC__) |
218 |
POINTER (*chunkfun) (POINTER, long); |
POINTER (*chunkfun) (POINTER, long); |
219 |
void (*freefun) (POINTER, POINTER); |
void (*freefun) (POINTER, POINTER); |
220 |
# else |
# else |
244 |
size = 4096 - extra; |
size = 4096 - extra; |
245 |
} |
} |
246 |
|
|
247 |
# if defined __STDC__ && __STDC__ |
# if PROTOTYPES || (defined __STDC__ && __STDC__) |
248 |
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun; |
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun; |
249 |
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; |
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; |
250 |
# else |
# else |
345 |
This is here for debugging. |
This is here for debugging. |
346 |
If you use it in a program, you are probably losing. */ |
If you use it in a program, you are probably losing. */ |
347 |
|
|
348 |
# if defined __STDC__ && __STDC__ |
# if PROTOTYPES || (defined __STDC__ && __STDC__) |
349 |
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in |
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in |
350 |
obstack.h because it is just for debugging. */ |
obstack.h because it is just for debugging. */ |
351 |
int _obstack_allocated_p (struct obstack *h, POINTER obj); |
int _obstack_allocated_p (struct obstack *h, POINTER obj); |
507 |
/* Now define the functional versions of the obstack macros. |
/* Now define the functional versions of the obstack macros. |
508 |
Define them to simply use the corresponding macros to do the job. */ |
Define them to simply use the corresponding macros to do the job. */ |
509 |
|
|
510 |
# if defined __STDC__ && __STDC__ |
# if PROTOTYPES || (defined __STDC__ && __STDC__) |
511 |
/* These function definitions do not work with non-ANSI preprocessors; |
/* These function definitions do not work with non-ANSI preprocessors; |
512 |
they won't pass through the macro names in parentheses. */ |
they won't pass through the macro names in parentheses. */ |
513 |
|
|
618 |
return obstack_copy0 (obstack, address, length); |
return obstack_copy0 (obstack, address, length); |
619 |
} |
} |
620 |
|
|
621 |
# endif /* __STDC__ */ |
# endif /* PROTOTYPES || (defined __STDC__ && __STDC__) */ |
622 |
|
|
623 |
# endif /* 0 */ |
# endif /* 0 */ |
624 |
|
|