[PATCH] cygwin: export wmempcpy
Corinna Vinschen
corinna-cygwin@cygwin.com
Thu Nov 30 09:49:00 GMT 2017
On Nov 30 10:27, Corinna Vinschen wrote:
> On Nov 29 19:48, Yaakov Selkowitz wrote:
> > Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
> > ---
> > Obviously this depends on the newlib implementation patch.
> >
> > winsup/cygwin/common.din | 1 +
> > winsup/cygwin/include/cygwin/version.h | 3 ++-
> > winsup/doc/posix.xml | 1 +
> > 3 files changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din
> > index a482cf2b7..14b9c2c18 100644
> > --- a/winsup/cygwin/common.din
> > +++ b/winsup/cygwin/common.din
> > @@ -1609,6 +1609,7 @@ wmemchr NOSIGFE
> > wmemcmp NOSIGFE
> > wmemcpy NOSIGFE
> > wmemmove NOSIGFE
> > +wmempcpy NOSIGFE
> > wmemset NOSIGFE
> > wordexp NOSIGFE
> > wordfree NOSIGFE
> > diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
> > index d8bb3ee44..7510f42b0 100644
> > --- a/winsup/cygwin/include/cygwin/version.h
> > +++ b/winsup/cygwin/include/cygwin/version.h
> > @@ -489,12 +489,13 @@ details. */
> > __stack_chk_fail, __stack_chk_guard, __stpcpy_chk, __stpncpy_chk,
> > __strcat_chk, __strcpy_chk, __strncat_chk, __strncpy_chk,
> > __vsnprintf_chk, __vsprintf_chk.
> > + 321: Export wmempcpy.
> >
> > Note that we forgot to bump the api for ualarm, strtoll, strtoull,
> > sigaltstack, sethostname. */
> >
> > #define CYGWIN_VERSION_API_MAJOR 0
> > -#define CYGWIN_VERSION_API_MINOR 320
> > +#define CYGWIN_VERSION_API_MINOR 321
> >
> > /* There is also a compatibity version number associated with the shared memory
> > regions. It is incremented when incompatible changes are made to the shared
> > diff --git a/winsup/doc/posix.xml b/winsup/doc/posix.xml
> > index c99e003ba..ab574300f 100644
> > --- a/winsup/doc/posix.xml
> > +++ b/winsup/doc/posix.xml
> > @@ -1396,6 +1396,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
> > wcstoll_l
> > wcstoul_l
> > wcstoull_l
> > + wmempcpy
> > </screen>
> >
> > </sect1>
> > --
> > 2.15.0
>
> Basically ok, but shouldn't we use the assembler implementation of
> memcpy/wmemcpy in miscfuncs.cc for x86_64 mempcpy/wmempcpy as well?
Kind of like the below patch. Can you test the mempcpy and wmempcy
return values for correctness?
Thanks,
Corinna
commit 243cbdf45cc48d885d821fdcda438101ff209bc0
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Thu Nov 30 10:47:38 2017 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: 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 --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index a6404c85e808..923556d1f4cc 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
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20171130/42c7552a/attachment.sig>
More information about the Cygwin-patches
mailing list