Re: Alignment - Structures and Other Things

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 13, 2011 at 9:56 PM, kevin diggs <diggskevin38@xxxxxxxxx> wrote:
> Even if it doesn't break it will likely incur a performance penalty
> from unaligned accesses, right?

Yes, in best case it will only be slow.
(however, you may have a 8 bit CPU or so, needing byte-boundary
alignment only :)).

I had some ARM boards where things like
  ((struct foo*)(&recv_buf[123]))->mess.cmd
do crash (but code was not generated with gcc), as far as I know
it is possible that compilers generate code to access using
multiple aligned access instructions, but I guess some CPUs do
this internally automatically (because the same binary code did
not crash on different [older/smaller/slower] ARM CPUs).

So I think the code example with (struct f*)(malloc(s)+1) may run
(slowly) in exceptional/lucky cases, but is not correct and
should be fixed, if possible.

oki,

Steffen


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux