bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

renaming obstack_free


From: Bruno Haible
Subject: renaming obstack_free
Date: Mon, 23 Oct 2006 14:15:03 +0200
User-agent: KMail/1.9.1

Hi,

To follow the Ralf's advice for gnulib code in shared libraries, one needs
to rename the exported symbols. Among those, one finds 'obstack_free'
from the obstack module. Renaming this one is not easy, because
  1. it occurs in obstack.h both as macro and as function name,
  2. any patch should not break the binary compatibility,
  3. any patch should not break glibc.

I propose this one. Paul, do you think you can push that into glibc?


2006-10-20  Bruno Haible  <address@hidden>

        Ability to rename obstack_free.
        * lib/obstack.h (_obstack_free): New macro. Declare instead of
        obstack_free.
        (obstack_free): Invoke the _obstack_free macro.
        * lib/obstack.c (obstack_free): Use _obstack_free macro, then undefine
        it.
        
*** lib/obstack.h       2005-10-15 01:23:50.000000000 +0200
--- lib/obstack.h       2006-10-21 02:54:04.000000000 +0200
***************
*** 1,5 ****
  /* obstack.h - object stack macros
!    Copyright (C) 1988-1994,1996-1999,2003,2004,2005
        Free Software Foundation, Inc.
     This file is part of the GNU C Library.
  
--- 1,5 ----
  /* obstack.h - object stack macros
!    Copyright (C) 1988-1994,1996-1999,2003,2004,2005,2006
        Free Software Foundation, Inc.
     This file is part of the GNU C Library.
  
***************
*** 186,192 ****
                             void (*) (void *, void *), void *);
  extern int _obstack_memory_used (struct obstack *);
  
! void obstack_free (struct obstack *obstack, void *block);
  
   
  /* Error handler called when `obstack_chunk_alloc' failed to allocate
--- 186,197 ----
                             void (*) (void *, void *), void *);
  extern int _obstack_memory_used (struct obstack *);
  
! /* The default name of the function for freeing a chunk is 'obstack_free',
!    but gnulib users can override this by defining '_obstack_free'.  */
! #ifndef _obstack_free
! # define _obstack_free obstack_free
! #endif
! void _obstack_free (struct obstack *obstack, void *block);
  
   
  /* Error handler called when `obstack_chunk_alloc' failed to allocate
***************
*** 399,405 ****
     void *__obj = (OBJ);                                                       
\
     if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit)  \
       __o->next_free = __o->object_base = (char *)__obj;                       
\
!    else (obstack_free) (__o, __obj); })
   
  #else /* not __GNUC__ or not __STDC__ */
  
--- 404,410 ----
     void *__obj = (OBJ);                                                       
\
     if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit)  \
       __o->next_free = __o->object_base = (char *)__obj;                       
\
!    else (_obstack_free) (__o, __obj); })
   
  #else /* not __GNUC__ or not __STDC__ */
  
***************
*** 497,503 ****
      && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk))   \
     ? (int) ((h)->next_free = (h)->object_base                         \
            = (h)->temp.tempint + (char *) (h)->chunk)                  \
!    : (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
  
  #endif /* not __GNUC__ or not __STDC__ */
  
--- 502,508 ----
      && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk))   \
     ? (int) ((h)->next_free = (h)->object_base                         \
            = (h)->temp.tempint + (char *) (h)->chunk)                  \
!    : (((_obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 
0)))
  
  #endif /* not __GNUC__ or not __STDC__ */
  
*** lib/obstack.c       2006-09-19 00:51:16.000000000 +0200
--- lib/obstack.c       2006-10-21 02:57:17.000000000 +0200
***************
*** 342,348 ****
  # undef obstack_free
  
  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 */
--- 342,348 ----
  # undef obstack_free
  
  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 */
***************
*** 372,377 ****
--- 372,378 ----
  }
  
  # ifdef _LIBC
+ #  undef _obstack_free
  /* Older versions of libc used a function _obstack_free intended to be
     called by non-GCC compilers.  */
  strong_alias (obstack_free, _obstack_free)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]