summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorstas <stas@FreeBSD.org>2009-06-21 12:58:56 +0000
committerstas <stas@FreeBSD.org>2009-06-21 12:58:56 +0000
commit4cb23c58c6ceb80017c2195d4fe9f27465c1949f (patch)
treea2cee5c321760f1e8d161670be1958aa6ce72780 /lib
parent3b006b3918667037f262d7d9d30668323e7a9d16 (diff)
downloadFreeBSD-src-4cb23c58c6ceb80017c2195d4fe9f27465c1949f.zip
FreeBSD-src-4cb23c58c6ceb80017c2195d4fe9f27465c1949f.tar.gz
- Fix strncmp on arm. Return 0 as result without performing the
main cycle only if the len passed is equal to 0. If end address overflows use last possible address as the end address. Based on: discussion on arm@ MFC after: 1 month
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/arm/string/strncmp.S14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/libc/arm/string/strncmp.S b/lib/libc/arm/string/strncmp.S
index d172264..5beff41 100644
--- a/lib/libc/arm/string/strncmp.S
+++ b/lib/libc/arm/string/strncmp.S
@@ -33,13 +33,17 @@
__FBSDID("$FreeBSD$");
ENTRY(strncmp)
-/* if ((len - 1) < 0) return 0 */
- subs r2, r2, #1
- movmi r0, #0
- movmi pc, lr
+/* if (len == 0) return 0 */
+ cmp r2, #0
+ moveq r0, #0
+ moveq pc, lr
/* ip == last src address to compare */
- add ip, r0, r2
+ adds ip, r0, r2
+ sub ip, ip, #1
+/* Use last possible address on overflow. */
+ movcs ip, #0
+ subcs ip, ip, #1
1:
ldrb r2, [r0], #1
ldrb r3, [r1], #1
OpenPOWER on IntegriCloud