This is the mail archive of the ecos-discuss@sourceware.cygnus.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: Packed on a Arm Evaulation Board


Try this:

struct snejs
{
  char bokstav1 __attribute__((aligned(2));
  char bokstav2 __attribute__((aligned(2));
  char bokstav3 __attribute__((aligned(2));
  char bokstav4 __attribute__((aligned(2));
  short siffra1;
  long siffra2;
} mojs;

or even this:

struct snejs
{
  char bokstav1; char foo1;
  char bokstav2; char foo2;
  char bokstav3; char foo3;
  char bokstav4;
  short siffra1;
  long siffra2;
} mojs;


jens.ohlund@secrc.abb.se writes:
> Hi !
>
> Well, didn't work. The code looks like:
>   struct snejs
>   {
>     char bokstav1;
>     char bokstav2;
>     char bokstav3;
>     char bokstav4;
>     short siffra1;
>     long siffra2;
>   } mojs;
>
> And I tried to put the __attribute__ before snejs and after mojs, I tried to
> change the aligned(1) to aligned(2) as well.
>
> yours Jens
>
>
>
>
>
> ecos-discuss-owner@sourceware.cygnus.com 2000-06-20 16:36
>
>
> To: jens.ohlund@secrc.abb.se cc: ecos-discuss@sourceware.cygnus.com Subject:
> RE: [ECOS] Packed on a Arm Evaulation Board
>
> Security Level:?  Internal
>
>
> Try
>
>   struct ABC { ...whatever... } __attribute__ ((aligned(1), packed));
>
> On 20-Jun-00 jens.ohlund@secrc.abb.se wrote:
> > Hi!
> >
> > I'm having a problem, I can't find out how to align data on even bytes.
> >
> > That is, if I create a struct with 4 uint8 (unsigned char) I want the struct
> >to be 8 bytes in size.
> >
> > Why ? It's a requirment for a jvm I try to run. I've tried with
> >__attribute__ ((packed)), which I thought worked when I tried to make a
> >struct with one byte, one short and one interger.  But I had lots of "funny"
> >errors so I checked it up a bit more just to se that that 2 unsigned chars
> >used only 16 bit together, not 16 bits EACH.
> >
> > Anybody got any idea how I should do instead ?
> >
> > yours Jens Ohlund
> >
> >
> >


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