aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/miscfuncs.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2022-08-08 16:25:41 +0200
committerCorinna Vinschen <corinna@vinschen.de>2022-08-08 16:25:41 +0200
commit3e13d935545f31cbd1f4871b84f5d70928c56f42 (patch)
tree1501dbbb0c19c0ec3fba3a3182ddc2c06b908832 /winsup/cygwin/miscfuncs.cc
parent4d6c88e03095e02537d99e90c4babd1a534a258b (diff)
downloadnewlib-3e13d935545f31cbd1f4871b84f5d70928c56f42.zip
newlib-3e13d935545f31cbd1f4871b84f5d70928c56f42.tar.gz
newlib-3e13d935545f31cbd1f4871b84f5d70928c56f42.tar.bz2
Cygwin: split out x86_64 memset/memcpy functions
move the assembler memset and memcpy functions into their own assembler files. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/miscfuncs.cc')
-rw-r--r--winsup/cygwin/miscfuncs.cc207
1 files changed, 0 insertions, 207 deletions
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index bc362e3..1513bc0 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -705,213 +705,6 @@ err:
return thread;
}
-#ifdef __x86_64__
-/* These functions are almost verbatim FreeBSD code (even if the header of
- one file mentiones NetBSD), just wrapped in the minimum required code to
- make them work with the MS AMD64 ABI.
- See FreeBSD src/lib/libc/amd64/string/memset.S
- and FreeBSD src/lib/libc/amd64/string/bcopy.S */
-
-asm (" \n\
-/* \n\
- * Written by J.T. Conklin <jtc@NetBSD.org>. \n\
- * Public domain. \n\
- * Adapted for NetBSD/x86_64 by \n\
- * Frank van der Linden <fvdl@wasabisystems.com> \n\
- */ \n\
- \n\
- .globl memset \n\
- .seh_proc memset \n\
-memset: \n\
- movq %rsi,8(%rsp) \n\
- movq %rdi,16(%rsp) \n\
- .seh_endprologue \n\
- movq %rcx,%rdi \n\
- movq %rdx,%rsi \n\
- movq %r8,%rdx \n\
- \n\
- movq %rsi,%rax \n\
- andq $0xff,%rax \n\
- movq %rdx,%rcx \n\
- movq %rdi,%r11 \n\
- \n\
- cld /* set fill direction forward */ \n\
- \n\
- /* if the string is too short, it's really not worth the \n\
- * overhead of aligning to word boundries, etc. So we jump to \n\
- * a plain unaligned set. */ \n\
- cmpq $0x0f,%rcx \n\
- jle L1 \n\
- \n\
- movb %al,%ah /* copy char to all bytes in word */\n\
- movl %eax,%edx \n\
- sall $16,%eax \n\
- orl %edx,%eax \n\
- \n\
- movl %eax,%edx \n\
- salq $32,%rax \n\
- orq %rdx,%rax \n\
- \n\
- movq %rdi,%rdx /* compute misalignment */ \n\
- negq %rdx \n\
- andq $7,%rdx \n\
- movq %rcx,%r8 \n\
- subq %rdx,%r8 \n\
- \n\
- movq %rdx,%rcx /* set until word aligned */ \n\
- rep \n\
- stosb \n\
- \n\
- movq %r8,%rcx \n\
- shrq $3,%rcx /* set by words */ \n\
- rep \n\
- stosq \n\
- \n\
- movq %r8,%rcx /* set remainder by bytes */ \n\
- andq $7,%rcx \n\
-L1: rep \n\
- stosb \n\
- movq %r11,%rax \n\
- \n\
- movq 8(%rsp),%rsi \n\
- movq 16(%rsp),%rdi \n\
- ret \n\
- .seh_endproc \n\
-");
-
-asm (" \n\
-/*- \n\
- * Copyright (c) 1990 The Regents of the University of California. \n\
- * All rights reserved. \n\
- * \n\
- * This code is derived from locore.s. \n\
- * \n\
- * Redistribution and use in source and binary forms, with or without \n\
- * modification, are permitted provided that the following conditions \n\
- * are met: \n\
- * 1. Redistributions of source code must retain the above copyright \n\
- * notice, this list of conditions and the following disclaimer. \n\
- * 2. Redistributions in binary form must reproduce the above copyright \n\
- * notice, this list of conditions and the following disclaimer in \n\
- * the documentation and/or other materials provided with the \n\
- * distribution. \n\
- * 3. Neither the name of the University nor the names of its \n\
- * contributors may be used to endorse or promote products derived \n\
- * from this software without specific prior written permission. \n\
- * \n\
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' \n\
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n\
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A \n\
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR \n\
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, \n\
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \n\
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY \n\
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \n\
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE \n\
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH \n\
- * DAMAGE. \n\
- */ \n\
- \n\
- .seh_proc _memcpy \n\
-_memcpy: \n\
- movq %rsi,8(%rsp) \n\
- movq %rdi,16(%rsp) \n\
- .seh_endprologue \n\
- movq %rcx,%rdi \n\
- movq %rdx,%rsi \n\
- movq %r8,%rdx \n\
- \n\
- movq %rdx,%rcx \n\
- movq %rdi,%r8 \n\
- subq %rsi,%r8 \n\
- cmpq %rcx,%r8 /* overlapping? */ \n\
- jb 1f \n\
- cld /* nope, copy forwards. */ \n\
- shrq $3,%rcx /* copy by words */ \n\
- rep movsq \n\
- movq %rdx,%rcx \n\
- andq $7,%rcx /* any bytes left? */ \n\
- rep movsb \n\
- jmp 2f \n\
-1: \n\
- addq %rcx,%rdi /* copy backwards. */ \n\
- addq %rcx,%rsi \n\
- std \n\
- andq $7,%rcx /* any fractional bytes? */ \n\
- decq %rdi \n\
- decq %rsi \n\
- rep movsb \n\
- movq %rdx,%rcx /* copy remainder by words */ \n\
- shrq $3,%rcx \n\
- subq $7,%rsi \n\
- subq $7,%rdi \n\
- rep movsq \n\
- cld \n\
-2: \n\
- movq 8(%rsp),%rsi \n\
- movq 16(%rsp),%rdi \n\
- ret \n\
- .seh_endproc \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 mempcpy \n\
- .seh_proc mempcpy \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\
- shlq $1,%r8 /* cnt * sizeof (wchar_t) */ \n\
- movq %rcx,%rax /* return dst */ \n\
- jmp _memcpy \n\
- .seh_endproc \n\
- \n\
- .globl wmemcpy \n\
- .seh_proc wmemcpy \n\
-wmemcpy: \n\
- .seh_endprologue \n\
- shlq $1,%r8 /* cnt * sizeof (wchar_t) */ \n\
- movq %rcx,%rax /* return dst */ \n\
- jmp _memcpy \n\
- .seh_endproc \n\
- \n\
- .globl wmempcpy \n\
- .seh_proc wmempcpy \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\
-");
-
-#else
-#error unimplemented for this target
-#endif
-
/* Signal the thread name to any attached debugger
(See "How to: Set a Thread Name in Native Code"