From: David Brownell <david-b@pacbell.net>
To: Nicolas Pitre <nico@cam.org>,
Marcus Tangermann <Marcus.Tangermann@web.de>
Cc: linux-embedded@vger.kernel.org
Subject: Re: Alignment on XScale ARM
Date: Sat, 8 Nov 2008 10:02:48 -0800 [thread overview]
Message-ID: <200811081002.48890.david-b@pacbell.net> (raw)
In-Reply-To: <alpine.LFD.2.00.0811081029500.13034@xanadu.home>
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
next prev parent reply other threads:[~2008-11-08 18:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-07 22:52 Alignment on XScale ARM Marcus Tangermann
2008-11-08 14:22 ` Will Newton
2008-11-08 15:37 ` Nicolas Pitre
2008-11-08 18:02 ` David Brownell [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-11-08 18:37 Marcus Tangermann
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=200811081002.48890.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=Marcus.Tangermann@web.de \
--cc=linux-embedded@vger.kernel.org \
--cc=nico@cam.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.