[uClibc] strlen for ARM big endian
Arne Jonsson
arne.jonsson at i3micro.com
Thu Feb 12 12:05:46 UTC 2004
Hi!
I believe there is a problem with libc/string/arm/strlen.S when running
in big endian mode.
I think I reported this once upon a time to some glibc-guy but either I
didn't do that or the patch was not liked at all.
The diff is made against uClibc-0.9.26.
Best regards,
Arne Jonsson
i3 micro technology AB
Phone:+46-8-506 388 00
Fax: +46-8-506 388 75
===== patch below =======
--- strlen.S.org Thu Feb 12 12:39:16 2004
+++ strlen.S Thu Feb 12 11:39:38 2004
@@ -51,6 +51,23 @@
orrgt r2, r2, $0x00ff0000 @ then set.
#endif
Laligned: @ here, we have a word in r2.
Does it
+#if __BYTE_ORDER == __BIG_ENDIAN
+ tst r2, $0xff000000 @ contain any zeroes?
+ tstne r2, $0x00ff0000 @
+ tstne r2, $0x0000ff00 @
+ tstne r2, $0x000000ff @
+ addne r0, r0, $4 @ if not, the string is 4 bytes
longer
+ ldrne r2, [r1], $4 @ and we continue to the next
word
+ bne Laligned @
+Llastword: @ drop through to here once we
find a
+ 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)
+ mov pc,lr
+#else
tst r2, $0x000000ff @ contain any zeroes?
tstne r2, $0x0000ff00 @
tstne r2, $0x00ff0000 @
@@ -66,6 +83,6 @@
tstne r2, $0x00ff0000 @ (if first three all non-zero,
4th
addne r0, r0, $1 @ must be zero)
mov pc,lr
-
+#endif
.size strlen,.-strlen;
More information about the uClibc
mailing list