public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] RE: Byte array address alignment
@ 2005-10-26  6:31 Uwe Kindler
  2005-10-26 16:23 ` Alexander Neundorf
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kindler @ 2005-10-26  6:31 UTC (permalink / raw)
  To: ecos-discuss; +Cc: embeddedeng

Hello,

not all compilers align byte arrays to a 4 byte boundary on a 32 bit 
machine or to a 2 byte boundary on a 16 bit machine. Even the GNU 
comiler does not follow these alignment rules for all machines. For 
example the h8300-elf toolchain does not align byte arrays and this is a 
big problem for eCos development because the eCos source code contains a 
number of byte arrays (i.e. the idle thread stack) that are expected to 
be aligned. In my opinion, if a certain alignment of arrays is required 
it should be explicit declared by using another data type (i.e. short or 
long).

Regards, Uwe

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] RE: Byte array address alignment
  2005-10-26  6:31 [ECOS] RE: Byte array address alignment Uwe Kindler
@ 2005-10-26 16:23 ` Alexander Neundorf
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Neundorf @ 2005-10-26 16:23 UTC (permalink / raw)
  To: ecos-discuss

On Wednesday 26 October 2005 08:30, Uwe Kindler wrote:
> Hello,
>
> not all compilers align byte arrays to a 4 byte boundary on a 32 bit
> machine or to a 2 byte boundary on a 16 bit machine. Even the GNU
> comiler does not follow these alignment rules for all machines. For
> example the h8300-elf toolchain does not align byte arrays and this is a
> big problem for eCos development because the eCos source code contains a
> number of byte arrays (i.e. the idle thread stack) that are expected to
> be aligned. In my opinion, if a certain alignment of arrays is required
> it should be explicit declared by using another data type (i.e. short or
> long).

Or even better and more explicit:
char buf[1024] __attribute__ ((aligned(4))); //or whatever alignment you need
This also doesn't require changing the type.

Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-10-26 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-26  6:31 [ECOS] RE: Byte array address alignment Uwe Kindler
2005-10-26 16:23 ` Alexander Neundorf

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).