This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


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

Re: data alignment issues




> Any comments on this alignment?  I thought the gcc compiler didn't do
> any alignment?

The compiler has to perform alignment since the ARM processor used will only read 32 bit words
on a 4 bytes boundary. As already written in one of the previous posts, a fetch of a 32 bit words
from a non aligned boundary will result in an exception.
To prevent any alignment problems, gcc will align all members on a word boundary (which is
a 4 byte boundary for the ARM core).

> Anyhow, I just ran a test.  I have the structure below.  All the char
> fields are just dummy values to test data alignment issues when sending
> the structure over the network to my PC.  Apparently, the PC compiler

You should never send structures to another platform in the hope that the alignment of structures
(and data widths of the members) are the same.
If both targets use the same alignment style and endianes this might work, you could check this
by populating a structure on both targets in the same way and comparing the actual memory content.

> I've forgotten how to read floats in hex! :)

That what computers are for:

     float f = 10.0;

     if(sizeof(f) == 4)
          printf("Your float reads %08X in hex.\n", *(int *) &f);

(you C ...)

Regards,

     Rob Jansen

Software Engineer
Competence Center Platforms
BU Mobile Communications
Meijhorst 60-10, 6537 KT Nijmegen, The Netherlands
Tel: +31-24-353-6329
Fax: +31-24-353-3613
mailto:Rob.WJ.Jansen@philips.com




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