From 21bfcecf7a4ac3c150430a1a312268781c145414 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 30 Aug 2013 10:43:39 -0700 Subject: [PATCH] Make armv6t2 strlen work in ARM mode too. --- ports/ChangeLog.arm | 5 +++++ ports/sysdeps/arm/armv6t2/strlen.S | 27 +++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ports/ChangeLog.arm b/ports/ChangeLog.arm index 2a95834..1806b08 100644 --- a/ports/ChangeLog.arm +++ b/ports/ChangeLog.arm @@ -1,3 +1,8 @@ +2013-08-30 Roland McGrath + + * sysdeps/arm/armv6t2/strlen.S: Include first thing. + [NO_THUMB]: Adapt code for ARM mode. + 2013-08-30 Will Newton [BZ #15909] diff --git a/ports/sysdeps/arm/armv6t2/strlen.S b/ports/sysdeps/arm/armv6t2/strlen.S index a52e2e7..4652c20 100644 --- a/ports/sysdeps/arm/armv6t2/strlen.S +++ b/ports/sysdeps/arm/armv6t2/strlen.S @@ -21,6 +21,7 @@ */ +#include /* This might #define NO_THUMB. */ #include #ifdef __ARMEB__ @@ -31,9 +32,24 @@ #define S2HI lsl #endif - /* This code requires Thumb. */ +#ifndef NO_THUMB +/* This code is best on Thumb. */ .thumb - .syntax unified +#else +/* Using bne.w explicitly is desirable in Thumb mode because it helps + align the following label without a nop. In ARM mode there is no + such difference. */ +.macro bne.w label + bne \label +.endm + +/* This clobbers the condition codes, which the real Thumb cbnz instruction + does not do. But it doesn't matter for any of the uses here. */ +.macro cbnz reg, label + cmp \reg, #0 + bne \label +.endm +#endif /* Parameters and result. */ #define srcin r0 @@ -130,9 +146,16 @@ ENTRY(strlen) tst tmp1, #4 pld [src, #64] S2HI tmp2, const_m1, tmp2 +#ifdef NO_THUMB + mvn tmp1, tmp2 + orr data1a, data1a, tmp1 + itt ne + orrne data1b, data1b, tmp1 +#else orn data1a, data1a, tmp2 itt ne ornne data1b, data1b, tmp2 +#endif movne data1a, const_m1 mov const_0, #0 b .Lstart_realigned -- 2.7.4