]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/i686/multiarch/strcpy.S
Replace FSF snail mail address with URLs.
[thirdparty/glibc.git] / sysdeps / i386 / i686 / multiarch / strcpy.S
1 /* Multiple versions of strcpy
2 Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 Contributed by Intel Corporation.
4 This file is part of the GNU C Library.
5
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.
10
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.
15
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/>. */
19
20 #include <sysdep.h>
21 #include <init-arch.h>
22
23 #if !defined (USE_AS_STPCPY) && !defined (USE_AS_STRNCPY)
24 # ifndef STRCPY
25 # define STRCPY strcpy
26 # endif
27 #endif
28
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_IA32 __stpncpy_ia32
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_IA32 __stpcpy_ia32
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_IA32 __strncpy_ia32
48 # define __GI_STRCPY __GI_strncpy
49 # else
50 # define STRCPY_SSSE3 __strcpy_ssse3
51 # define STRCPY_SSE2 __strcpy_sse2
52 # define STRCPY_IA32 __strcpy_ia32
53 # define __GI_STRCPY __GI_strcpy
54 # endif
55 #endif
56
57
58 /* Define multiple versions only for the definition in libc. Don't
59 define multiple versions for strncpy in static library since we
60 need strncpy before the initialization happened. */
61 #ifndef NOT_IN_libc
62
63 # ifdef SHARED
64 .text
65 ENTRY(STRCPY)
66 .type STRCPY, @gnu_indirect_function
67 pushl %ebx
68 cfi_adjust_cfa_offset (4)
69 cfi_rel_offset (ebx, 0)
70 LOAD_PIC_REG(bx)
71 cmpl $0, KIND_OFFSET+__cpu_features@GOTOFF(%ebx)
72 jne 1f
73 call __init_cpu_features
74 1: leal STRCPY_IA32@GOTOFF(%ebx), %eax
75 testl $bit_SSE2, CPUID_OFFSET+index_SSE2+__cpu_features@GOTOFF(%ebx)
76 jz 2f
77 leal STRCPY_SSE2@GOTOFF(%ebx), %eax
78 testl $bit_Fast_Unaligned_Load, FEATURE_OFFSET+index_Fast_Unaligned_Load+__cpu_features@GOTOFF(%ebx)
79 jnz 2f
80 testl $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features@GOTOFF(%ebx)
81 jz 2f
82 leal STRCPY_SSSE3@GOTOFF(%ebx), %eax
83 2: popl %ebx
84 cfi_adjust_cfa_offset (-4)
85 cfi_restore (ebx)
86 ret
87 END(STRCPY)
88 # else
89
90 ENTRY(STRCPY)
91 .type STRCPY, @gnu_indirect_function
92 cmpl $0, KIND_OFFSET+__cpu_features
93 jne 1f
94 call __init_cpu_features
95 1: leal STRCPY_IA32, %eax
96 testl $bit_SSE2, CPUID_OFFSET+index_SSE2+__cpu_features
97 jz 2f
98 leal STRCPY_SSE2, %eax
99 testl $bit_Fast_Unaligned_Load, FEATURE_OFFSET+index_Fast_Unaligned_Load+__cpu_features
100 jnz 2f
101 testl $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features
102 jz 2f
103 leal STRCPY_SSSE3, %eax
104 2: ret
105 END(STRCPY)
106
107 # endif
108
109 # undef ENTRY
110 # define ENTRY(name) \
111 .type STRCPY_IA32, @function; \
112 .align 16; \
113 STRCPY_IA32: cfi_startproc; \
114 CALL_MCOUNT
115 # undef END
116 # define END(name) \
117 cfi_endproc; .size STRCPY_IA32, .-STRCPY_IA32
118
119 # ifdef SHARED
120 # undef libc_hidden_builtin_def
121 /* It doesn't make sense to send libc-internal strcpy calls through a PLT.
122 The speedup we get from using SSSE3 instruction is likely eaten away
123 by the indirect call in the PLT. */
124 # define libc_hidden_builtin_def(name) \
125 .globl __GI_STRCPY; __GI_STRCPY = STRCPY_IA32
126 # undef libc_hidden_def
127 # define libc_hidden_def(name) \
128 .globl __GI___STRCPY; __GI___STRCPY = STRCPY_IA32
129
130 # endif
131 #endif
132
133 #ifdef USE_AS_STPCPY
134 # ifdef USE_AS_STRNCPY
135 # include "../../stpncpy.S"
136 # else
137 # include "../../i586/stpcpy.S"
138 # endif
139 #else
140 # ifndef USE_AS_STRNCPY
141 # include "../../i586/strcpy.S"
142 # endif
143 #endif