public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Bronislav Gabrhelik" <discuss@ahojky.com>
To: thekyz@gmail.com
Cc: "eCos discuss mailing list" <ecos-discuss@ecos.sourceware.org>
Subject: Re: [ECOS] pragma pack
Date: Wed, 09 Jan 2008 21:55:00 -0000	[thread overview]
Message-ID: <7b2a34230801091355n355da963lce9b0264e1c99653@mail.gmail.com> (raw)
In-Reply-To: <d5aafeec0801090656o7f8bce14v258392fa75ad1791@mail.gmail.com>

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.

Best Regards
Bronislav Gabrhelik

2008/1/9, Alexandre <thekyz@gmail.com>:
> Thanks a lot to all of you,
>
> I'm gonna try what you wrote to see if it works Olaf, but what Andrew
> told me resolved the problem. My structure is now defined like this:
>
> typedef struct __attribute__ ((__packed__)) s_pelco_pattern_array{
>       cyg_uint8 command2_byte;
>       cyg_uint8       data3;
>       cyg_uint8       data4;
>       cyg_uint16      timestamp;
> } pelco_pattern_array;
>
> and is actually 5 bytes large :)
>
> I was reffering to this page of the gcc doc for the "pack" pragma and
> thought it would work, maybe what Bernard pointed should also help
> resolve the problem about the pragma:
>
> http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html
>
> Again, thanks a lot, i'm still gonna push a little my research on this
> matter and i'll get you all updated.
>
> Alex Garcia
> Hymatom SA
>
> PS: Sorry for the double mail Bernard :(
>
> --
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
>

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

  reply	other threads:[~2008-01-09 21:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-09 14:19 Alexandre
2008-01-09 14:40 ` Andrew Lunn
2008-01-09 14:51 ` Bernard Fouché
2008-01-09 14:56   ` Alexandre
2008-01-09 21:55     ` Bronislav Gabrhelik [this message]
2008-01-09 22:22       ` Paul D. DeRocco
2008-01-09 23:50         ` [ECOS] " Grant Edwards
2008-01-10  0:50           ` Paul D. DeRocco
2008-01-10  9:43             ` Alexandre
2008-01-10 10:07               ` EXTERNAL Gladis Olaf (Praktikant; CR/AEM)
2008-01-10 10:29                 ` Alexandre
2008-01-09 15:02 ` [ECOS] " EXTERNAL Gladis Olaf (Praktikant; CR/AEM)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7b2a34230801091355n355da963lce9b0264e1c99653@mail.gmail.com \
    --to=discuss@ahojky.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=thekyz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).