Add x86-64 __libc_ifunc_impl_list
[glibc.git] / sysdeps / x86_64 / multiarch / memset.S
blobf7c6a9f11aa9da3fb9209370f40fcbce28d5be87
1 /* Multiple versions of memset
2    All versions must be listed in ifunc-impl-list.c.
3    Copyright (C) 2010-2012 Free Software Foundation, Inc.
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 /* Define multiple versions only for the definition in lib.  */
24 #ifndef NOT_IN_libc
25 ENTRY(memset)
26         .type   memset, @gnu_indirect_function
27         cmpl    $0, __cpu_features+KIND_OFFSET(%rip)
28         jne     1f
29         call    __init_cpu_features
30 1:      leaq    __memset_x86_64(%rip), %rax
31         testl   $bit_Prefer_SSE_for_memop, __cpu_features+FEATURE_OFFSET+index_Prefer_SSE_for_memop(%rip)
32         jz      2f
33         leaq    __memset_sse2(%rip), %rax
34 2:      ret
35 END(memset)
37 /* Define internal IFUNC memset for bzero.  */
38         .globl __libc_memset
39         .hidden __libc_memset
40         __libc_memset = memset
42 # define USE_SSE2 1
44 # undef ENTRY
45 # define ENTRY(name) \
46         .type __memset_sse2, @function; \
47         .globl __memset_sse2; \
48         .p2align 4; \
49         __memset_sse2: cfi_startproc; \
50         CALL_MCOUNT
51 # undef END
52 # define END(name) \
53         cfi_endproc; .size __memset_sse2, .-__memset_sse2
55 # undef ENTRY_CHK
56 # define ENTRY_CHK(name) \
57         .type __memset_chk_sse2, @function; \
58         .globl __memset_chk_sse2; \
59         .p2align 4; \
60         __memset_chk_sse2: cfi_startproc; \
61         CALL_MCOUNT
62 # undef END_CHK
63 # define END_CHK(name) \
64         cfi_endproc; .size __memset_chk_sse2, .-__memset_chk_sse2
66 # ifdef SHARED
67 #  undef libc_hidden_builtin_def
68 /* It doesn't make sense to send libc-internal memset calls through a PLT.
69    The speedup we get from using GPR instruction is likely eaten away
70    by the indirect call in the PLT.  */
71 #  define libc_hidden_builtin_def(name) \
72         .globl __GI_memset; __GI_memset = __memset_sse2
73 # endif
75 # undef strong_alias
76 # define strong_alias(original, alias)
77 #endif
79 #include "../memset.S"