svn commit: r203343 - head/sys/netinet

M. Warner Losh imp at bsdimp.com
Mon Feb 1 17:58:03 UTC 2010


In message: <20100202012830.B1230 at besplex.bde.org>
            Bruce Evans <brde at optusnet.com.au> writes:
: Rev.1.30 attempted to fix this by also adding the __aligned(4)
: attribute.
: I haven't checked that this works.  It adds additional unportability
: and
: ugliness.

__packed is necessary for ARM where the rules of the ABI we use are
such that this structure isn't properly packed otherwise.[*]

__aligned(4) tells the compiler that pointers to this structure are
4-byte aligned, which helps on many platforms generate more optimal
code.

The root cause of all this mess is that 'C' doesn't have any good,
easy ways to specify "on the wire" formats of structures.  So we have
to play these games to make the headers we snarfed off the wire match
the C structs that we're using to access the fields in those
structures.  We are necessarily in unportability land here.  It is
only by the chance alignment of the x86 ABI and the wire format that
the project was able to ignore the issue for so long...

Warner

[*] Of course, it could be argued that ARM should use a different
and/or better ABI for newer cores, and I'd agree with that...  But
until that's fixed, we have to cope.


More information about the svn-src-head mailing list