Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2009-03-25 21:56:15 +0300
committerJeff Johnston <jjohnstn@redhat.com>2009-03-25 21:56:15 +0300
commitbaea11cd6a53ccde63b5fefa4c7ae2b5426a668d (patch)
tree78068ca8c7a7b1a1d79599008b105d77fa2aa469 /newlib
parent0b211e340fc1d1a6cfd7d2d21d8cbd233865ce71 (diff)
2009-03-25 Richard Earnshaw <rearnsha@arm.com>
* libc/machine/arm/strcmp.c (strcmp_unaligned): Correctly detect the nul-byte in a big-endian string.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog5
-rw-r--r--newlib/libc/machine/arm/strcmp.c34
2 files changed, 33 insertions, 6 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 26e3dbb99..61c899fae 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-25 Richard Earnshaw <rearnsha@arm.com>
+
+ * libc/machine/arm/strcmp.c (strcmp_unaligned): Correctly
+ detect the nul-byte in a big-endian string.
+
2009-03-25 Jeff Johnston <jjohnstn@redhat.com>
* libc/string/wcsdup.c: Fix documentation error.
diff --git a/newlib/libc/machine/arm/strcmp.c b/newlib/libc/machine/arm/strcmp.c
index d34bae094..0d0c3d363 100644
--- a/newlib/libc/machine/arm/strcmp.c
+++ b/newlib/libc/machine/arm/strcmp.c
@@ -192,6 +192,7 @@ strcmp_unaligned(const char* s1, const char* s2)
} \
if (__builtin_expect(((w1 - b1) & ~w1) & (b1 << 7), 0)) \
{ \
+ /* See comment in assembler below re syndrome on big-endian */\
if ((((w1 - b1) & ~w1) & (b1 << 7)) & mask) \
w2 RSHIFT= shift; \
else \
@@ -319,12 +320,22 @@ strcmp_unaligned(const char* s1, const char* s2)
"b 8f\n"
"5:\n\t"
- "bics r3, r3, #"MSB"\n\t"
+#ifdef __ARMEB__
+ /* The syndrome value may contain false ones if the string ends
+ with the bytes 0x01 0x00 */
+ "tst w1, #0xff000000\n\t"
+ "itt ne\n\t"
+ "tstne w1, #0x00ff0000\n\t"
+ "tstne w1, #0x0000ff00\n\t"
+ "beq 7f\n\t"
+#else
+ "bics r3, r3, #0xff000000\n\t"
"bne 7f\n\t"
+#endif
"ldrb w2, [wp2]\n\t"
SHFT2LSB" t1, w1, #24\n\t"
#ifdef __ARMEB__
- SHFT2LSB" w2, w2, #24\n\t"
+ "lsl w2, w2, #24\n\t"
#endif
"b 8f\n"
@@ -353,12 +364,21 @@ strcmp_unaligned(const char* s1, const char* s2)
"b 2b\n"
"5:\n\t"
- SHFT2MSB"s r3, r3, #16\n\t"
+#ifdef __ARMEB__
+ /* The syndrome value may contain false ones if the string ends
+ with the bytes 0x01 0x00 */
+ "tst w1, #0xff000000\n\t"
+ "it ne\n\t"
+ "tstne w1, #0x00ff0000\n\t"
+ "beq 7f\n\t"
+#else
+ "lsls r3, r3, #16\n\t"
"bne 7f\n\t"
+#endif
"ldrh w2, [wp2]\n\t"
SHFT2LSB" t1, w1, #16\n\t"
#ifdef __ARMEB__
- SHFT2LSB" w2, w2, #16\n\t"
+ "lsl w2, w2, #16\n\t"
#endif
"b 8f\n"
@@ -390,8 +410,10 @@ strcmp_unaligned(const char* s1, const char* s2)
SHFT2LSB" w2, w2, #24\n\t"
"b 8f\n"
"5:\n\t"
- "tst r3, #128\n\t"
- "bne 7f\n\t"
+ /* The syndrome value may contain false ones if the string ends
+ with the bytes 0x01 0x00 */
+ "tst w1, #"LSB"\n\t"
+ "beq 7f\n\t"
"ldr w2, [wp2], #4\n"
"6:\n\t"
SHFT2LSB" t1, w1, #8\n\t"