From owner-svn-src-all@FreeBSD.ORG Tue Feb 22 07:49:51 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C964106564A; Tue, 22 Feb 2011 07:49:51 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B6448FC0C; Tue, 22 Feb 2011 07:49:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p1M7np9m098770; Tue, 22 Feb 2011 07:49:51 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1M7npLt098768; Tue, 22 Feb 2011 07:49:51 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201102220749.p1M7npLt098768@svn.freebsd.org> From: "Jayachandran C." Date: Tue, 22 Feb 2011 07:49:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218939 - head/lib/libc/mips/string X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Feb 2011 07:49:51 -0000 Author: jchandra Date: Tue Feb 22 07:49:51 2011 New Revision: 218939 URL: http://svn.freebsd.org/changeset/base/218939 Log: Fix bzero() for 64-bit. The existing implementation of bzero incorrectly clears bytes when the start address is not word aligned. Fix it by using REG_SHI macro which works on both 32 and 64 bit. Submitted by: Artem Belevich (fbsdlist at src cx) Modified: head/lib/libc/mips/string/bzero.S Modified: head/lib/libc/mips/string/bzero.S ============================================================================== --- head/lib/libc/mips/string/bzero.S Tue Feb 22 05:13:26 2011 (r218938) +++ head/lib/libc/mips/string/bzero.S Tue Feb 22 07:49:51 2011 (r218939) @@ -58,27 +58,9 @@ LEAF(bzero) PTR_SUBU a3, zero, a0 # compute # bytes to word align address and a3, a3, SZREG-1 beq a3, zero, 1f # skip if word aligned -#if SZREG == 4 PTR_SUBU a1, a1, a3 # subtract from remaining count - SWHI zero, 0(a0) # clear 1, 2, or 3 bytes to align + REG_SHI zero, 0(a0) # clear 1, 2, or 3 bytes to align PTR_ADDU a0, a0, a3 -#endif -#if SZREG == 8 - PTR_SUBU a1, a1, a3 # subtract from remaining count - PTR_ADDU a0, a0, a3 # align dst to next word - sll a3, a3, 3 # bits to bytes - li a2, -1 # make a mask -#if _BYTE_ORDER == _BIG_ENDIAN - REG_SRLV a2, a2, a3 # we want to keep the MSB bytes -#endif -#if _BYTE_ORDER == _LITTLE_ENDIAN - REG_SLLV a2, a2, a3 # we want to keep the LSB bytes -#endif - nor a2, zero, a2 # complement the mask - REG_L v0, -SZREG(a0) # load the word to partially clear - and v0, v0, a2 # clear the bytes - REG_S v0, -SZREG(a0) # store it back -#endif 1: and v0, a1, SZREG-1 # compute number of words left PTR_SUBU a3, a1, v0