Mercurial > hg > octave-nkf > gnulib-hg
changeset 4805:8f430f14ff21
Merge changes from glibc obstack; minor cleanups to make it easier to
merge back in the future.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 22 Oct 2003 05:10:04 +0000 |
parents | d0a345595720 |
children | 151b8ba4ab1d |
files | lib/ChangeLog lib/obstack.c lib/obstack.h |
diffstat | 3 files changed, 38 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,18 @@ 2003-10-21 Paul Eggert <eggert@twinsun.com> + * obstack.c: Merge from glibc. + [defined _LIBC]: Include <obstack.h>, not "obstack.h". + Add libc_hidden_def (_obstack_newchunk). + (_obstack_free) [! defined _LIBC]: Remove. + [defined _LIBC]: Make a strong alias from obstack_free, rather than + a clone of the function body. + (fputs) [defined _LIBC && defined USE_IN_LIBIO]: Remove. + [defined _LIBC && !defined USE_IN_LIBIO]: Include <libio/iolibio.h>. + + * obstack.h: Indenting cleanup, to make it easier to merge with glibc. + (obstack_grow, obstack_grow0): Remove unnecessary parentheses around + arg to memcpy. + * obstack.h (obstack_1grow_fast): Properly parenthesize arg. (obstack_ptr_grow_fast, obstack_int_grow_fast): Don't use lvalue casts, as GCC plans to remove support for them
--- a/lib/obstack.c +++ b/lib/obstack.c @@ -21,7 +21,11 @@ # include <config.h> #endif +#ifdef _LIBC +#include <obstack.h> +#else #include "obstack.h" +#endif /* NOTE BEFORE MODIFYING THIS FILE: This version number must be incremented whenever callers compiled using an old obstack.h can no @@ -282,6 +286,9 @@ /* The new chunk certainly contains no empty object yet. */ h->maybe_empty_object = 0; } +#ifdef _LIBC +libc_hidden_def (_obstack_newchunk) +#endif /* Return nonzero if object OBJ has been allocated from obstack H. This is here for debugging. @@ -314,41 +321,6 @@ # undef obstack_free -/* This function has two names with identical definitions. - This is the first one, called from non-ANSI code. */ - -void -_obstack_free (struct obstack *h, void *obj) -{ - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ - - lp = h->chunk; - /* We use >= because there cannot be an object at the beginning of a chunk. - But there can be an empty object at that address - at the end of another chunk. */ - while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj)) - { - plp = lp->prev; - CALL_FREEFUN (h, lp); - lp = plp; - /* If we switch chunks, we can't tell whether the new current - chunk contains an empty object, so assume that it may. */ - h->maybe_empty_object = 1; - } - if (lp) - { - h->object_base = h->next_free = (char *) (obj); - h->chunk_limit = lp->limit; - h->chunk = lp; - } - else if (obj != 0) - /* obj is not in any of the chunks! */ - abort (); -} - -/* This function is used from ANSI code. */ - void obstack_free (struct obstack *h, void *obj) { @@ -378,6 +350,12 @@ /* obj is not in any of the chunks! */ abort (); } + +#ifdef _LIBC +/* Older versions of libc used a function _obstack_free intended to be + called by non-GCC compilers. */ +strong_alias (obstack_free, _obstack_free) +#endif int _obstack_memory_used (struct obstack *h) @@ -400,9 +378,8 @@ # endif # define _(msgid) gettext (msgid) -# if defined _LIBC && defined USE_IN_LIBIO +# ifdef _LIBC # include <libio/iolibio.h> -# define fputs(s, f) _IO_fputs (s, f) # endif # ifndef __attribute__
--- a/lib/obstack.h +++ b/lib/obstack.h @@ -248,30 +248,30 @@ #define obstack_alignment_mask(h) ((h)->alignment_mask) /* To prevent prototype warnings provide complete argument list. */ -# define obstack_init(h) \ +#define obstack_init(h) \ _obstack_begin ((h), 0, 0, \ (void *(*) (long)) obstack_chunk_alloc, \ (void (*) (void *)) obstack_chunk_free) -# define obstack_begin(h, size) \ +#define obstack_begin(h, size) \ _obstack_begin ((h), (size), 0, \ (void *(*) (long)) obstack_chunk_alloc, \ (void (*) (void *)) obstack_chunk_free) -# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ +#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ _obstack_begin ((h), (size), (alignment), \ (void *(*) (long)) (chunkfun), \ (void (*) (void *)) (freefun)) -# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ +#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ _obstack_begin_1 ((h), (size), (alignment), \ (void *(*) (void *, long)) (chunkfun), \ (void (*) (void *, void *)) (freefun), (arg)) -# define obstack_chunkfun(h, newchunkfun) \ +#define obstack_chunkfun(h, newchunkfun) \ ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) -# define obstack_freefun(h, newfreefun) \ +#define obstack_freefun(h, newfreefun) \ ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) #define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar)) @@ -322,7 +322,7 @@ int __len = (length); \ if (__o->next_free + __len > __o->chunk_limit) \ _obstack_newchunk (__o, __len); \ - memcpy (__o->next_free, (where), __len); \ + memcpy (__o->next_free, where, __len); \ __o->next_free += __len; \ (void) 0; }) @@ -332,7 +332,7 @@ int __len = (length); \ if (__o->next_free + __len + 1 > __o->chunk_limit) \ _obstack_newchunk (__o, __len + 1); \ - memcpy (__o->next_free, (where), __len); \ + memcpy (__o->next_free, where, __len); \ __o->next_free += __len; \ *(__o->next_free)++ = 0; \ (void) 0; }) @@ -456,14 +456,14 @@ ( (h)->temp = (length), \ (((h)->next_free + (h)->temp > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - memcpy ((h)->next_free, (where), (h)->temp), \ + memcpy ((h)->next_free, where, (h)->temp), \ (h)->next_free += (h)->temp) # define obstack_grow0(h,where,length) \ ( (h)->temp = (length), \ (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ - memcpy ((h)->next_free, (where), (h)->temp), \ + memcpy ((h)->next_free, where, (h)->temp), \ (h)->next_free += (h)->temp, \ *((h)->next_free)++ = 0) @@ -517,7 +517,7 @@ (h)->object_base = (h)->next_free, \ (void *) __INT_TO_PTR ((h)->temp)) -# define obstack_free(h,obj) \ +# define obstack_free(h,obj) \ ( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ ? (int) ((h)->next_free = (h)->object_base \