From: Ian Campbell Subject: [PATCH 08/17] xen: arm32: add optimised strchr and strrchr routines Date: Thu, 20 Mar 2014 15:45:56 +0000 Message-ID: <1395330365-9901-8-git-send-email-ian.campbell@citrix.com> References: <1395330336.3104.12.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1395330336.3104.12.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org Taken from Linux v3.14-rc7. These aren't widely used enough to be critical, but we may as well have them. Signed-off-by: Ian Campbell --- xen/arch/arm/arm32/lib/Makefile | 1 + xen/arch/arm/arm32/lib/strchr.S | 29 +++++++++++++++++++++++++++++ xen/arch/arm/arm32/lib/strrchr.S | 28 ++++++++++++++++++++++++++++ xen/include/asm-arm/string.h | 12 ++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 xen/arch/arm/arm32/lib/strchr.S create mode 100644 xen/arch/arm/arm32/lib/strrchr.S diff --git a/xen/arch/arm/arm32/lib/Makefile b/xen/arch/arm/arm32/lib/Makefile index fa4e241..e9fbc59 100644 --- a/xen/arch/arm/arm32/lib/Makefile +++ b/xen/arch/arm/arm32/lib/Makefile @@ -2,4 +2,5 @@ obj-y += memcpy.o memmove.o memset.o memchr.o memzero.o obj-y += findbit.o setbit.o obj-y += setbit.o clearbit.o changebit.o obj-y += testsetbit.o testclearbit.o testchangebit.o +obj-y += strchr.o strrchr.o obj-y += lib1funcs.o lshrdi3.o div64.o diff --git a/xen/arch/arm/arm32/lib/strchr.S b/xen/arch/arm/arm32/lib/strchr.S new file mode 100644 index 0000000..f01740e --- /dev/null +++ b/xen/arch/arm/arm32/lib/strchr.S @@ -0,0 +1,29 @@ +/* + * linux/arch/arm/lib/strchr.S + * + * Copyright (C) 1995-2000 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ASM optimised string functions + */ + +#include + +#include "assembler.h" + + .text + .align 5 +ENTRY(strchr) + and r1, r1, #0xff +1: ldrb r2, [r0], #1 + teq r2, r1 + teqne r2, #0 + bne 1b + teq r2, r1 + movne r0, #0 + subeq r0, r0, #1 + mov pc, lr +ENDPROC(strchr) diff --git a/xen/arch/arm/arm32/lib/strrchr.S b/xen/arch/arm/arm32/lib/strrchr.S new file mode 100644 index 0000000..88fc0de --- /dev/null +++ b/xen/arch/arm/arm32/lib/strrchr.S @@ -0,0 +1,28 @@ +/* + * linux/arch/arm/lib/strrchr.S + * + * Copyright (C) 1995-2000 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ASM optimised string functions + */ + +#include + +#include "assembler.h" + + .text + .align 5 +ENTRY(strrchr) + mov r3, #0 +1: ldrb r2, [r0], #1 + teq r2, r1 + subeq r3, r0, #1 + teq r2, #0 + bne 1b + mov r0, r3 + mov pc, lr +ENDPROC(strrchr) diff --git a/xen/include/asm-arm/string.h b/xen/include/asm-arm/string.h index 2c9f4f7..7d8b35a 100644 --- a/xen/include/asm-arm/string.h +++ b/xen/include/asm-arm/string.h @@ -4,6 +4,18 @@ #include #if defined(CONFIG_ARM_32) + +/* + * We don't do inline string functions, since the + * optimised inline asm versions are not small. + */ + +#define __HAVE_ARCH_STRRCHR +extern char * strrchr(const char * s, int c); + +#define __HAVE_ARCH_STRCHR +extern char * strchr(const char * s, int c); + #define __HAVE_ARCH_MEMCPY extern void * memcpy(void *, const void *, __kernel_size_t); -- 1.7.10.4