1 /* Multiple versions of strcpy
2 Copyright (C) 2009, 2011 Free Software Foundation, Inc.
3 Contributed by Intel Corporation.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
21 #include <init-arch.h>
23 #if !defined (USE_AS_STPCPY) && !defined (USE_AS_STRNCPY)
25 # define STRCPY strcpy
30 # ifdef USE_AS_STRNCPY
31 # define STRCPY_SSSE3 __stpncpy_ssse3
32 # define STRCPY_SSE2 __stpncpy_sse2
33 # define STRCPY_SSE2_UNALIGNED __stpncpy_sse2_unaligned
34 # define __GI_STRCPY __GI_stpncpy
35 # define __GI___STRCPY __GI___stpncpy
37 # define STRCPY_SSSE3 __stpcpy_ssse3
38 # define STRCPY_SSE2 __stpcpy_sse2
39 # define STRCPY_SSE2_UNALIGNED __stpcpy_sse2_unaligned
40 # define __GI_STRCPY __GI_stpcpy
41 # define __GI___STRCPY __GI___stpcpy
44 # ifdef USE_AS_STRNCPY
45 # define STRCPY_SSSE3 __strncpy_ssse3
46 # define STRCPY_SSE2 __strncpy_sse2
47 # define STRCPY_SSE2_UNALIGNED __strncpy_sse2_unaligned
48 # define __GI_STRCPY __GI_strncpy
50 # define STRCPY_SSSE3 __strcpy_ssse3
51 # define STRCPY_SSE2 __strcpy_sse2
52 # define STRCPY_SSE2_UNALIGNED __strcpy_sse2_unaligned
53 # define __GI_STRCPY __GI_strcpy
58 /* Define multiple versions only for the definition in libc. */
62 .type STRCPY, @gnu_indirect_function
63 cmpl $0, __cpu_features+KIND_OFFSET(%rip)
65 call __init_cpu_features
66 1: leaq STRCPY_SSE2_UNALIGNED(%rip), %rax
67 testl $bit_Fast_Unaligned_Load, __cpu_features+FEATURE_OFFSET+index_Fast_Unaligned_Load(%rip)
69 leaq STRCPY_SSE2(%rip), %rax
70 testl $bit_SSSE3, __cpu_features+CPUID_OFFSET+index_SSSE3(%rip)
72 leaq STRCPY_SSSE3(%rip), %rax
77 # define ENTRY(name) \
78 .type STRCPY_SSE2, @function; \
80 STRCPY_SSE2: cfi_startproc; \
84 cfi_endproc; .size STRCPY_SSE2, .-STRCPY_SSE2
85 # undef libc_hidden_builtin_def
86 /* It doesn't make sense to send libc-internal strcpy calls through a PLT.
87 The speedup we get from using SSSE3 instruction is likely eaten away
88 by the indirect call in the PLT. */
89 # define libc_hidden_builtin_def(name) \
90 .globl __GI_STRCPY; __GI_STRCPY = STRCPY_SSE2
91 # undef libc_hidden_def
92 # define libc_hidden_def(name) \
93 .globl __GI___STRCPY; __GI___STRCPY = STRCPY_SSE2
96 #ifndef USE_AS_STRNCPY
97 #include "../strcpy.S"