summaryrefslogtreecommitdiff
path: root/libc/string/arm
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-06-12 06:12:21 +0000
committerEric Andersen <andersen@codepoet.org>2004-06-12 06:12:21 +0000
commit2ca977faefda1b8c807291e3ee4a817d919b44de (patch)
tree9c2966a903b36603424699d4c15cfa45726f4974 /libc/string/arm
parentca001ed767bc2643d1c875fd4240942867949baa (diff)
Philip Craig at snapgear dot com writes:
Strlen was counting the last 3 bytes incorrectly for big endian arm.
Diffstat (limited to 'libc/string/arm')
-rw-r--r--libc/string/arm/strlen.S11
1 files changed, 10 insertions, 1 deletions
diff --git a/libc/string/arm/strlen.S b/libc/string/arm/strlen.S
index a84114c31..65ee94d99 100644
--- a/libc/string/arm/strlen.S
+++ b/libc/string/arm/strlen.S
@@ -59,12 +59,21 @@ Laligned: @ here, we have a word in r2. Does it
ldrne r2, [r1], $4 @ and we continue to the next word
bne Laligned @
Llastword: @ drop through to here once we find a
- tst r2, $0x000000ff @ word that has a zero byte in it
+#if __BYTE_ORDER == __BIG_ENDIAN
+ tst r2, $0xff000000 @ word that has a zero byte in it
+ addne r0, r0, $1 @
+ tstne r2, $0x00ff0000 @ and add up to 3 bytes on to it
+ addne r0, r0, $1 @
+ tstne r2, $0x0000ff00 @ (if first three all non-zero, 4th
+ addne r0, r0, $1 @ must be zero)
+#else
+ tst r2, $0x000000ff @
addne r0, r0, $1 @
tstne r2, $0x0000ff00 @ and add up to 3 bytes on to it
addne r0, r0, $1 @
tstne r2, $0x00ff0000 @ (if first three all non-zero, 4th
addne r0, r0, $1 @ must be zero)
+#endif
mov pc,lr
.size strlen,.-strlen;