Re: Equivalent of __packed for arm-linux-gcc ?
On Thu, Jul 15, 2004 at 10:03:46AM +0530, amith wrote:
> Hi all,
> Quoted from "http://www.arm.com/support/faqdev/1228.html".
This refers to the C compiler from ARM Ltd, which is not related to
gcc at all.
> the following definition would work armcc :
> How can i declare something of this kind using arm-linux-gcc?
> __packed int *pi; // pointer to unaligned int
There is no equivalent compiler directive in gcc. The reason is because
the hardware itself cannot perform the unaligned access, and the only
way around this is to make several smaller reads (two 16-bit reads
for example, or 4 bytes) and then combine them.
This is inefficient, which is why gcc does not give you a directive
like "__packed" to try and encorage this behaviour.
Fix the code to not do unaligned accesses, if possible. If you must,
there already exist functions for doing unaligned reads and writes
which you can use.