Module Name:    src
Committed By:   dsl
Date:           Sat Jul 11 08:48:52 UTC 2009

Modified Files:
        src/common/lib/libc/arch/x86_64/string: strlen.S

Log Message:
Change comments about algorithms, 99.6% for random data isn't 'rare' in my book!
(The 'rare' case is any byte values 0x80-0xff.)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/x86_64/string/strlen.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/x86_64/string/strlen.S
diff -u src/common/lib/libc/arch/x86_64/string/strlen.S:1.1 src/common/lib/libc/arch/x86_64/string/strlen.S:1.2
--- src/common/lib/libc/arch/x86_64/string/strlen.S:1.1	Tue Dec 20 19:28:51 2005
+++ src/common/lib/libc/arch/x86_64/string/strlen.S	Sat Jul 11 08:48:51 2009
@@ -6,7 +6,7 @@
 #include <machine/asm.h>
 
 #if defined(LIBC_SCCS)
-	RCSID("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:51 christos Exp $")
+	RCSID("$NetBSD: strlen.S,v 1.2 2009/07/11 08:48:51 dsl Exp $")
 #endif
 
 ENTRY(strlen)
@@ -74,9 +74,9 @@
 	 * (3)  ((x - 0x01....01) & 0x80....80)
 	 *
 	 * always evaluates to a non-zero value if any of the bytes in
-	 * the original word is zero.  However, in rare cases, it also
-	 * evaluates to a non-zero value when none of the bytes in the
-	 * original word is zero.
+	 * the original word is zero or has the top bit set.
+	 * For strings that are likely to only contain 7-bit ascii these
+	 * false positives will be rare.
 	 *
 	 * To account for possible false positives, each byte of the
 	 * original word must be checked when the expression evaluates to
@@ -110,7 +110,7 @@
 	je	.Lloop
 
 	/*
-	 * In rare cases, the above loop may exit prematurely. We must
+	 * For bytes 0x80-0xff the above loop will exit prematurely. We must
 	 * return to the loop if none of the bytes in the word equal 0.
 	 */
 	cmpb	$0,-8(%rax)		/* 1st byte == 0? */

Reply via email to