1 |
/* obstack.h - object stack macros |
/* obstack.h - object stack macros |
2 |
Copyright (C) 1988,89,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. |
Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, |
3 |
|
1999, 2000 |
4 |
|
Free Software Foundation, Inc. |
5 |
|
|
6 |
|
|
7 |
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. |
145 |
|
|
146 |
#if defined _LIBC || defined HAVE_STRING_H |
#if defined _LIBC || defined HAVE_STRING_H |
147 |
# include <string.h> |
# include <string.h> |
148 |
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) |
# if defined __STDC__ && __STDC__ |
149 |
|
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) |
150 |
|
# else |
151 |
|
# define _obstack_memcpy(To, From, N) memcpy ((To), (char *)(From), (N)) |
152 |
|
# endif |
153 |
#else |
#else |
154 |
# ifdef memcpy |
# ifdef memcpy |
155 |
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) |
# define _obstack_memcpy(To, From, N) memcpy ((To), (char *)(From), (N)) |
156 |
# else |
# else |
157 |
# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N)) |
# define _obstack_memcpy(To, From, N) bcopy ((char *)(From), (To), (N)) |
158 |
# endif |
# endif |
159 |
#endif |
#endif |
160 |
|
|
343 |
|
|
344 |
#endif |
#endif |
345 |
|
|
346 |
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) |
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar)) |
347 |
|
|
348 |
#define obstack_blank_fast(h,n) ((h)->next_free += (n)) |
#define obstack_blank_fast(h,n) ((h)->next_free += (n)) |
349 |
|
|
391 |
int __len = (length); \ |
int __len = (length); \ |
392 |
if (__o->next_free + __len > __o->chunk_limit) \ |
if (__o->next_free + __len > __o->chunk_limit) \ |
393 |
_obstack_newchunk (__o, __len); \ |
_obstack_newchunk (__o, __len); \ |
394 |
_obstack_memcpy (__o->next_free, (char *) (where), __len); \ |
_obstack_memcpy (__o->next_free, (where), __len); \ |
395 |
__o->next_free += __len; \ |
__o->next_free += __len; \ |
396 |
(void) 0; }) |
(void) 0; }) |
397 |
|
|
401 |
int __len = (length); \ |
int __len = (length); \ |
402 |
if (__o->next_free + __len + 1 > __o->chunk_limit) \ |
if (__o->next_free + __len + 1 > __o->chunk_limit) \ |
403 |
_obstack_newchunk (__o, __len + 1); \ |
_obstack_newchunk (__o, __len + 1); \ |
404 |
_obstack_memcpy (__o->next_free, (char *) (where), __len); \ |
_obstack_memcpy (__o->next_free, (where), __len); \ |
405 |
__o->next_free += __len; \ |
__o->next_free += __len; \ |
406 |
*(__o->next_free)++ = 0; \ |
*(__o->next_free)++ = 0; \ |
407 |
(void) 0; }) |
(void) 0; }) |
411 |
({ struct obstack *__o = (OBSTACK); \ |
({ struct obstack *__o = (OBSTACK); \ |
412 |
if (__o->next_free + 1 > __o->chunk_limit) \ |
if (__o->next_free + 1 > __o->chunk_limit) \ |
413 |
_obstack_newchunk (__o, 1); \ |
_obstack_newchunk (__o, 1); \ |
414 |
*(__o->next_free)++ = (datum); \ |
obstack_1grow_fast (__o, datum); \ |
415 |
(void) 0; }) |
(void) 0; }) |
416 |
|
|
417 |
/* These assume that the obstack alignment is good enough for pointers or ints, |
/* These assume that the obstack alignment is good enough for pointers or ints, |
423 |
({ struct obstack *__o = (OBSTACK); \ |
({ struct obstack *__o = (OBSTACK); \ |
424 |
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ |
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ |
425 |
_obstack_newchunk (__o, sizeof (void *)); \ |
_obstack_newchunk (__o, sizeof (void *)); \ |
426 |
*((void **)__o->next_free)++ = ((void *)datum); \ |
obstack_ptr_grow_fast (__o, datum); }) |
|
(void) 0; }) |
|
427 |
|
|
428 |
# define obstack_int_grow(OBSTACK,datum) \ |
# define obstack_int_grow(OBSTACK,datum) \ |
429 |
__extension__ \ |
__extension__ \ |
430 |
({ struct obstack *__o = (OBSTACK); \ |
({ struct obstack *__o = (OBSTACK); \ |
431 |
if (__o->next_free + sizeof (int) > __o->chunk_limit) \ |
if (__o->next_free + sizeof (int) > __o->chunk_limit) \ |
432 |
_obstack_newchunk (__o, sizeof (int)); \ |
_obstack_newchunk (__o, sizeof (int)); \ |
433 |
*((int *)__o->next_free)++ = ((int)datum); \ |
obstack_int_grow_fast (__o, datum); }) |
434 |
|
|
435 |
|
# define obstack_ptr_grow_fast(OBSTACK,aptr) \ |
436 |
|
__extension__ \ |
437 |
|
({ struct obstack *__o1 = (OBSTACK); \ |
438 |
|
*(const void **) __o1->next_free = (aptr); \ |
439 |
|
__o1->next_free += sizeof (const void *); \ |
440 |
(void) 0; }) |
(void) 0; }) |
441 |
|
|
442 |
# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr) |
# define obstack_int_grow_fast(OBSTACK,aint) \ |
443 |
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) |
__extension__ \ |
444 |
|
({ struct obstack *__o1 = (OBSTACK); \ |
445 |
|
*(int *) __o1->next_free = (aint); \ |
446 |
|
__o1->next_free += sizeof (int); \ |
447 |
|
(void) 0; }) |
448 |
|
|
449 |
# define obstack_blank(OBSTACK,length) \ |
# define obstack_blank(OBSTACK,length) \ |
450 |
__extension__ \ |
__extension__ \ |
452 |
int __len = (length); \ |
int __len = (length); \ |
453 |
if (__o->chunk_limit - __o->next_free < __len) \ |
if (__o->chunk_limit - __o->next_free < __len) \ |
454 |
_obstack_newchunk (__o, __len); \ |
_obstack_newchunk (__o, __len); \ |
455 |
__o->next_free += __len; \ |
obstack_blank_fast (__o, __len); \ |
456 |
(void) 0; }) |
(void) 0; }) |
457 |
|
|
458 |
# define obstack_alloc(OBSTACK,length) \ |
# define obstack_alloc(OBSTACK,length) \ |
525 |
( (h)->temp = (length), \ |
( (h)->temp = (length), \ |
526 |
(((h)->next_free + (h)->temp > (h)->chunk_limit) \ |
(((h)->next_free + (h)->temp > (h)->chunk_limit) \ |
527 |
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ |
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ |
528 |
_obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ |
_obstack_memcpy ((h)->next_free, (where), (h)->temp), \ |
529 |
(h)->next_free += (h)->temp) |
(h)->next_free += (h)->temp) |
530 |
|
|
531 |
# define obstack_grow0(h,where,length) \ |
# define obstack_grow0(h,where,length) \ |
532 |
( (h)->temp = (length), \ |
( (h)->temp = (length), \ |
533 |
(((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ |
(((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ |
534 |
? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ |
? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ |
535 |
_obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ |
_obstack_memcpy ((h)->next_free, (where), (h)->temp), \ |
536 |
(h)->next_free += (h)->temp, \ |
(h)->next_free += (h)->temp, \ |
537 |
*((h)->next_free)++ = 0) |
*((h)->next_free)++ = 0) |
538 |
|
|
539 |
# define obstack_1grow(h,datum) \ |
# define obstack_1grow(h,datum) \ |
540 |
( (((h)->next_free + 1 > (h)->chunk_limit) \ |
( (((h)->next_free + 1 > (h)->chunk_limit) \ |
541 |
? (_obstack_newchunk ((h), 1), 0) : 0), \ |
? (_obstack_newchunk ((h), 1), 0) : 0), \ |
542 |
(*((h)->next_free)++ = (datum))) |
obstack_1grow_fast (h, datum)) |
543 |
|
|
544 |
# define obstack_ptr_grow(h,datum) \ |
# define obstack_ptr_grow(h,datum) \ |
545 |
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ |
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ |
546 |
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ |
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ |
547 |
(*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum))) |
obstack_ptr_grow_fast (h, datum)) |
548 |
|
|
549 |
# define obstack_int_grow(h,datum) \ |
# define obstack_int_grow(h,datum) \ |
550 |
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ |
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ |
551 |
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ |
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ |
552 |
(*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum))) |
obstack_int_grow_fast (h, datum)) |
553 |
|
|
554 |
|
# define obstack_ptr_grow_fast(h,aptr) \ |
555 |
|
(((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) |
556 |
|
|
557 |
# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr) |
# define obstack_int_grow_fast(h,aint) \ |
558 |
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) |
(((int *) ((h)->next_free += sizeof (int)))[-1] = (aptr)) |
559 |
|
|
560 |
# define obstack_blank(h,length) \ |
# define obstack_blank(h,length) \ |
561 |
( (h)->temp = (length), \ |
( (h)->temp = (length), \ |
562 |
(((h)->chunk_limit - (h)->next_free < (h)->temp) \ |
(((h)->chunk_limit - (h)->next_free < (h)->temp) \ |
563 |
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ |
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ |
564 |
((h)->next_free += (h)->temp)) |
obstack_blank_fast (h, (h)->temp)) |
565 |
|
|
566 |
# define obstack_alloc(h,length) \ |
# define obstack_alloc(h,length) \ |
567 |
(obstack_blank ((h), (length)), obstack_finish ((h))) |
(obstack_blank ((h), (length)), obstack_finish ((h))) |