ts-7000
[Top] [All Lists]

[ts-7000] Re: Problems with crosstool gcc on packed structures

To:
Subject: [ts-7000] Re: Problems with crosstool gcc on packed structures
From: "Jesse Off" <>
Date: Tue, 28 Jun 2005 16:23:21 -0000
This is with a struct declared with __attribute__(packed) or no?

Keep in mind ARM needs 32 bit numbers aligned on 32bit boundaries and 
16 bit numbers on 16 bit boundaries.  If you use __attribute__(packed)
on a structure gcc will emit 4 byte loads OR'ed and shifted into a 
32bit register for 32 bit variables, which can give a performance/code 
size penalty.  FYI. 

GCC will always pad sizeof(struct XX) to a 4 byte boundary
partly so you don't end up placing the struct on a non-4 byte aligned 
address when laying out an array.  Aligning the struct on a 4-byte 
boundary allows gcc to emit 32-bit load/stores for accessing members.  
Linux may catch the alignment trap and emulate the correct behavior if 
you violate this, but at another large performance hit.

//Jesse Off

--- In  "manx10004" <> wrote:
> Folks,
> 
>   I have run into a small problem with the suggested gcc compiler.
> The sizeof operator does not yield the correct size of a structure
> when the structure is packed on byte bounderies. Instead the compiler
> seems to give the size up to the next four byte boundery.
> 
>   Offsets of variables within the stucture are correct, and I have 
used
> this property to derive the proper size for the structure which I
> needed for communications. Still, it is an annoyance, and took some
> test code and packet sniffing to diagnose the problem.
> 
>   I hope this helps someone else out of a simular situation.
> Regards




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU