patch-2.2.18 linux/arch/arm/lib/memchr.S

Next file: linux/arch/arm/lib/memcpy.S
Previous file: linux/arch/arm/lib/loaders.S
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/arch/arm/lib/memchr.S linux/arch/arm/lib/memchr.S
@@ -0,0 +1,33 @@
+/*
+ * linux/arch/arm/lib/memchr.S
+ *
+ * Copyright (C) 1995-1999 Russell King
+ *
+ * ASM optimised string functions
+ *
+ */
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+#include "constants.h"
+
+		.text
+
+@ I have this hunch that this one can be optimised further.
+@ Beware false optimisation of ldrb the byte BEYOND the end of buffer (could
+@ be beyond end of memory) before testing to see if length had been exhausted
+@ on the previous byte.
+ENTRY(memchr)				@ 2nd argument char
+		stmfd	sp!, {lr}
+		and	r1, r1, #0xff	@ cast 2nd argument to char
+		add	r2, r2, r0	@ Point to end (exclusive)
+
+1:		teq	r0, r2
+		beq	2f		@ No more to do
+		ldrb	r3, [r0], #1
+		teq	r3, r1
+		bne	1b
+		sub	r0, r0, #1
+		LOADREGS(fd, sp!, {pc})
+
+2:		mov	r0, #0		@ Got to end and not found.
+		LOADREGS(fd, sp!, {pc})

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)