]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/x86_64/multiarch/strcpy.S
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / x86_64 / multiarch / strcpy.S
CommitLineData
8912479f 1/* Multiple versions of strcpy
ac49ecaf 2 All versions must be listed in ifunc-impl-list.c.
d4697bc9 3 Copyright (C) 2009-2014 Free Software Foundation, Inc.
ab6a873f
L
4 Contributed by Intel Corporation.
5 This file is part of the GNU C Library.
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
ab6a873f
L
20
21#include <sysdep.h>
51ddd2c0 22#include <init-arch.h>
ab6a873f
L
23
24#if !defined (USE_AS_STPCPY) && !defined (USE_AS_STRNCPY)
25# ifndef STRCPY
26# define STRCPY strcpy
27# endif
28#endif
29
30#ifdef USE_AS_STPCPY
31# ifdef USE_AS_STRNCPY
8912479f
L
32# define STRCPY_SSSE3 __stpncpy_ssse3
33# define STRCPY_SSE2 __stpncpy_sse2
34# define STRCPY_SSE2_UNALIGNED __stpncpy_sse2_unaligned
35# define __GI_STRCPY __GI_stpncpy
36# define __GI___STRCPY __GI___stpncpy
ab6a873f 37# else
8912479f
L
38# define STRCPY_SSSE3 __stpcpy_ssse3
39# define STRCPY_SSE2 __stpcpy_sse2
40# define STRCPY_SSE2_UNALIGNED __stpcpy_sse2_unaligned
41# define __GI_STRCPY __GI_stpcpy
42# define __GI___STRCPY __GI___stpcpy
ab6a873f
L
43# endif
44#else
45# ifdef USE_AS_STRNCPY
8912479f
L
46# define STRCPY_SSSE3 __strncpy_ssse3
47# define STRCPY_SSE2 __strncpy_sse2
48# define STRCPY_SSE2_UNALIGNED __strncpy_sse2_unaligned
49# define __GI_STRCPY __GI_strncpy
ab6a873f 50# else
8912479f
L
51# define STRCPY_SSSE3 __strcpy_ssse3
52# define STRCPY_SSE2 __strcpy_sse2
53# define STRCPY_SSE2_UNALIGNED __strcpy_sse2_unaligned
54# define __GI_STRCPY __GI_strcpy
ab6a873f
L
55# endif
56#endif
57
ab6a873f
L
58
59/* Define multiple versions only for the definition in libc. */
60#ifndef NOT_IN_libc
61 .text
62ENTRY(STRCPY)
63 .type STRCPY, @gnu_indirect_function
64 cmpl $0, __cpu_features+KIND_OFFSET(%rip)
65 jne 1f
66 call __init_cpu_features
8912479f
L
671: leaq STRCPY_SSE2_UNALIGNED(%rip), %rax
68 testl $bit_Fast_Unaligned_Load, __cpu_features+FEATURE_OFFSET+index_Fast_Unaligned_Load(%rip)
69 jnz 2f
70 leaq STRCPY_SSE2(%rip), %rax
51ddd2c0 71 testl $bit_SSSE3, __cpu_features+CPUID_OFFSET+index_SSSE3(%rip)
d28797e4
UD
72 jz 2f
73 leaq STRCPY_SSSE3(%rip), %rax
742: ret
ab6a873f
L
75END(STRCPY)
76
ab6a873f
L
77# undef ENTRY
78# define ENTRY(name) \
79 .type STRCPY_SSE2, @function; \
d6485c98 80 .align 16; \
ac49ecaf
L
81 .globl STRCPY_SSE2; \
82 .hidden STRCPY_SSE2; \
ab6a873f
L
83 STRCPY_SSE2: cfi_startproc; \
84 CALL_MCOUNT
85# undef END
86# define END(name) \
87 cfi_endproc; .size STRCPY_SSE2, .-STRCPY_SSE2
88# undef libc_hidden_builtin_def
89/* It doesn't make sense to send libc-internal strcpy calls through a PLT.
90 The speedup we get from using SSSE3 instruction is likely eaten away
91 by the indirect call in the PLT. */
92# define libc_hidden_builtin_def(name) \
93 .globl __GI_STRCPY; __GI_STRCPY = STRCPY_SSE2
94# undef libc_hidden_def
95# define libc_hidden_def(name) \
96 .globl __GI___STRCPY; __GI___STRCPY = STRCPY_SSE2
97#endif
98
99#ifndef USE_AS_STRNCPY
100#include "../strcpy.S"
101#endif