[parisc-linux] gcc-3.[02] alignment problem
Richard Henderson
rth@redhat.com
Tue, 16 Jul 2002 13:21:08 -0700
On Tue, Jul 16, 2002 at 10:22:55AM -0700, Randolph Chung wrote:
> __u32 tcpdiag_cookie[2];
> #define TCPDIAG_NOCOOKIE (~0U)
> };
>
> the code goes on to do:
> *((struct sock **)&r->id.tcpdiag_cookie) = sk;
> and
> sk != *((struct sock **)&req->id.tcpdiag_cookie[0]))
This is absolutely awful.
> the "vomit grade hack" alan mentioned in another post is that in our
> tree, we have:
>
> struct tcpdiag_sockid
> {
> __u16 tcpdiag_sport;
> __u16 tcpdiag_dport;
> __u32 tcpdiag_src[4];
> __u32 tcpdiag_dst[4];
> __u32 tcpdiag_if;
> #if defined (__hppa__) && defined (__LP64__)
> char * parisc_hack_to_align_tcpdiag_cookie;
> #endif
> __u32 tcpdiag_cookie[2];
An only marginally better fix is
__u32 tcpdiag_cookie[2] __attribute__((aligned(sizeof(void*))));
Note that this should be unconditional so that the other
64-bit ports don't take an alignment trap here too.
A much nicer fix would be to, gasp, use a union.
r~