1*8d67ca89SAndroid Build Coastguard Worker/* 2*8d67ca89SAndroid Build Coastguard WorkerCopyright (c) 2014, Intel Corporation 3*8d67ca89SAndroid Build Coastguard WorkerAll rights reserved. 4*8d67ca89SAndroid Build Coastguard Worker 5*8d67ca89SAndroid Build Coastguard WorkerRedistribution and use in source and binary forms, with or without 6*8d67ca89SAndroid Build Coastguard Workermodification, are permitted provided that the following conditions are met: 7*8d67ca89SAndroid Build Coastguard Worker 8*8d67ca89SAndroid Build Coastguard Worker * Redistributions of source code must retain the above copyright notice, 9*8d67ca89SAndroid Build Coastguard Worker * this list of conditions and the following disclaimer. 10*8d67ca89SAndroid Build Coastguard Worker 11*8d67ca89SAndroid Build Coastguard Worker * Redistributions in binary form must reproduce the above copyright notice, 12*8d67ca89SAndroid Build Coastguard Worker * this list of conditions and the following disclaimer in the documentation 13*8d67ca89SAndroid Build Coastguard Worker * and/or other materials provided with the distribution. 14*8d67ca89SAndroid Build Coastguard Worker 15*8d67ca89SAndroid Build Coastguard Worker * Neither the name of Intel Corporation nor the names of its contributors 16*8d67ca89SAndroid Build Coastguard Worker * may be used to endorse or promote products derived from this software 17*8d67ca89SAndroid Build Coastguard Worker * without specific prior written permission. 18*8d67ca89SAndroid Build Coastguard Worker 19*8d67ca89SAndroid Build Coastguard WorkerTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20*8d67ca89SAndroid Build Coastguard WorkerANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21*8d67ca89SAndroid Build Coastguard WorkerWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22*8d67ca89SAndroid Build Coastguard WorkerDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23*8d67ca89SAndroid Build Coastguard WorkerANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24*8d67ca89SAndroid Build Coastguard Worker(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25*8d67ca89SAndroid Build Coastguard WorkerLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26*8d67ca89SAndroid Build Coastguard WorkerANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27*8d67ca89SAndroid Build Coastguard Worker(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28*8d67ca89SAndroid Build Coastguard WorkerSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29*8d67ca89SAndroid Build Coastguard Worker*/ 30*8d67ca89SAndroid Build Coastguard Worker 31*8d67ca89SAndroid Build Coastguard Worker#ifndef STRCAT 32*8d67ca89SAndroid Build Coastguard Worker# define STRCAT strcat 33*8d67ca89SAndroid Build Coastguard Worker#endif 34*8d67ca89SAndroid Build Coastguard Worker 35*8d67ca89SAndroid Build Coastguard Worker#ifndef L 36*8d67ca89SAndroid Build Coastguard Worker# define L(label) .L##label 37*8d67ca89SAndroid Build Coastguard Worker#endif 38*8d67ca89SAndroid Build Coastguard Worker 39*8d67ca89SAndroid Build Coastguard Worker#ifndef cfi_startproc 40*8d67ca89SAndroid Build Coastguard Worker# define cfi_startproc .cfi_startproc 41*8d67ca89SAndroid Build Coastguard Worker#endif 42*8d67ca89SAndroid Build Coastguard Worker 43*8d67ca89SAndroid Build Coastguard Worker#ifndef cfi_endproc 44*8d67ca89SAndroid Build Coastguard Worker# define cfi_endproc .cfi_endproc 45*8d67ca89SAndroid Build Coastguard Worker#endif 46*8d67ca89SAndroid Build Coastguard Worker 47*8d67ca89SAndroid Build Coastguard Worker#ifndef ENTRY 48*8d67ca89SAndroid Build Coastguard Worker# define ENTRY(name) \ 49*8d67ca89SAndroid Build Coastguard Worker .type name, @function; \ 50*8d67ca89SAndroid Build Coastguard Worker .globl name; \ 51*8d67ca89SAndroid Build Coastguard Worker .p2align 4; \ 52*8d67ca89SAndroid Build Coastguard Workername: \ 53*8d67ca89SAndroid Build Coastguard Worker cfi_startproc 54*8d67ca89SAndroid Build Coastguard Worker#endif 55*8d67ca89SAndroid Build Coastguard Worker 56*8d67ca89SAndroid Build Coastguard Worker#ifndef END 57*8d67ca89SAndroid Build Coastguard Worker# define END(name) \ 58*8d67ca89SAndroid Build Coastguard Worker cfi_endproc; \ 59*8d67ca89SAndroid Build Coastguard Worker .size name, .-name 60*8d67ca89SAndroid Build Coastguard Worker#endif 61*8d67ca89SAndroid Build Coastguard Worker 62*8d67ca89SAndroid Build Coastguard Worker#define USE_AS_STRCAT 63*8d67ca89SAndroid Build Coastguard Worker 64*8d67ca89SAndroid Build Coastguard Worker.text 65*8d67ca89SAndroid Build Coastguard WorkerENTRY (STRCAT) 66*8d67ca89SAndroid Build Coastguard Worker mov %rdi, %r9 67*8d67ca89SAndroid Build Coastguard Worker#ifdef USE_AS_STRNCAT 68*8d67ca89SAndroid Build Coastguard Worker mov %rdx, %r8 69*8d67ca89SAndroid Build Coastguard Worker#endif 70*8d67ca89SAndroid Build Coastguard Worker 71*8d67ca89SAndroid Build Coastguard Worker#define RETURN jmp L(Strcpy) 72*8d67ca89SAndroid Build Coastguard Worker#include "sse2-strlen-slm.S" 73*8d67ca89SAndroid Build Coastguard Worker 74*8d67ca89SAndroid Build Coastguard Worker#undef RETURN 75*8d67ca89SAndroid Build Coastguard Worker#define RETURN ret 76*8d67ca89SAndroid Build Coastguard Worker 77*8d67ca89SAndroid Build Coastguard WorkerL(Strcpy): 78*8d67ca89SAndroid Build Coastguard Worker lea (%r9, %rax), %rdi 79*8d67ca89SAndroid Build Coastguard Worker mov %rsi, %rcx 80*8d67ca89SAndroid Build Coastguard Worker mov %r9, %rax /* save result */ 81*8d67ca89SAndroid Build Coastguard Worker 82*8d67ca89SAndroid Build Coastguard Worker#ifdef USE_AS_STRNCAT 83*8d67ca89SAndroid Build Coastguard Worker test %r8, %r8 84*8d67ca89SAndroid Build Coastguard Worker jz L(ExitZero) 85*8d67ca89SAndroid Build Coastguard Worker# define USE_AS_STRNCPY 86*8d67ca89SAndroid Build Coastguard Worker#endif 87*8d67ca89SAndroid Build Coastguard Worker#include "sse2-strcpy-slm.S" 88