summaryrefslogtreecommitdiff
path: root/lib/libc/arch/i386/string/strchr.S
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/arch/i386/string/strchr.S')
-rw-r--r--lib/libc/arch/i386/string/strchr.S26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/libc/arch/i386/string/strchr.S b/lib/libc/arch/i386/string/strchr.S
index f76e593fcd0..453cdd6c281 100644
--- a/lib/libc/arch/i386/string/strchr.S
+++ b/lib/libc/arch/i386/string/strchr.S
@@ -1,3 +1,23 @@
-/* $OpenBSD: strchr.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
-#define STRCHR
-#include "index.S"
+/* $OpenBSD: strchr.S,v 1.4 2014/11/30 19:43:56 deraadt Exp $ */
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+ALTENTRY(index)
+ENTRY(strchr)
+ movl 4(%esp),%eax
+ movb 8(%esp),%cl
+ .align 2,0x90
+L1:
+ movb (%eax),%dl
+ cmpb %dl,%cl /* found char??? */
+ je L2
+ incl %eax
+ testb %dl,%dl /* null terminator??? */
+ jnz L1
+ xorl %eax,%eax
+L2:
+ ret