[openib-general] compilation platform dependencies

Grant Grundler iod00d at hp.com
Thu Nov 3 08:52:52 PST 2005


Hi Roland,
since no one smarter touched this....

On Tue, Nov 01, 2005 at 12:10:56PM -0800, Roland Dreier wrote:
>     > I've seen use of this use of "data[0]":
>     > include/rdma/ib_user_verbs.h:   __u64 driver_data[0];
>     > 
>     > isn't that for the same purpose?
>     > Apologies if I'm mixing things up...
> 
> The driver_data[] in ib_user_verbs.h is really there to give a hint
> that extra device-dependent data could follow.  Reserved members of
> structs are used to pad it up to a 64-bit boundary.

Yeah, this is the right way to do it. I just wasn't sure.

> I'm not sure if __u64 driver_data[0]; forces alignment to an 8-byte
> boundary on i386... does it?

I'm now convinced it doesn't on x86.
See output below.

thanks,
grant

grundler <481>uname -a
Linux ob500 2.6.13 #6 Sat Oct 1 23:58:35 PDT 2005 i686 GNU/Linux
grundler <482>cat alignment_test.c
#include <stdio.h>
#include <stddef.h>

struct foo {
        int y;
	unsigned  long long x;
};

int main(void)
{
	return printf("offset of x is %d\n", offsetof(struct foo, x));
}
grundler <483>make alignment_test
cc     alignment_test.c   -o alignment_test
grundler <484>./alignment_test 
offset of x is 4




More information about the general mailing list