On 23/07/13 09:53, Dominic Fandrey wrote:
> So I propose keeping the boundary check, but getting rid of the
> alignment check. Patches are attached.

> + r0 = opStack[opStackOfs] = *(int *) &image[r0 & dataMask ];

This is now dereferencing an int* that is not guaranteed to be
sizeof(int)-aligned, which is not portable away from x86. On x86 it's
slow but works as intended (for historical reasons), but on RISC CPUs
like ARM and PowerPC it will usually do something wrong: it will
typically either be fixed-up by the kernel at a massive performance
penalty (much greater than x86), read the int above or below[1], read
the int above or below rotated by the appropriate number of bits[2], or
crash.

The 2-byte version is the same, but with 2- instead of 4-byte
grouping/alignment.

Similarly, unaligned writes might either work as intended, overwrite the
wrong bytes, overwrite the wrong bytes with the wrong value, or crash.

    S

[1] for instance if the address is 5 and memory contains hex bytes
"00 01 02 03 | 04 05 06 07 | 08..." where | denotes a 4-byte boundary,
it might return 0x04050607 instead of the intended 0x05060708
[2] for instance in the situation above it might return 0x05060704

_______________________________________________
ioquake3 mailing list
ioquake3@lists.ioquake.org
http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org
By sending this message I agree to love ioquake3 and libsdl.

Reply via email to