118 #ifdef __PTRDIFF_TYPE__ 119 # define PTR_INT_TYPE __PTRDIFF_TYPE__ 122 # define PTR_INT_TYPE ptrdiff_t 129 #define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A))) 138 #define __PTR_ALIGN(B, P, A) \ 139 __BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \ 160 PTR_INT_TYPE tempint;
170 unsigned use_extra_arg:1;
171 unsigned maybe_empty_object:1;
175 unsigned alloc_failed:1;
182 extern void _obstack_newchunk (
struct obstack *,
int);
183 extern int _obstack_begin (
struct obstack *,
int,
int,
184 void *(*) (
long),
void (*) (
void *));
185 extern int _obstack_begin_1 (
struct obstack *,
int,
int,
186 void *(*) (
void *,
long),
187 void (*) (
void *,
void *),
void *);
188 extern int _obstack_memory_used (
struct obstack *);
197 extern void (*obstack_alloc_failed_handler) (void);
200 extern int obstack_exit_failure;
206 #define obstack_base(h) ((void *) (h)->object_base) 210 #define obstack_chunk_size(h) ((h)->chunk_size) 214 #define obstack_next_free(h) ((h)->next_free) 218 #define obstack_alignment_mask(h) ((h)->alignment_mask) 221 #define obstack_init(h) \ 222 _obstack_begin ((h), 0, 0, \ 223 (void *(*) (long)) obstack_chunk_alloc, \ 224 (void (*) (void *)) obstack_chunk_free) 226 #define obstack_begin(h, size) \ 227 _obstack_begin ((h), (size), 0, \ 228 (void *(*) (long)) obstack_chunk_alloc, \ 229 (void (*) (void *)) obstack_chunk_free) 231 #define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ 232 _obstack_begin ((h), (size), (alignment), \ 233 (void *(*) (long)) (chunkfun), \ 234 (void (*) (void *)) (freefun)) 236 #define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ 237 _obstack_begin_1 ((h), (size), (alignment), \ 238 (void *(*) (void *, long)) (chunkfun), \ 239 (void (*) (void *, void *)) (freefun), (arg)) 241 #define obstack_chunkfun(h, newchunkfun) \ 242 ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) 244 #define obstack_freefun(h, newfreefun) \ 245 ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) 247 #define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar)) 249 #define obstack_blank_fast(h,n) ((h)->next_free += (n)) 251 #define obstack_memory_used(h) _obstack_memory_used (h) 253 #if defined __GNUC__ && defined __STDC__ && __STDC__ 257 # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) 258 # define __extension__ 266 # define obstack_object_size(OBSTACK) \ 268 ({ struct obstack const *__o = (OBSTACK); \ 269 (unsigned) (__o->next_free - __o->object_base); }) 271 # define obstack_room(OBSTACK) \ 273 ({ struct obstack const *__o = (OBSTACK); \ 274 (unsigned) (__o->chunk_limit - __o->next_free); }) 276 # define obstack_make_room(OBSTACK,length) \ 278 ({ struct obstack *__o = (OBSTACK); \ 279 int __len = (length); \ 280 if (__o->chunk_limit - __o->next_free < __len) \ 281 _obstack_newchunk (__o, __len); \ 284 # define obstack_empty_p(OBSTACK) \ 286 ({ struct obstack const *__o = (OBSTACK); \ 287 (__o->chunk->prev == 0 \ 288 && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \ 289 __o->chunk->contents, \ 290 __o->alignment_mask)); }) 292 # define obstack_grow(OBSTACK,where,length) \ 294 ({ struct obstack *__o = (OBSTACK); \ 295 int __len = (length); \ 296 if (__o->next_free + __len > __o->chunk_limit) \ 297 _obstack_newchunk (__o, __len); \ 298 memcpy (__o->next_free, where, __len); \ 299 __o->next_free += __len; \ 302 # define obstack_grow0(OBSTACK,where,length) \ 304 ({ struct obstack *__o = (OBSTACK); \ 305 int __len = (length); \ 306 if (__o->next_free + __len + 1 > __o->chunk_limit) \ 307 _obstack_newchunk (__o, __len + 1); \ 308 memcpy (__o->next_free, where, __len); \ 309 __o->next_free += __len; \ 310 *(__o->next_free)++ = 0; \ 313 # define obstack_1grow(OBSTACK,datum) \ 315 ({ struct obstack *__o = (OBSTACK); \ 316 if (__o->next_free + 1 > __o->chunk_limit) \ 317 _obstack_newchunk (__o, 1); \ 318 obstack_1grow_fast (__o, datum); \ 325 # define obstack_ptr_grow(OBSTACK,datum) \ 327 ({ struct obstack *__o = (OBSTACK); \ 328 if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ 329 _obstack_newchunk (__o, sizeof (void *)); \ 330 obstack_ptr_grow_fast (__o, datum); }) \ 332 # define obstack_int_grow(OBSTACK,datum) \ 334 ({ struct obstack *__o = (OBSTACK); \ 335 if (__o->next_free + sizeof (int) > __o->chunk_limit) \ 336 _obstack_newchunk (__o, sizeof (int)); \ 337 obstack_int_grow_fast (__o, datum); }) 339 # define obstack_ptr_grow_fast(OBSTACK,aptr) \ 341 ({ struct obstack *__o1 = (OBSTACK); \ 342 *(const void **) __o1->next_free = (aptr); \ 343 __o1->next_free += sizeof (const void *); \ 346 # define obstack_int_grow_fast(OBSTACK,aint) \ 348 ({ struct obstack *__o1 = (OBSTACK); \ 349 *(int *) __o1->next_free = (aint); \ 350 __o1->next_free += sizeof (int); \ 353 # define obstack_blank(OBSTACK,length) \ 355 ({ struct obstack *__o = (OBSTACK); \ 356 int __len = (length); \ 357 if (__o->chunk_limit - __o->next_free < __len) \ 358 _obstack_newchunk (__o, __len); \ 359 obstack_blank_fast (__o, __len); \ 362 # define obstack_alloc(OBSTACK,length) \ 364 ({ struct obstack *__h = (OBSTACK); \ 365 obstack_blank (__h, (length)); \ 366 obstack_finish (__h); }) 368 # define obstack_copy(OBSTACK,where,length) \ 370 ({ struct obstack *__h = (OBSTACK); \ 371 obstack_grow (__h, (where), (length)); \ 372 obstack_finish (__h); }) 374 # define obstack_copy0(OBSTACK,where,length) \ 376 ({ struct obstack *__h = (OBSTACK); \ 377 obstack_grow0 (__h, (where), (length)); \ 378 obstack_finish (__h); }) 382 # define obstack_finish(OBSTACK) \ 384 ({ struct obstack *__o1 = (OBSTACK); \ 385 void *__value = (void *) __o1->object_base; \ 386 if (__o1->next_free == __value) \ 387 __o1->maybe_empty_object = 1; \ 389 = __PTR_ALIGN (__o1->object_base, __o1->next_free, \ 390 __o1->alignment_mask); \ 391 if (__o1->next_free - (char *)__o1->chunk \ 392 > __o1->chunk_limit - (char *)__o1->chunk) \ 393 __o1->next_free = __o1->chunk_limit; \ 394 __o1->object_base = __o1->next_free; \ 397 # define obstack_free(OBSTACK, OBJ) \ 399 ({ struct obstack *__o = (OBSTACK); \ 400 void *__obj = (OBJ); \ 401 if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ 402 __o->next_free = __o->object_base = (char *)__obj; \ 403 else (obstack_free) (__o, __obj); }) 407 # define obstack_object_size(h) \ 408 (unsigned) ((h)->next_free - (h)->object_base) 410 # define obstack_room(h) \ 411 (unsigned) ((h)->chunk_limit - (h)->next_free) 413 # define obstack_empty_p(h) \ 414 ((h)->chunk->prev == 0 \ 415 && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \ 416 (h)->chunk->contents, \ 417 (h)->alignment_mask)) 425 # define obstack_make_room(h,length) \ 426 ( (h)->temp.tempint = (length), \ 427 (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ 428 ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0)) 430 # define obstack_grow(h,where,length) \ 431 ( (h)->temp.tempint = (length), \ 432 (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ 433 ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ 434 memcpy ((h)->next_free, where, (h)->temp.tempint), \ 435 (h)->next_free += (h)->temp.tempint) 437 # define obstack_grow0(h,where,length) \ 438 ( (h)->temp.tempint = (length), \ 439 (((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \ 440 ? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \ 441 memcpy ((h)->next_free, where, (h)->temp.tempint), \ 442 (h)->next_free += (h)->temp.tempint, \ 443 *((h)->next_free)++ = 0) 445 # define obstack_1grow(h,datum) \ 446 ( (((h)->next_free + 1 > (h)->chunk_limit) \ 447 ? (_obstack_newchunk ((h), 1), 0) : 0), \ 448 obstack_1grow_fast (h, datum)) 450 # define obstack_ptr_grow(h,datum) \ 451 ( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ 452 ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ 453 obstack_ptr_grow_fast (h, datum)) 455 # define obstack_int_grow(h,datum) \ 456 ( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ 457 ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ 458 obstack_int_grow_fast (h, datum)) 460 # define obstack_ptr_grow_fast(h,aptr) \ 461 (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) 463 # define obstack_int_grow_fast(h,aint) \ 464 (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint)) 466 # define obstack_blank(h,length) \ 467 ( (h)->temp.tempint = (length), \ 468 (((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \ 469 ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ 470 obstack_blank_fast (h, (h)->temp.tempint)) 472 # define obstack_alloc(h,length) \ 473 (obstack_blank ((h), (length)), obstack_finish ((h))) 475 # define obstack_copy(h,where,length) \ 476 (obstack_grow ((h), (where), (length)), obstack_finish ((h))) 478 # define obstack_copy0(h,where,length) \ 479 (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) 481 # define obstack_finish(h) \ 482 ( ((h)->next_free == (h)->object_base \ 483 ? (((h)->maybe_empty_object = 1), 0) \ 485 (h)->temp.tempptr = (h)->object_base, \ 487 = __PTR_ALIGN ((h)->object_base, (h)->next_free, \ 488 (h)->alignment_mask), \ 489 (((h)->next_free - (char *) (h)->chunk \ 490 > (h)->chunk_limit - (char *) (h)->chunk) \ 491 ? ((h)->next_free = (h)->chunk_limit) : 0), \ 492 (h)->object_base = (h)->next_free, \ 495 # define obstack_free(h,obj) \ 496 ( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \ 497 ((((h)->temp.tempint > 0 \ 498 && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \ 499 ? (int) ((h)->next_free = (h)->object_base \ 500 = (h)->temp.tempint + (char *) (h)->chunk) \ 501 : (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0))) Definition: obstack.h:151
Definition: obstack.h:144