This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: memcpy to an unaligned address
- From: Shaun Jackman <sjackman at gmail dot com>
- To: Carl Whitwell <carl dot whitwell at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 5 Aug 2005 12:09:38 -0400
- Subject: Re: memcpy to an unaligned address
- References: <345be691050804025955c0b4ab@mail.gmail.com> <7f45d93905080408053411888b@mail.gmail.com> <345be69105080501405eb8663e@mail.gmail.com>
- Reply-to: Shaun Jackman <sjackman at gmail dot com>
On 8/5/05, Carl Whitwell <carl.whitwell@gmail.com> wrote:
> On 8/4/05, Shaun Jackman <sjackman@gmail.com> wrote:
> > Are you using an x86 host and an arm target?
>
> Actually no, my major concern at the time was the large quantity of
> legacy code with packed structures that we have on an embedded linux
> x86 system. I was just testing that we didn't have an issue there with
> the structure access.
The x86 includes hardware to fetch a word from an unaligned address by
fetching from two aligned address and shifting and combining to
produce the correct result. So, unaligned accesses on the x86 might
effect a slight performance hit, but they will still act correctly.
The ARM on the other hand does not include such hardware, so a load
instruction fetching from an unaligned address will behave
incorrectly. My primary concern is really just code correctness.
Cheers,
Shaun