This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

Re: ARM and padding



Looking at your structure, and noting that the data is not word aligned
in the first place, I suspect you may struggle to get this approach to
work - won't the ARM end up totally garbling the word access to the int
field three quarters of the time?

You might prefer to use direct byte reads and manipulations - e.g.

inline int getRemainingBytes( unsigned char *bytes ) {
    unsigned char *ptr = bytes+251;
    return ptr[0]+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);  // or
something like that
}

This also has the virtue that you can cope better if you get endian
blues.

Just my 2c.


jens.ohlund@secrc.abb.se wrote:
> 
> Hi !
> 
> My problem is the following:
> I have an ARM Evaluation Board-1. Rev B. I receive data from a serial line.
> this data is placed in a linear buffer, and then i typecast to a struct of some kind.
> 
> This data which i receive I cannot control, and have therefore to work with it as is.
> 
> The structs contains other structs and so on and in the end it's only 16 or 8 bits values a extract.
> BUT these values are not aligned, and when I typecast I get the wrong values, since the buffer is "packed".
> 
> How do I tell the compiler that the structs are to be packed ?
> 
> I'm developing on NT4, using cygwin and gcc-2.95.2 (arm-elf-gcc).
> 
> yours
> Jens Ohlund
> 
> ------
> Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
> Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com

-- 
Virata http://www.virata.com
Cambridge
Tel: +44 1223 566919      Fax: +44 1223 566915

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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