1 /* Multiple versions of strcmp
2 All versions must be listed in ifunc-impl-list.c.
3 Copyright (C) 2010-2014 Free Software Foundation, Inc.
4 Contributed by Intel Corporation.
5 This file is part of the GNU C Library.
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.
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.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
22 #include <init-arch.h>
25 # define STRCMP strncmp
26 # define __GI_STRCMP __GI_strncmp
27 # define __STRCMP_IA32 __strncmp_ia32
28 # define __STRCMP_SSSE3 __strncmp_ssse3
29 # define __STRCMP_SSE4_2 __strncmp_sse4_2
30 #elif defined USE_AS_STRCASECMP_L
31 # define STRCMP __strcasecmp_l
32 # define __GI_STRCMP __GI_strcasecmp_l
33 # define __STRCMP_IA32 __strcasecmp_l_ia32
34 # define __STRCMP_SSSE3 __strcasecmp_l_ssse3
35 # define __STRCMP_SSE4_2 __strcasecmp_l_sse4_2
36 #elif defined USE_AS_STRNCASECMP_L
37 # define STRCMP __strncasecmp_l
38 # define __GI_STRCMP __GI_strncasecmp_l
39 # define __STRCMP_IA32 __strncasecmp_l_ia32
40 # define __STRCMP_SSSE3 __strncasecmp_l_ssse3
41 # define __STRCMP_SSE4_2 __strncasecmp_l_sse4_2
43 # define STRCMP strcmp
44 # define __GI_STRCMP __GI_strcmp
45 # define __STRCMP_IA32 __strcmp_ia32
46 # define __STRCMP_SSSE3 __strcmp_ssse3
47 # define __STRCMP_SSE4_2 __strcmp_sse4_2
50 /* Define multiple versions only for the definition in libc. Don't
51 define multiple versions for strncmp in static library since we
52 need strncmp before the initialization happened. */
53 #if (defined SHARED || !defined USE_AS_STRNCMP) && !defined NOT_IN_libc
57 .type STRCMP, @gnu_indirect_function
59 cfi_adjust_cfa_offset (4)
60 cfi_rel_offset (ebx, 0)
62 cmpl $0, KIND_OFFSET+__cpu_features@GOTOFF(%ebx)
64 call __init_cpu_features
65 1: leal __STRCMP_IA32@GOTOFF(%ebx), %eax
66 testl $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features@GOTOFF(%ebx)
68 leal __STRCMP_SSSE3@GOTOFF(%ebx), %eax
69 testl $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features@GOTOFF(%ebx)
71 testl $bit_Slow_SSE4_2, CPUID_OFFSET+index_Slow_SSE4_2+__cpu_features@GOTOFF(%ebx)
73 leal __STRCMP_SSE4_2@GOTOFF(%ebx), %eax
75 cfi_adjust_cfa_offset (-4)
82 .type STRCMP, @gnu_indirect_function
83 cmpl $0, KIND_OFFSET+__cpu_features
85 call __init_cpu_features
86 1: leal __STRCMP_IA32, %eax
87 testl $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features
89 leal __STRCMP_SSSE3, %eax
90 testl $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features
92 testl $bit_Slow_SSE4_2, CPUID_OFFSET+index_Slow_SSE4_2+__cpu_features
94 leal __STRCMP_SSE4_2, %eax
100 # define ENTRY(name) \
101 .type __STRCMP_IA32, @function; \
103 .globl __STRCMP_IA32; \
104 .hidden __STRCMP_IA32; \
105 __STRCMP_IA32: cfi_startproc; \
109 cfi_endproc; .size __STRCMP_IA32, .-__STRCMP_IA32
112 # undef libc_hidden_builtin_def
113 /* IFUNC doesn't work with the hidden functions in shared library since
114 they will be called without setting up EBX needed for PLT which is
116 # define libc_hidden_builtin_def(name) \
117 .globl __GI_STRCMP; __GI_STRCMP = __STRCMP_IA32
121 #if !defined USE_AS_STRNCMP && !defined USE_AS_STRCASECMP_L \
122 && !defined USE_AS_STRNCASECMP_L
123 # include "../strcmp.S"