ARM Patch: correctly deal with big-endian string termination

Richard Earnshaw Richard.Earnshaw@buzzard.freeserve.co.uk
Wed Mar 25 08:27:00 GMT 2009


If a word loaded from the string being compared contains the byte-pair
0x01000 at any position within the word (ie 0xXXXX0100, 0xXX0100XX or
0x0100XXXX) then the syndrome value calculated by the zero-detection
algorithm will contain 0x8080 at the position of these two bytes.

On a little-endian machine this makes no difference to the behaviour of
the algorithm because the interesting bytes (if any) are in the least
significant part of the word; but on big-endian machines the 0x01 byte
is the last byte in the string.  We therefore have to handle this case
by testing each of the last bytes explicitly.

2009-03-24  Richard Earnshaw  <rearnsha@arm.com>

	* libc/machine/arm/strcmp.c (strcmp_unaligned): Correctly
	detect the nul-byte in a big-endian string.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: strcmp.patch
Type: text/x-patch
Size: 2856 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20090325/55435597/attachment.bin>


More information about the Newlib mailing list