bug-hurd
[Top][All Lists]
Advanced

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

Re: kalloc.c and recent gcc's


From: Thomas Schwinge
Subject: Re: kalloc.c and recent gcc's
Date: Mon, 29 Aug 2005 00:49:42 +0200
User-agent: Mutt/1.5.9i

Note that this is not my patch we're discussing, but as Alfred is
currently on vacations, ...

On Sun, Aug 28, 2005 at 02:51:37PM -0700, Thomas Bushnell BSG wrote:
> Thomas Schwinge <schwinge-lists-gnu.org-bug-hurd@nic-nac-project.de> writes:
> >> > +void (*__malloc_initialize_hook) (void) = (void *) init_hook;
> >> 
> >> Do you really need the void * cast?
> 
> > The cast avoids the following warning:
> > [...]
> 
> Ideally, fix the declaration of init_hook.

That's exactly where the problem lies.
Alfred seems to have created the patch using glibc's documentation as an
example, only that there is an error in that documentation:
<URL:http://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html#index-g_t_005f_005fmalloc_005finitialize_005fhook-283>
#v+
     /* Prototypes for __malloc_hook, __free_hook */
     #include <malloc.h>
     
     /* Prototypes for our hooks.  */
     static void *my_init_hook (void);
[...]
     /* Override initializing hook from the C library. */
     void (*__malloc_initialize_hook) (void) = my_init_hook;
     
     static void
     my_init_hook (void)
     {
[...]
#v-

I'll report that in glibc's bugzilla.


So, we need the following:
#v+
static void init_hook (void);
[...]
void (*__malloc_initialize_hook) (void) = init_hook;
[...]
static void
init_hook (void) {
[...]
#v-


Can we be sure that we don't have to also hook realloc() and memalign()?


> Failing that, at least
> give a correct cast instead of kludging with void *.
> 
> void (*__malloc_initialize_hook) (void) = (void (*)(void)) init_hook;

That's also what I did before having a look at glibc's documentation.


Neal, could you please fix the patch accordingly before checking it in?
Or is some testing needed?  (I don't know how to do that, here.)


Regards,
> Thomas

(Recycled.  ;-)




reply via email to

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