This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ARM packed structures


On Wed, Nov 29, 2006 at 07:05:45PM +0000, Dimitry Andric wrote:
>
> Caputo, Tim wrote:
>
> >I am having a problem with structures using the arm cross complier I've
> >built.  Initially I noticed that my structures were not being packed in
> >memory.  I realize now that this is meant to be efficient, however, I
> >need to share these structures with legacy code on another processor and
> >with specialty hardware that both expect/need them to be packed.  I
> >tried the pragma route, the attribute route and finally was successful
> >packing my structures with the directive -fpack_struct.
> 
> Don't do that.  Read the gcc manual, and use __attribute__((packed))
> instead.

Another alternative is -mstructure-size-boundary={8,32}, depending on
the types of alignment issues you're having.  Tagging all your struct
definitions with __attribute__((__packed__)) may solve a larger set of
issues.

> >Unfortunately this resulted the compiler being extremely conservative in
> >how it accessed elements of the struct.  It now reads one byte at a time
> >from memory and reconstructs longwords in registers (I assume it is
> >worried about the whole structure being unaligned in memory.)
> 
> It is not "worried", arm processors just *require* you to do this
> dance.  It depends on the specific cpu model how complicated the dance
> is. :)

To get the minimum size dance required by your particular CPU, tell GCC
which architecture or which particular core it is with -march= or -mcpu=.


                          -----Carl

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]