Source-Changes-D archive

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

Re: CVS commit: src/tests/lib/libc/gen



On Mon, 23 Apr 2012 19:02:04 +0100, David Laight wrote:
On Mon, Apr 23, 2012 at 10:09:09AM +0200, Jean-Yves Migeon wrote:
>
> But, as has been pointed out before, code in libc will generate
> alignment traps - because it is faster that way.

I did not know -- care to give an example? #AC exception from amd64 was not working, so I would guess that this was not used for this port at least.

memcpy() between misaligned addresses will do misaligned reads, writes
or both. (aligning reads is best on amd cpus)

memset() will do an unaligned store to the last word of the buffer
prior to filling the rest of the buffer. (IIRC memcpy/memmove do similar.)

Any access to a packed structure relies on misaligned transfers.
eg: the 'sector number' fields in the disk mbr.
    in 64bit mode any code that has to match the alignment of
    64bit items from 32bit code.

Basically, on i386 and amd64 (and other cpus that allow misaligned
accesses) if a buffer has to match an external representation
that contains misaligned items, then misaligned tranfers are very
likely to be used.

So although the cpu supports the trap, the os doesn't expect
it to be enabled.

I see; thanks for the details. That explains why this feature is rarily seen or used on x86.

--
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost


Home | Main Index | Thread Index | Old Index