[Pvfs2-developers] offsetof

Sam Lang slang at mcs.anl.gov
Fri Nov 30 12:48:03 EST 2007


On Nov 30, 2007, at 7:51 AM, Pete Wyckoff wrote:

> slang at mcs.anl.gov wrote on Thu, 29 Nov 2007 16:51 -0800:
>> It looks like you added the #include <malloc.h> to pvfs2-types.h to  
>> get the
>> offsetof macro.  That gets defined in stddef.h, and in fact, we  
>> define it
>> later in the header if its not defined at that point. What's the  
>> workaround
>> on Cray that requires the offsetof from malloc.h?
>
> I tried taking it out just now to remind myself.  Most (but not all)
> of the compiled files end up with an error similar to this:
>
>  CC            src/client/sysint/client-state-machine.o
> In file included from /opt/xt-libc/2.0.24a/amd64/include/malloc.h:46,
>                 from ../pvfs2/src/common/llist/llist.h:14,
>                 from ../pvfs2/src/common/misc/server-config.h:11,
>                 from ../pvfs2/src/common/misc/pint-cached-config.h:15,
>                 from ../pvfs2/src/client/sysint/pint-sysint-utils.h: 
> 25,
>                 from ../pvfs2/src/client/sysint/client-state- 
> machine.c:14:
> /opt/gcc/4.1.2/cnos/lib/gcc-lib/x86_64-suse-linux/4.1.2//include/ 
> stddef.h:414:1: warning: "offsetof" redefined
> In file included from ../pvfs2/include/pvfs2-sysint.h:23,
>                 from ../pvfs2/src/client/sysint/client-state- 
> machine.c:13:
> ../pvfs2/include/pvfs2-types.h:37:1: warning: this is the location  
> of the previous definition
>
> That stddef.h file is in the normal gcc install.  It has the
> offsetof() definition at the end of the file.  llist.h picks it
> up due to needing malloc.h.
>
> Our pvfs2-types.h definition of offsetof comes first, then later the
> system stddef.h tries to provide one and spits an error.  I just
> tried to system include to the top.
>
> If I change the line I added to #include <stddef.h>, things work
> just fine.  Maybe this is the more correct fix?
>
> Not sure what your complaint about including malloc.h is, but we
> probably should change that to stddef.h anyway.  Feel free to check
> this in yourself, or tell me what should be going on with these
> headers.

No complaint, its just that malloc and offsetof are defined in  
stddef.h on most linuxes today.  I guess your point is that we don't  
handle the case where malloc.h is still used.  As I understand it the  
problem you're seeing is that we #include <stddef.h> in some source  
files ahead of pvfs2-types.h.

I would get rid of the specific malloc.h in pvfs2-types.h, and then  
maybe remove the stddef.h includes in our sources as well, so that  
only the pvfs2-types.h includes it.

We could also move the #ifndef offsetof to the places where its used  
(quicklist.h) as well, to avoid the error you're seeing on Cray.
-sam

>
>
> 		-- Pete
>



More information about the Pvfs2-developers mailing list