Mercurial > hg > octave-kai > gnulib-hg
annotate lib/obstack.h @ 17463:203c036eb0c6
bootstrap: support checksum utils without a --status option
* build-aux/bootstrap: Only look for sha1sum if updating po files.
Add sha1 to the list of supported checksum utils since it's now
supported through adjustments below.
(update_po_files): Remove the use of --status
in a way that will suppress all error messages, but since this is
only used to minimize updates, it shouldn't cause an issue.
Exit early if there is a problem updating the po file checksums.
(find_tool): Remove the check for --version support as this
is optional as per commit 86186b17. Don't even check for the
presence of the command as if that is needed, it's supported
through configuring prerequisites in bootstrap.conf.
Prompt that when a tool isn't found, one can define an environment
variable to add to the hardcoded search list.
author | Pádraig Brady <P@draigBrady.com> |
---|---|
date | Thu, 08 Aug 2013 11:08:49 +0100 |
parents | 253d6bbd7aa4 |
children |
rev | line source |
---|---|
334 | 1 /* obstack.h - object stack macros |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16358
diff
changeset
|
2 Copyright (C) 1988-1994, 1996-1999, 2003-2006, 2009-2013 Free Software |
12518
b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
Jim Meyering <meyering@redhat.com>
parents:
12421
diff
changeset
|
3 Foundation, Inc. |
6376
56829cd68e67
* config/srclist.txt: Add glibc bug 321 for obstack.c, obstack.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
4 This file is part of the GNU C Library. |
334 | 5 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7550
diff
changeset
|
6 This program is free software: you can redistribute it and/or modify |
4422 | 7 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7550
diff
changeset
|
8 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7550
diff
changeset
|
9 (at your option) any later version. |
1112 | 10 |
11 This program is distributed in the hope that it will be useful, | |
881 | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
4422 | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | |
881 | 15 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7550
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7550
diff
changeset
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
334 | 18 |
19 /* Summary: | |
20 | |
21 All the apparent functions defined here are macros. The idea | |
22 is that you would use these pre-tested macros to solve a | |
23 very specific set of problems, and they would run fast. | |
24 Caution: no side-effects in arguments please!! They may be | |
25 evaluated MANY times!! | |
26 | |
27 These macros operate a stack of objects. Each object starts life | |
28 small, and may grow to maturity. (Consider building a word syllable | |
29 by syllable.) An object can move while it is growing. Once it has | |
30 been "finished" it never changes address again. So the "top of the | |
31 stack" is typically an immature growing object, while the rest of the | |
32 stack is of mature, fixed size and fixed address objects. | |
33 | |
34 These routines grab large chunks of memory, using a function you | |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
35 supply, called 'obstack_chunk_alloc'. On occasion, they free chunks, |
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
36 by calling 'obstack_chunk_free'. You must define them and declare |
334 | 37 them before using any obstack macros. |
38 | |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
39 Each independent stack is represented by a 'struct obstack'. |
334 | 40 Each of the obstack macros expects a pointer to such a structure |
41 as the first argument. | |
42 | |
43 One motivation for this package is the problem of growing char strings | |
44 in symbol tables. Unless you are "fascist pig with a read-only mind" | |
45 --Gosper's immortal quote from HAKMEM item 154, out of context--you | |
46 would not like to put any arbitrary upper limit on the length of your | |
47 symbols. | |
48 | |
49 In practice this often means you will build many short symbols and a | |
50 few long symbols. At the time you are reading a symbol you don't know | |
51 how long it is. One traditional method is to read a symbol into a | |
52 buffer, realloc()ating the buffer every time you try to read a symbol | |
53 that is longer than the buffer. This is beaut, but you still will | |
54 want to copy the symbol from the buffer to a more permanent | |
55 symbol-table entry say about half the time. | |
56 | |
57 With obstacks, you can work differently. Use one obstack for all symbol | |
58 names. As you read a symbol, grow the name in the obstack gradually. | |
59 When the name is complete, finalize it. Then, if the symbol exists already, | |
60 free the newly read name. | |
61 | |
62 The way we do this is to take a large chunk, allocating memory from | |
63 low addresses. When you want to build a symbol in the chunk you just | |
64 add chars above the current "high water mark" in the chunk. When you | |
65 have finished adding chars, because you got to the end of the symbol, | |
66 you know how long the chars are, and you can create a new object. | |
67 Mostly the chars will not burst over the highest address of the chunk, | |
68 because you would typically expect a chunk to be (say) 100 times as | |
69 long as an average object. | |
70 | |
71 In case that isn't clear, when we have enough chars to make up | |
72 the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) | |
73 so we just point to it where it lies. No moving of chars is | |
74 needed and this is the second win: potentially long strings need | |
75 never be explicitly shuffled. Once an object is formed, it does not | |
76 change its address during its lifetime. | |
77 | |
78 When the chars burst over a chunk boundary, we allocate a larger | |
79 chunk, and then copy the partly formed object from the end of the old | |
80 chunk to the beginning of the new larger chunk. We then carry on | |
81 accreting characters to the end of the object as we normally would. | |
82 | |
83 A special macro is provided to add a single char at a time to a | |
84 growing object. This allows the use of register variables, which | |
85 break the ordinary 'growth' macro. | |
86 | |
87 Summary: | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
88 We allocate large chunks. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
89 We carve out one object at a time from the current chunk. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
90 Once carved, an object never moves. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
91 We are free to append data of any size to the currently |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
92 growing object. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
93 Exactly one object is growing in an obstack at any one time. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
94 You can run one obstack per control block. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
95 You may have as many control blocks as you dare. |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
96 Because of the way we do it, you can "unwind" an obstack |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
97 back to a previous state. (You may remove objects much |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
98 as you would with a stack.) |
334 | 99 */ |
100 | |
101 | |
102 /* Don't do the contents of this file more than once. */ | |
103 | |
1112 | 104 #ifndef _OBSTACK_H |
105 #define _OBSTACK_H 1 | |
995 | 106 |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
107 /* We need the type of a pointer subtraction. If __PTRDIFF_TYPE__ is |
2477
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
108 defined, as with GNU C, use that; that way we don't pollute the |
4667 | 109 namespace with <stddef.h>'s symbols. Otherwise, include <stddef.h> |
110 and use ptrdiff_t. */ | |
334 | 111 |
2477
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
112 #ifdef __PTRDIFF_TYPE__ |
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
113 # define PTR_INT_TYPE __PTRDIFF_TYPE__ |
334 | 114 #else |
4667 | 115 # include <stddef.h> |
116 # define PTR_INT_TYPE ptrdiff_t | |
334 | 117 #endif |
118 | |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
119 /* If B is the base of an object addressed by P, return the result of |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
120 aligning P to the next multiple of A + 1. B and P must be of type |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
121 char *. A + 1 must be a power of 2. */ |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
122 |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
123 #define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A))) |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
124 |
16358 | 125 /* Similar to _BPTR_ALIGN (B, P, A), except optimize the common case |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
126 where pointers can be converted to integers, aligned as integers, |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
127 and converted back again. If PTR_INT_TYPE is narrower than a |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
128 pointer (e.g., the AS/400), play it safe and compute the alignment |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
129 relative to B. Otherwise, use the faster strategy of computing the |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
130 alignment relative to 0. */ |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
131 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
132 #define __PTR_ALIGN(B, P, A) \ |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
133 __BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
134 P, A) |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
135 |
4667 | 136 #include <string.h> |
881 | 137 |
13021
239c17119e60
Ensure no #include statements inside extern "C" { ... }.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
138 #ifdef __cplusplus |
239c17119e60
Ensure no #include statements inside extern "C" { ... }.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
139 extern "C" { |
239c17119e60
Ensure no #include statements inside extern "C" { ... }.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
140 #endif |
239c17119e60
Ensure no #include statements inside extern "C" { ... }.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
141 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
142 struct _obstack_chunk /* Lives at front of each chunk. */ |
334 | 143 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
144 char *limit; /* 1 past end of this chunk */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
145 struct _obstack_chunk *prev; /* address of prior chunk or NULL */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
146 char contents[4]; /* objects begin here */ |
334 | 147 }; |
148 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
149 struct obstack /* control current object in current chunk */ |
334 | 150 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
151 long chunk_size; /* preferred size to allocate chunks in */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
152 struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
153 char *object_base; /* address of object we are building */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
154 char *next_free; /* where to add next char to current object */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
155 char *chunk_limit; /* address of char after current chunk */ |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
156 union |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
157 { |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
158 PTR_INT_TYPE tempint; |
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
159 void *tempptr; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
160 } temp; /* Temporary for some macros. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
161 int alignment_mask; /* Mask of alignment for each object. */ |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
162 /* These prototypes vary based on 'use_extra_arg', and we use |
779 | 163 casts to the prototypeless function type in all assignments, |
164 but having prototypes here quiets -Wstrict-prototypes. */ | |
165 struct _obstack_chunk *(*chunkfun) (void *, long); | |
166 void (*freefun) (void *, struct _obstack_chunk *); | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
167 void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
168 unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ |
334 | 169 unsigned maybe_empty_object:1;/* There is a possibility that the current |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
170 chunk contains a zero-length object. This |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
171 prevents freeing the chunk if we allocate |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
172 a bigger chunk to replace it. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
173 unsigned alloc_failed:1; /* No longer used, as we now call the failed |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
174 handler on error, but retained for binary |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
175 compatibility. */ |
334 | 176 }; |
177 | |
178 /* Declare the external functions we use; they are in obstack.c. */ | |
179 | |
180 extern void _obstack_newchunk (struct obstack *, int); | |
181 extern int _obstack_begin (struct obstack *, int, int, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
182 void *(*) (long), void (*) (void *)); |
334 | 183 extern int _obstack_begin_1 (struct obstack *, int, int, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
184 void *(*) (void *, long), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
185 void (*) (void *, void *), void *); |
881 | 186 extern int _obstack_memory_used (struct obstack *); |
334 | 187 |
7550
0d3d27f21643
Make it possible to rename obstack_free.
Bruno Haible <bruno@clisp.org>
parents:
6376
diff
changeset
|
188 /* The default name of the function for freeing a chunk is 'obstack_free', |
0d3d27f21643
Make it possible to rename obstack_free.
Bruno Haible <bruno@clisp.org>
parents:
6376
diff
changeset
|
189 but gnulib users can override this by defining '__obstack_free'. */ |
0d3d27f21643
Make it possible to rename obstack_free.
Bruno Haible <bruno@clisp.org>
parents:
6376
diff
changeset
|
190 #ifndef __obstack_free |
0d3d27f21643
Make it possible to rename obstack_free.
Bruno Haible <bruno@clisp.org>
parents:
6376
diff
changeset
|
191 # define __obstack_free obstack_free |
0d3d27f21643
Make it possible to rename obstack_free.
Bruno Haible <bruno@clisp.org>
parents:
6376
diff
changeset
|
192 #endif |
0d3d27f21643
Make it possible to rename obstack_free.
Bruno Haible <bruno@clisp.org>
parents:
6376
diff
changeset
|
193 extern void __obstack_free (struct obstack *obstack, void *block); |
334 | 194 |
5070
57d23334289f
Remove unused vars and decls in obstack.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5065
diff
changeset
|
195 |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
196 /* Error handler called when 'obstack_chunk_alloc' failed to allocate |
2477
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
197 more memory. This can be set to a user defined function which |
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
198 should either abort gracefully or use longjump - but shouldn't |
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
199 return. The default action is to print a message and abort. */ |
881 | 200 extern void (*obstack_alloc_failed_handler) (void); |
201 | |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
202 /* Exit value used when 'print_and_abort' is used. */ |
881 | 203 extern int obstack_exit_failure; |
334 | 204 |
205 /* Pointer to beginning of object being allocated or to be allocated next. | |
206 Note that this might not be the final address of the object | |
207 because a new chunk might be needed to hold the final size. */ | |
208 | |
5095
0afa9dc2bdfc
(obstack_base): Cast to (void *), per documentation.
Jim Meyering <jim@meyering.net>
parents:
5070
diff
changeset
|
209 #define obstack_base(h) ((void *) (h)->object_base) |
334 | 210 |
211 /* Size for allocating ordinary chunks. */ | |
212 | |
213 #define obstack_chunk_size(h) ((h)->chunk_size) | |
214 | |
215 /* Pointer to next byte not yet allocated in current chunk. */ | |
216 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
217 #define obstack_next_free(h) ((h)->next_free) |
334 | 218 |
219 /* Mask specifying low bits that should be clear in address of an object. */ | |
220 | |
221 #define obstack_alignment_mask(h) ((h)->alignment_mask) | |
222 | |
4667 | 223 /* To prevent prototype warnings provide complete argument list. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
224 #define obstack_init(h) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
225 _obstack_begin ((h), 0, 0, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
226 (void *(*) (long)) obstack_chunk_alloc, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
227 (void (*) (void *)) obstack_chunk_free) |
779 | 228 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
229 #define obstack_begin(h, size) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
230 _obstack_begin ((h), (size), 0, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
231 (void *(*) (long)) obstack_chunk_alloc, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
232 (void (*) (void *)) obstack_chunk_free) |
779 | 233 |
4805
8f430f14ff21
Merge changes from glibc obstack; minor cleanups to make it easier to
Paul Eggert <eggert@cs.ucla.edu>
parents:
4804
diff
changeset
|
234 #define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
235 _obstack_begin ((h), (size), (alignment), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
236 (void *(*) (long)) (chunkfun), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
237 (void (*) (void *)) (freefun)) |
779 | 238 |
4805
8f430f14ff21
Merge changes from glibc obstack; minor cleanups to make it easier to
Paul Eggert <eggert@cs.ucla.edu>
parents:
4804
diff
changeset
|
239 #define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
240 _obstack_begin_1 ((h), (size), (alignment), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
241 (void *(*) (void *, long)) (chunkfun), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
242 (void (*) (void *, void *)) (freefun), (arg)) |
779 | 243 |
4805
8f430f14ff21
Merge changes from glibc obstack; minor cleanups to make it easier to
Paul Eggert <eggert@cs.ucla.edu>
parents:
4804
diff
changeset
|
244 #define obstack_chunkfun(h, newchunkfun) \ |
995 | 245 ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) |
779 | 246 |
4805
8f430f14ff21
Merge changes from glibc obstack; minor cleanups to make it easier to
Paul Eggert <eggert@cs.ucla.edu>
parents:
4804
diff
changeset
|
247 #define obstack_freefun(h, newfreefun) \ |
995 | 248 ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) |
779 | 249 |
4804
d0a345595720
Don't use lvalue casts, as GCC plans to remove support for them in GCC 3.5.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4667
diff
changeset
|
250 #define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar)) |
334 | 251 |
252 #define obstack_blank_fast(h,n) ((h)->next_free += (n)) | |
881 | 253 |
254 #define obstack_memory_used(h) _obstack_memory_used (h) | |
334 | 255 |
16311
ca5972990d4f
obstack: remove __STDC__ conditionals
Paul Eggert <eggert@cs.ucla.edu>
parents:
16235
diff
changeset
|
256 #if defined __GNUC__ |
350 | 257 /* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and |
258 does not implement __extension__. But that compiler doesn't define | |
259 __GNUC_MINOR__. */ | |
2477
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
260 # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) |
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
261 # define __extension__ |
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
262 # endif |
334 | 263 |
264 /* For GNU C, if not -traditional, | |
265 we can define these macros to compute all args only once | |
266 without using a global variable. | |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
267 Also, we can avoid using the 'temp' slot, to make faster code. */ |
334 | 268 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
269 # define obstack_object_size(OBSTACK) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
270 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
271 ({ struct obstack const *__o = (OBSTACK); \ |
334 | 272 (unsigned) (__o->next_free - __o->object_base); }) |
273 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
274 # define obstack_room(OBSTACK) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
275 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
276 ({ struct obstack const *__o = (OBSTACK); \ |
334 | 277 (unsigned) (__o->chunk_limit - __o->next_free); }) |
278 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
279 # define obstack_make_room(OBSTACK,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
280 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
281 ({ struct obstack *__o = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
282 int __len = (length); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
283 if (__o->chunk_limit - __o->next_free < __len) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
284 _obstack_newchunk (__o, __len); \ |
881 | 285 (void) 0; }) |
286 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
287 # define obstack_empty_p(OBSTACK) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
288 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
289 ({ struct obstack const *__o = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
290 (__o->chunk->prev == 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
291 && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
292 __o->chunk->contents, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
293 __o->alignment_mask)); }) |
1112 | 294 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
295 # define obstack_grow(OBSTACK,where,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
296 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
297 ({ struct obstack *__o = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
298 int __len = (length); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
299 if (__o->next_free + __len > __o->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
300 _obstack_newchunk (__o, __len); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
301 memcpy (__o->next_free, where, __len); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
302 __o->next_free += __len; \ |
334 | 303 (void) 0; }) |
304 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
305 # define obstack_grow0(OBSTACK,where,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
306 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
307 ({ struct obstack *__o = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
308 int __len = (length); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
309 if (__o->next_free + __len + 1 > __o->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
310 _obstack_newchunk (__o, __len + 1); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
311 memcpy (__o->next_free, where, __len); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
312 __o->next_free += __len; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
313 *(__o->next_free)++ = 0; \ |
334 | 314 (void) 0; }) |
315 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
316 # define obstack_1grow(OBSTACK,datum) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
317 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
318 ({ struct obstack *__o = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
319 if (__o->next_free + 1 > __o->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
320 _obstack_newchunk (__o, 1); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
321 obstack_1grow_fast (__o, datum); \ |
334 | 322 (void) 0; }) |
323 | |
2990 | 324 /* These assume that the obstack alignment is good enough for pointers |
325 or ints, and that the data added so far to the current object | |
334 | 326 shares that much alignment. */ |
479 | 327 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
328 # define obstack_ptr_grow(OBSTACK,datum) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
329 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
330 ({ struct obstack *__o = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
331 if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
332 _obstack_newchunk (__o, sizeof (void *)); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
333 obstack_ptr_grow_fast (__o, datum); }) \ |
334 | 334 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
335 # define obstack_int_grow(OBSTACK,datum) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
336 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
337 ({ struct obstack *__o = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
338 if (__o->next_free + sizeof (int) > __o->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
339 _obstack_newchunk (__o, sizeof (int)); \ |
4804
d0a345595720
Don't use lvalue casts, as GCC plans to remove support for them in GCC 3.5.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4667
diff
changeset
|
340 obstack_int_grow_fast (__o, datum); }) |
d0a345595720
Don't use lvalue casts, as GCC plans to remove support for them in GCC 3.5.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4667
diff
changeset
|
341 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
342 # define obstack_ptr_grow_fast(OBSTACK,aptr) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
343 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
344 ({ struct obstack *__o1 = (OBSTACK); \ |
17406
253d6bbd7aa4
obstack: port --enable-gcc-warnings to clang
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
345 void *__p1 = __o1->next_free; \ |
253d6bbd7aa4
obstack: port --enable-gcc-warnings to clang
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
346 *(const void **) __p1 = (aptr); \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
347 __o1->next_free += sizeof (const void *); \ |
334 | 348 (void) 0; }) |
349 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
350 # define obstack_int_grow_fast(OBSTACK,aint) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
351 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
352 ({ struct obstack *__o1 = (OBSTACK); \ |
17406
253d6bbd7aa4
obstack: port --enable-gcc-warnings to clang
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
353 void *__p1 = __o1->next_free; \ |
253d6bbd7aa4
obstack: port --enable-gcc-warnings to clang
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
354 *(int *) __p1 = (aint); \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
355 __o1->next_free += sizeof (int); \ |
4804
d0a345595720
Don't use lvalue casts, as GCC plans to remove support for them in GCC 3.5.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4667
diff
changeset
|
356 (void) 0; }) |
334 | 357 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
358 # define obstack_blank(OBSTACK,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
359 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
360 ({ struct obstack *__o = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
361 int __len = (length); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
362 if (__o->chunk_limit - __o->next_free < __len) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
363 _obstack_newchunk (__o, __len); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
364 obstack_blank_fast (__o, __len); \ |
334 | 365 (void) 0; }) |
366 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
367 # define obstack_alloc(OBSTACK,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
368 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
369 ({ struct obstack *__h = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
370 obstack_blank (__h, (length)); \ |
334 | 371 obstack_finish (__h); }) |
372 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
373 # define obstack_copy(OBSTACK,where,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
374 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
375 ({ struct obstack *__h = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
376 obstack_grow (__h, (where), (length)); \ |
334 | 377 obstack_finish (__h); }) |
378 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
379 # define obstack_copy0(OBSTACK,where,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
380 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
381 ({ struct obstack *__h = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
382 obstack_grow0 (__h, (where), (length)); \ |
334 | 383 obstack_finish (__h); }) |
384 | |
385 /* The local variable is named __o1 to avoid a name conflict | |
386 when obstack_blank is called. */ | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
387 # define obstack_finish(OBSTACK) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
388 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
389 ({ struct obstack *__o1 = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
390 void *__value = (void *) __o1->object_base; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
391 if (__o1->next_free == __value) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
392 __o1->maybe_empty_object = 1; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
393 __o1->next_free \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
394 = __PTR_ALIGN (__o1->object_base, __o1->next_free, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
395 __o1->alignment_mask); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
396 if (__o1->next_free - (char *)__o1->chunk \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
397 > __o1->chunk_limit - (char *)__o1->chunk) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
398 __o1->next_free = __o1->chunk_limit; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
399 __o1->object_base = __o1->next_free; \ |
5057
f4b3a4229349
Import obstack changes from libc.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4805
diff
changeset
|
400 __value; }) |
334 | 401 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
402 # define obstack_free(OBSTACK, OBJ) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
403 __extension__ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
404 ({ struct obstack *__o = (OBSTACK); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
405 void *__obj = (OBJ); \ |
334 | 406 if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
407 __o->next_free = __o->object_base = (char *)__obj; \ |
7550
0d3d27f21643
Make it possible to rename obstack_free.
Bruno Haible <bruno@clisp.org>
parents:
6376
diff
changeset
|
408 else (__obstack_free) (__o, __obj); }) |
334 | 409 |
16311
ca5972990d4f
obstack: remove __STDC__ conditionals
Paul Eggert <eggert@cs.ucla.edu>
parents:
16235
diff
changeset
|
410 #else /* not __GNUC__ */ |
334 | 411 |
2477
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
412 # define obstack_object_size(h) \ |
881 | 413 (unsigned) ((h)->next_free - (h)->object_base) |
334 | 414 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
415 # define obstack_room(h) \ |
334 | 416 (unsigned) ((h)->chunk_limit - (h)->next_free) |
417 | |
2477
27aa55bf95b7
update from glibc -- solely white space changes
Jim Meyering <jim@meyering.net>
parents:
1112
diff
changeset
|
418 # define obstack_empty_p(h) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
419 ((h)->chunk->prev == 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
420 && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
421 (h)->chunk->contents, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
422 (h)->alignment_mask)) |
1112 | 423 |
334 | 424 /* Note that the call to _obstack_newchunk is enclosed in (..., 0) |
425 so that we can avoid having void expressions | |
426 in the arms of the conditional expression. | |
427 Casting the third operand to void was tried before, | |
428 but some compilers won't accept it. */ | |
429 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
430 # define obstack_make_room(h,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
431 ( (h)->temp.tempint = (length), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
432 (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
433 ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0)) |
881 | 434 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
435 # define obstack_grow(h,where,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
436 ( (h)->temp.tempint = (length), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
437 (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
438 ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
439 memcpy ((h)->next_free, where, (h)->temp.tempint), \ |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
440 (h)->next_free += (h)->temp.tempint) |
334 | 441 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
442 # define obstack_grow0(h,where,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
443 ( (h)->temp.tempint = (length), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
444 (((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
445 ? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
446 memcpy ((h)->next_free, where, (h)->temp.tempint), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
447 (h)->next_free += (h)->temp.tempint, \ |
881 | 448 *((h)->next_free)++ = 0) |
334 | 449 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
450 # define obstack_1grow(h,datum) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
451 ( (((h)->next_free + 1 > (h)->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
452 ? (_obstack_newchunk ((h), 1), 0) : 0), \ |
4804
d0a345595720
Don't use lvalue casts, as GCC plans to remove support for them in GCC 3.5.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4667
diff
changeset
|
453 obstack_1grow_fast (h, datum)) |
334 | 454 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
455 # define obstack_ptr_grow(h,datum) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
456 ( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
457 ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ |
4804
d0a345595720
Don't use lvalue casts, as GCC plans to remove support for them in GCC 3.5.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4667
diff
changeset
|
458 obstack_ptr_grow_fast (h, datum)) |
334 | 459 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
460 # define obstack_int_grow(h,datum) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
461 ( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
462 ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ |
4804
d0a345595720
Don't use lvalue casts, as GCC plans to remove support for them in GCC 3.5.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4667
diff
changeset
|
463 obstack_int_grow_fast (h, datum)) |
334 | 464 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
465 # define obstack_ptr_grow_fast(h,aptr) \ |
4804
d0a345595720
Don't use lvalue casts, as GCC plans to remove support for them in GCC 3.5.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4667
diff
changeset
|
466 (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) |
2990 | 467 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
468 # define obstack_int_grow_fast(h,aint) \ |
6376
56829cd68e67
* config/srclist.txt: Add glibc bug 321 for obstack.c, obstack.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
469 (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint)) |
334 | 470 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
471 # define obstack_blank(h,length) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
472 ( (h)->temp.tempint = (length), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
473 (((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
474 ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
475 obstack_blank_fast (h, (h)->temp.tempint)) |
334 | 476 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
477 # define obstack_alloc(h,length) \ |
334 | 478 (obstack_blank ((h), (length)), obstack_finish ((h))) |
479 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
480 # define obstack_copy(h,where,length) \ |
334 | 481 (obstack_grow ((h), (where), (length)), obstack_finish ((h))) |
482 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
483 # define obstack_copy0(h,where,length) \ |
334 | 484 (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) |
485 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
486 # define obstack_finish(h) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
487 ( ((h)->next_free == (h)->object_base \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
488 ? (((h)->maybe_empty_object = 1), 0) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
489 : 0), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
490 (h)->temp.tempptr = (h)->object_base, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
491 (h)->next_free \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
492 = __PTR_ALIGN ((h)->object_base, (h)->next_free, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
493 (h)->alignment_mask), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
494 (((h)->next_free - (char *) (h)->chunk \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
495 > (h)->chunk_limit - (char *) (h)->chunk) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
496 ? ((h)->next_free = (h)->chunk_limit) : 0), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
497 (h)->object_base = (h)->next_free, \ |
5065
4ce8ff7e5f06
Port obstack to the AS/400.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5057
diff
changeset
|
498 (h)->temp.tempptr) |
334 | 499 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
500 # define obstack_free(h,obj) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
501 ( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
502 ((((h)->temp.tempint > 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
503 && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
504 ? (int) ((h)->next_free = (h)->object_base \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
505 = (h)->temp.tempint + (char *) (h)->chunk) \ |
7550
0d3d27f21643
Make it possible to rename obstack_free.
Bruno Haible <bruno@clisp.org>
parents:
6376
diff
changeset
|
506 : (((__obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0))) |
334 | 507 |
16311
ca5972990d4f
obstack: remove __STDC__ conditionals
Paul Eggert <eggert@cs.ucla.edu>
parents:
16235
diff
changeset
|
508 #endif /* not __GNUC__ */ |
334 | 509 |
995 | 510 #ifdef __cplusplus |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
511 } /* C++ */ |
995 | 512 #endif |
513 | |
1112 | 514 #endif /* obstack.h */ |