This is the mail archive of the ecos-discuss@sourceware.org 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]
Other format: [Raw text]

Re: pragma pack


On 2008-01-09, Paul D. DeRocco <pderocco@ix.netcom.com> wrote:
>> From: Bronislav Gabrhelik
>> 
>> Beware of bad alignment of timestamp field. Some processors 
>> might raise an exception/interrupt when you use the int like 
>> operation directly on field (including assignment & 
>> evaluation). You should copy out/in this by memcpy into/from 
>> temporary variable of the same type when you need to do some 
>> integer computing on this field. In other case your code 
>> might not be portable.
>
> I think that's the point of the __packed__ attribute: it
> forces the compiler for any machine on which it matters to do
> the necessary byte packing/unpacking automagically. I know
> that's what the Gnu ARM compiler does.

The trap snaps shut when you take the address of a field in a
packed struct and pass that to somebody who's expecting a
pointer to a normally aligned value.

-- 
Grant Edwards                   grante             Yow! I am covered with
                                  at               pure vegetable oil and I am
                               visi.com            writing a best seller!


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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