This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] cygwin: x86_64: implement mempcpy/wmempcpy in assembler


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=aea710b5fbaec09ebe29bd32424440723731ec6e

commit aea710b5fbaec09ebe29bd32424440723731ec6e
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Thu Nov 30 10:47:38 2017 +0100

    cygwin: x86_64: implement mempcpy/wmempcpy in assembler
    
    * change memcpy to internal _memcpy not setting the return value in %rax
    * implement all memcpy-like functions as caller to _memcpy, setting %rax
      to correct return value beforehand.  This is possible because _memcpy
      does not use %rax at all
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/miscfuncs.cc | 60 +++++++++++++++++++++++++++++++++-------------
 1 file changed, 44 insertions(+), 16 deletions(-)

diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index a6404c8..923556d 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -824,16 +824,8 @@ asm volatile ("								\n\
  * DAMAGE.								\n\
  */									\n\
 									\n\
-	.globl  memmove							\n\
-	.seh_proc memmove						\n\
-memmove:								\n\
-	.seh_endprologue						\n\
-	nop			/* FALLTHRU */				\n\
-	.seh_endproc							\n\
-									\n\
-	.globl  memcpy							\n\
-	.seh_proc memcpy						\n\
-memcpy:									\n\
+	.seh_proc _memcpy						\n\
+_memcpy:								\n\
 	movq	%rsi,8(%rsp)						\n\
 	movq	%rdi,16(%rsp)						\n\
 	.seh_endprologue						\n\
@@ -841,7 +833,6 @@ memcpy:									\n\
 	movq	%rdx,%rsi						\n\
 	movq	%r8,%rdx						\n\
 									\n\
-	movq	%rdi,%rax	/* return dst */			\n\
 	movq    %rdx,%rcx						\n\
 	movq    %rdi,%r8						\n\
 	subq    %rsi,%r8						\n\
@@ -873,14 +864,39 @@ memcpy:									\n\
 	movq	16(%rsp),%rdi						\n\
 	ret								\n\
 	.seh_endproc							\n\
-");
-
-asm volatile ("								\n\
+									\n\
+	.globl  memmove							\n\
+	.seh_proc memmove						\n\
+memmove:								\n\
+	.seh_endprologue						\n\
+	movq	%rcx,%rax	/* return dst */			\n\
+	jmp	_memcpy							\n\
+	.seh_endproc							\n\
+									\n\
+	.globl  memcpy							\n\
+	.seh_proc memcpy						\n\
+memcpy:									\n\
+	.seh_endprologue						\n\
+	movq	%rcx,%rax	/* return dst */			\n\
+	jmp	_memcpy							\n\
+	.seh_endproc							\n\
+									\n\
+	.globl  memcpy							\n\
+	.seh_proc memcpy						\n\
+mempcpy:									\n\
+	.seh_endprologue						\n\
+	movq	%rcx,%rax	/* return dst  */			\n\
+	addq	%r8,%rax	/*         + n */			\n\
+	jmp	_memcpy							\n\
+	.seh_endproc							\n\
+									\n\
 	.globl  wmemmove						\n\
 	.seh_proc wmemmove						\n\
 wmemmove:								\n\
 	.seh_endprologue						\n\
-	nop			/* FALLTHRU */				\n\
+	shlq	$1,%r8		/* cnt * sizeof (wchar_t) */		\n\
+	movq	%rcx,%rax	/* return dst */			\n\
+	jmp	_memcpy							\n\
 	.seh_endproc							\n\
 									\n\
 	.globl  wmemcpy							\n\
@@ -888,9 +904,21 @@ wmemmove:								\n\
 wmemcpy:								\n\
 	.seh_endprologue						\n\
 	shlq	$1,%r8		/* cnt * sizeof (wchar_t) */		\n\
-	jmp	memcpy							\n\
+	movq	%rcx,%rax	/* return dst */			\n\
+	jmp	_memcpy							\n\
+	.seh_endproc							\n\
+									\n\
+	.globl  wmemcpy							\n\
+	.seh_proc wmemcpy						\n\
+wmempcpy:								\n\
+	.seh_endprologue						\n\
+	shlq	$1,%r8		/* cnt * sizeof (wchar_t) */		\n\
+	movq	%rcx,%rax	/* return dst */			\n\
+	addq	%r8,%rax	/*         + n */			\n\
+	jmp	_memcpy							\n\
 	.seh_endproc							\n\
 ");
+
 #endif
 
 /* Signal the thread name to any attached debugger


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]