aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2018-09-17 15:49:35 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2018-09-17 15:49:35 +0000
commit23ec0d58bf2008a8dfa6466f0c0dcc27c2312b0f (patch)
tree2e03e809308335de08a1ccc0b0285515d15fd8af /lib
parent09a6ada9919eac191b28e72fedfa9fa06e50b176 (diff)
Notes
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/amd64/string/bcopy.S7
-rw-r--r--lib/libc/i386/string/bcopy.S13
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/libc/amd64/string/bcopy.S b/lib/libc/amd64/string/bcopy.S
index cc38f4755254..eca7a23d7721 100644
--- a/lib/libc/amd64/string/bcopy.S
+++ b/lib/libc/amd64/string/bcopy.S
@@ -66,6 +66,9 @@ ENTRY(bcopy)
movsq
movq %rdx,%rcx
andq $7,%rcx /* any bytes left? */
+ jne 2f
+ ret
+2:
rep
movsb
ret
@@ -73,11 +76,13 @@ ENTRY(bcopy)
addq %rcx,%rdi /* copy backwards. */
addq %rcx,%rsi
std
- andq $7,%rcx /* any fractional bytes? */
decq %rdi
decq %rsi
+ andq $7,%rcx /* any fractional bytes? */
+ je 3f
rep
movsb
+3:
movq %rdx,%rcx /* copy remainder by words */
shrq $3,%rcx
subq $7,%rsi
diff --git a/lib/libc/i386/string/bcopy.S b/lib/libc/i386/string/bcopy.S
index 89576f379d6a..4c653d744f15 100644
--- a/lib/libc/i386/string/bcopy.S
+++ b/lib/libc/i386/string/bcopy.S
@@ -64,7 +64,7 @@ ENTRY(bcopy)
movl %edi,%edx
subl %esi,%edx
cmpl %ecx,%edx /* overlapping? */
- jb 1f
+ jb 2f
cld /* nope, copy forwards. */
movl %ecx,%edx
shrl $2,%ecx /* copy by words */
@@ -72,21 +72,28 @@ ENTRY(bcopy)
movsl
movl %edx,%ecx
andl $3,%ecx /* any bytes left? */
+ jne 1f
+ popl %edi
+ popl %esi
+ ret
+1:
rep
movsb
popl %edi
popl %esi
ret
-1:
+2:
addl %ecx,%edi /* copy backwards. */
addl %ecx,%esi
std
movl %ecx,%edx
- andl $3,%ecx /* any fractional bytes? */
decl %edi
decl %esi
+ andl $3,%ecx /* any fractional bytes? */
+ je 3f
rep
movsb
+3:
movl %edx,%ecx /* copy remainder by words */
shrl $2,%ecx
subl $3,%esi