This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: misaligned access
- To: Mike Stump <mrs at windriver dot com>
- Subject: Re: misaligned access
- From: Davy Durham <david dot durham at wcom dot com>
- Date: Wed, 13 Dec 2000 13:22:41 -0600
- Cc: gcc at gcc dot gnu dot org
- Organization: WorldCom
- References: <200012131746.JAA16972@kankakee.wrs.com>
Mike Stump wrote:
> > Date: Wed, 13 Dec 2000 11:09:30 -0600
> > From: Davy Durham <david.durham@wcom.com>
> > To: gcc@gcc.gnu.org
>
> > And I can point a foo * anywhere to any address not aligned i.e.
> > anywhere in the buffer'o'data... And I don't get a bus error on
> > sparc.... I tested it..
>
> The only issue, which I am sure you already know about, but I mention
> it for others that might not know, packing does change the structure
> layout, so you have to be sure the start address of each element you
> want to get at, is at the right place.
>
Well, of course.... ;)
>
> Also, you could also memcpy to a suitably aligned location, and then
> use it out of there. And last, ABI compatibility across platforms
> with structures can be problematic (non-portable). gcc needs a way to
> have a machine and platform independent layout format and expose that
> to the C programmer. Programmers already do this, and already expect
> it to work. :-(
>
Yes, I suggested the memcpy solution to the guy who _actually_ has the
problem (my very original posting was on his behalf)... He that would be
to (time) inefficient.. But smart as he is.... I couldn't convince him
that 3 shifts and 4 load/stores for EVERY variable access in his program
is even *MORE* inefficient...
>
> Thanks for sharing your solution.
Oh sure... I'm just glad this solution will now be found when someone
searches in the archives for "misalign" (which is what I did some time
ago)
-- Davy