[Linux-ha-dev] Patch for pils.c and plugin.h for dev tip.
Dejan Muhamedagic
dejanmm at fastmail.fm
Thu Dec 11 09:03:43 MST 2008
On Thu, Dec 11, 2008 at 06:35:57AM -0500, Davin Flatten wrote:
> On Thu, Dec 11, 2008 at 6:02 AM, Dejan Muhamedagic <dejanmm at fastmail.fm>wrote:
> > > Dejan-
> > >
> > > Looks like the definitions of g_malloc and g_realloc changes from minor
> > > version 14 -> 16. Redhat 5.2 uses the 2.12.3 so using the gsize format
> > > doesn't compile. I added some preprocessor directives to define these
> > areas
> > > of code correctly depending on the glib version. Does this patch work
> > for
> > > you?
> >
> > Yes, it does. Though it'd be better to create an extra header
> > to hide #ifdefs of the glib type du jour from the code.
> >
> > Cheers,
> >
> > Dejan
> >
> > > Thanks!
> > > Davin
> >
> > > diff -r f343aa2db1a4 include/pils/plugin.h.in
> > > --- a/include/pils/plugin.h.in Wed Dec 10 17:25:09 2008 +0100
> > > +++ b/include/pils/plugin.h.in Wed Dec 10 21:34:16 2008 -0500
> > > @@ -442,9 +442,14 @@
> > > , void* plugin_private);
> > >
> > > void (*log) (PILLogLevel priority, const char * fmt, ...);
> > > - void* (*alloc)(size_t size);
> > > - void* (*mrealloc)(void * ptr, size_t size);
> > > - void (*mfree)(void* space);
> > > +#if GLIB_MINOR_VERSION <= 14
> > > + gpointer (*alloc)(gulong size);
> > > + gpointer (*mrealloc)(gpointer space, gulong size);
> > > +#else
> > > + gpointer (*alloc)(gsize size);
> > > + gpointer (*mrealloc)(gpointer space, gsize size);
> > > +#endif
> > > + void (*mfree)(gpointer space);
> > > char* (*mstrdup)(const char *s);
> > > };
> > >
> > > @@ -465,8 +470,13 @@
> > >
> > > /* Change memory allocation functions right after creating universe */
> > > void PilPluginUnivSetMemalloc(PILPluginUniv*
> > > -, void* (*alloc)(size_t size)
> > > -, void* (*mrealloc)(void *, size_t size)
> > > +#if GLIB_MINOR_VERSION <= 14
> > > +, gpointer (*alloc)(gulong size)
> > > +, gpointer (*mrealloc)(gpointer, gulong size)
> > > +#else
> > > +, gpointer (*alloc)(gsize size)
> > > +, gpointer (*mrealloc)(gpointer, gsize size)
> > > +#endif
> > > , void (*mfree)(void* space)
> > > , char* (*mstrdup)(const char *s));
> > >
> > > diff -r f343aa2db1a4 lib/pils/pils.c
> > > --- a/lib/pils/pils.c Wed Dec 10 17:25:09 2008 +0100
> > > +++ b/lib/pils/pils.c Wed Dec 10 21:34:16 2008 -0500
> > > @@ -492,8 +492,13 @@
> > > /* Change memory allocation functions immediately after creating
> > universe */
> > > void
> > > PilPluginUnivSetMemalloc(PILPluginUniv* u
> > > -, void* (*allocfun)(size_t size)
> > > -, void* (*reallocfun)(void * ptr, size_t size)
> > > +#if GLIB_MINOR_VERSION <= 14
> > > +, gpointer (*allocfun)(gulong size)
> > > +, gpointer (*reallocfun)(gpointer ptr, gulong size)
> > > +#else
> > > +, gpointer (*allocfun)(gsize size)
> > > +, gpointer (*reallocfun)(gpointer ptr, gsize size)
> > > +#endif
> > > , void (*freefun)(void* space)
> > > , char* (*strdupfun)(const char *s))
> > > {
> > > diff -r f343aa2db1a4 tools/send_arp.linux.c
> > > --- a/tools/send_arp.linux.c Wed Dec 10 17:25:09 2008 +0100
> > > +++ b/tools/send_arp.linux.c Wed Dec 10 21:34:16 2008 -0500
> > > @@ -35,7 +35,7 @@
> > > static void usage(void) __attribute__((noreturn));
> > >
> > > int quit_on_reply=0;
> > > -char *device = NULL;
> > > +const char *device = NULL;
> > > int ifindex;
> > > char *source;
> > > struct in_addr src, dst;
> >
> > > _______________________________________________________
> > > Linux-HA-Dev: Linux-HA-Dev at lists.linux-ha.org
> > > http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> > > Home Page: http://linux-ha.org/
> >
> > _______________________________________________________
> > Linux-HA-Dev: Linux-HA-Dev at lists.linux-ha.org
> > http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> > Home Page: http://linux-ha.org/
> >
>
> Dejan-
>
> This is where my C inexperience shows. Are you saying to make two
> definitions of the structures surrounded in #if #elsif #endif directives?
No, the idea is to put #define or typedef for various glib types
in a separate header file, so that we do not repeat #if
statements. We also probably need another #elsif for earlier
glib2 releases.
> Do you want me to do this and provide a patch?
No, I think I'll do that. But many thanks for pushing the
discussion.
Cheers,
Dejan
>
> Thanks for the help.
>
> -Davin
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev at lists.linux-ha.org
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
More information about the Linux-HA-Dev
mailing list