On Feb 12, 2009, at 8:34 AM, Jille Timmermans wrote:
Julian Stacey schreef:
1) Is it worth my time trying to rearrange structs?
I wondered whether as a sensitivity test, some version of gcc (or
its competitor ?) might have capability to automatically re-order
variables ? but found nothing in man gcc "Optimization Options".
There is a __packed attribute, I don't know what it exactly does and
whether it is an improvement.
__packed is always a gross pessimization. The side-effect of
packing a structure is that the alignment of the structure
drops to 1. That means that any field will be read 1 byte at
a time and reconstructed by logical operations.
For best results, __packed should be used with __aligned(X),
in case __packed is needed of course to address the side-
effect. Of course multi-byte fields that are unaligned in
the structure as the result of packing, will still be read
in parts.
In other words: don't use __packed when you don't have to.
--
Marcel Moolenaar
xcl...@mac.com
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"