summaryrefslogtreecommitdiffstats
path: root/lib/libc/mips/string
diff options
context:
space:
mode:
authorjchandra <jchandra@FreeBSD.org>2011-02-22 07:49:51 +0000
committerjchandra <jchandra@FreeBSD.org>2011-02-22 07:49:51 +0000
commit33cfbb02c4e93874e1572097a3acc46e3dfb6ec9 (patch)
tree569ace02e86ced548242b914a71dcd8039491575 /lib/libc/mips/string
parenta8ca1e2aacb49dc2bb0be0cc9e6069353e223528 (diff)
downloadFreeBSD-src-33cfbb02c4e93874e1572097a3acc46e3dfb6ec9.zip
FreeBSD-src-33cfbb02c4e93874e1572097a3acc46e3dfb6ec9.tar.gz
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)
Diffstat (limited to 'lib/libc/mips/string')
-rw-r--r--lib/libc/mips/string/bzero.S20
1 files changed, 1 insertions, 19 deletions
diff --git a/lib/libc/mips/string/bzero.S b/lib/libc/mips/string/bzero.S
index 66f29dd..83e54ba 100644
--- a/lib/libc/mips/string/bzero.S
+++ b/lib/libc/mips/string/bzero.S
@@ -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
OpenPOWER on IntegriCloud