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. David -- David Laight: da...@l8s.co.uk