Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / x86_64 / multiarch / strcpy.S
blob7be1b8be701da8a96aa3fb79a2b2206e503521d7
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/>.  */
20 #include <sysdep.h>
21 #include <init-arch.h>
23 #if !defined (USE_AS_STPCPY) && !defined (USE_AS_STRNCPY)
24 # ifndef STRCPY
25 #  define STRCPY strcpy
26 # endif
27 #endif
29 #ifdef USE_AS_STPCPY
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
36 # else
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
42 # endif
43 #else
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
49 # else
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
54 # endif
55 #endif
58 /* Define multiple versions only for the definition in libc.  */
59 #ifndef NOT_IN_libc
60         .text
61 ENTRY(STRCPY)
62         .type   STRCPY, @gnu_indirect_function
63         cmpl    $0, __cpu_features+KIND_OFFSET(%rip)
64         jne     1f
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)
68         jnz     2f
69         leaq    STRCPY_SSE2(%rip), %rax
70         testl   $bit_SSSE3, __cpu_features+CPUID_OFFSET+index_SSSE3(%rip)
71         jz      2f
72         leaq    STRCPY_SSSE3(%rip), %rax
73 2:      ret
74 END(STRCPY)
76 # undef ENTRY
77 # define ENTRY(name) \
78         .type STRCPY_SSE2, @function; \
79         .align 16; \
80         STRCPY_SSE2: cfi_startproc; \
81         CALL_MCOUNT
82 # undef END
83 # define END(name) \
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
94 #endif
96 #ifndef USE_AS_STRNCPY
97 #include "../strcpy.S"
98 #endif