diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2017-11-30 10:47:38 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2017-11-30 21:15:28 +0100 |
commit | aea710b5fbaec09ebe29bd32424440723731ec6e (patch) | |
tree | edd46017d423b5f7ff1dfb5cbe96578b3f1f4642 /winsup/cygwin/miscfuncs.cc | |
parent | 71616225144e61c0a951a1353aea77e524849976 (diff) | |
download | newlib-aea710b5fbaec09ebe29bd32424440723731ec6e.zip newlib-aea710b5fbaec09ebe29bd32424440723731ec6e.tar.gz newlib-aea710b5fbaec09ebe29bd32424440723731ec6e.tar.bz2 |
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>
Diffstat (limited to 'winsup/cygwin/miscfuncs.cc')
-rw-r--r-- | winsup/cygwin/miscfuncs.cc | 60 |
1 files 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 |