Subject: Re: Strange C compiler code generation
To: Richard Earnshaw <rearnsha@buzzard.freeserve.co.uk>
From: Todd Vierling <tv@wasabisystems.com>
List: port-arm32
Date: 02/24/2001 19:48:33
On Sun, 25 Feb 2001, Richard Earnshaw wrote:

: > > Are your structures marked as packed?  If not, what compilation flags are
: > > being used?
: >
: > Hm. They are. But: Still all variables are 32 bit aligned!

: > One example structure looks like this:
: >
: > #pragma pack(1)

: #prgama pack(1) means that this structure can appear at *any* address
: (that's part of the definition of a packed structure).

Which means, AVOID PACKED STRUCTURES.  They will cause you headaches.  Take
"#pragma pack" and throw it out the window with extreme prejudice.  Since
you didn't write the code in question, obviously someone who did is
EXCEEDINGLY boneheaded (not to mention probably x86-centric, since >98% of
code that uses packed structures comes from the x86).

If everything is 32-bit quantities in the code, and you can verify that the
struct is only assigned 32-bit aligned pointer addresses, remove the
"#pragma pack", and you'll get your speed back.

-- 
-- Todd Vierling <tv@wasabisystems.com>  *  Wasabi NetBSD:  Run with it.
-- NetBSD 1.5 now available on CD-ROM  --  http://www.wasabisystems.com/