Subject: Re: lib/29248: memchr.S
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: J.T. Conklin <jtc@acorntoolworks.com>
List: netbsd-bugs
Date: 02/06/2005 15:38:01
The following reply was made to PR lib/29248; it has been noted by GNATS.
From: jtc@acorntoolworks.com (J.T. Conklin)
To: Geoff Wing <gcw@pobox.com>
Cc: NetBSD GNATS <gnats-bugs@netbsd.org>
Subject: Re: lib/29248: memchr.S
Date: Sun, 06 Feb 2005 07:37:12 -0800
Geoff Wing <gcw@pobox.com> writes:
> OK, this fixes my problems. Maybe memset.S strchr.S strrchr.S also
> need similar clearing on %ecx.
Thanks for tracking this down. My str* and mem* regression test never
checked for "character" arguments with values in their high bytes.
Zero extending the value when it's read from the stack frame is better
than clearing it later.
Here is a patch for memchr.S, strchr.S, and strrchr.S. Memset already
used movzbl.
--jtc
--- memchr.S 2004/04/14 02:10:40 1.8
+++ memchr.S 2005/02/06 15:26:57
@@ -12,7 +12,7 @@
ENTRY(memchr)
pushl %esi
movl 8(%esp),%eax
- movl 12(%esp),%ecx
+ movzbl 12(%esp),%ecx
movl 16(%esp),%esi
/*
@@ -29,6 +29,7 @@
incl %eax
decl %esi
jnz .Lalign
+ jmp .Lzero
.Lword_aligned:
/* copy char to all bytes in word */
--- strchr.S 2004/04/14 02:17:24 1.9
+++ strchr.S 2005/02/06 15:30:52
@@ -17,7 +17,7 @@
pushl %esi
pushl %ebx
movl 12(%esp),%eax
- movl 16(%esp),%ecx
+ movzbl 16(%esp),%ecx
/*
* Align to word boundary.
--- strrchr.S 2004/04/16 16:41:10 1.7
+++ strrchr.S 2005/02/06 15:31:04
@@ -18,7 +18,7 @@
pushl %edi
pushl %ebx
movl 16(%esp),%edx
- movl 20(%esp),%ecx
+ movzbl 20(%esp),%ecx
/* zero return value */
xorl %eax,%eax
--
J.T. Conklin