From: Brendan Kehoe Date: Mon, 17 Apr 1995 22:02:01 +0000 (+0000) Subject: * sysdeps/alpha/strlen.c (strlen): Fix cmpbge insn, and returning X-Git-Tag: glibc-2.16-ports-before-merge~3924 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fd1e71567ef998ce868f81eba43cfa9d22f79373;p=thirdparty%2Fglibc.git * sysdeps/alpha/strlen.c (strlen): Fix cmpbge insn, and returning of the byte that was zero, so we return a valid number. --- diff --git a/sysdeps/alpha/strlen.c b/sysdeps/alpha/strlen.c index d7744476ad6..36f106c9c31 100644 --- a/sysdeps/alpha/strlen.c +++ b/sysdeps/alpha/strlen.c @@ -36,19 +36,20 @@ strlen (const char *str) for (;;) { + const unsigned long int longword = *longword_ptr++; int mask; - asm ("cmpbge %1, %2, %0" : "=r" (mask) : "r" (0), "r" (*longword_ptr++)); + + /* Set bits in MASK if bytes in LONGWORD are zero. */ + asm ("cmpbge $31, %1, %0" : "=r" (mask) : "r" (longword)); if (mask) { /* Which of the bytes was the zero? */ - const char *cp = (const char *) (longword_ptr - 1); int i; - for (i = 0; i < 6; i++) + for (i = 0; i < 8; i++) if (cp[i] == 0) return cp - str + i; - return cp - str + 7; } } }