Re: Alignment on XScale ARM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 08 November 2008, Nicolas Pitre wrote:
> The ARM processor traditionally cannot access misaligned short and int 
> values in memory.  By using the packed attribute you tell the compiler 
> that the structure should not have inserted padding to align its 
> members, and that accesses are to be performed wth byte accesses and the 
> value reconstructed that way.

... but then when you pass "&misaligned_ptr->member" to some other
function, that other function generally won't know it needs to use
byte access.  So, be careful.  The "packed" struct attribute isn't
a panacea.

General Linux kernel policy is to use <asm/unaligned.h> accessors,
but obviously "packed" has advantages when you've got to pull
structures out of protocol buffers.  The userspace headers don't
seem to support such accessors though.

Also, the network stack is known for making assumptions about its
data being properly aligned.  See how NET_IP_ALIGN is used inside
the kernel; you might be happier aligning your RX buffers before
reading data into them from the kernel.

- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Gstreamer Embedded]     [Linux MMC Devel]     [U-Boot V2]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux ARM Kernel]     [Linux OMAP]     [Linux SCSI]

  Powered by Linux