Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / i386 / i686 / multiarch / strcmp.S
blob2ad6bf4212cf391489f11a70fc7d17fb47815ca6
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/>.  */
21 #include <sysdep.h>
22 #include <init-arch.h>
24 #ifdef USE_AS_STRNCMP
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
42 #else
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
48 #endif
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
54 # ifdef SHARED
55         .text
56 ENTRY(STRCMP)
57         .type   STRCMP, @gnu_indirect_function
58         pushl   %ebx
59         cfi_adjust_cfa_offset (4)
60         cfi_rel_offset (ebx, 0)
61         LOAD_PIC_REG(bx)
62         cmpl    $0, KIND_OFFSET+__cpu_features@GOTOFF(%ebx)
63         jne     1f
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)
67         jz      2f
68         leal    __STRCMP_SSSE3@GOTOFF(%ebx), %eax
69         testl   $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features@GOTOFF(%ebx)
70         jz      2f
71         testl   $bit_Slow_SSE4_2, CPUID_OFFSET+index_Slow_SSE4_2+__cpu_features@GOTOFF(%ebx)
72         jnz     2f
73         leal    __STRCMP_SSE4_2@GOTOFF(%ebx), %eax
74 2:      popl    %ebx
75         cfi_adjust_cfa_offset (-4)
76         cfi_restore (ebx)
77         ret
78 END(STRCMP)
79 # else
80         .text
81 ENTRY(STRCMP)
82         .type   STRCMP, @gnu_indirect_function
83         cmpl    $0, KIND_OFFSET+__cpu_features
84         jne     1f
85         call    __init_cpu_features
86 1:      leal    __STRCMP_IA32, %eax
87         testl   $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features
88         jz      2f
89         leal    __STRCMP_SSSE3, %eax
90         testl   $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features
91         jz      2f
92         testl   $bit_Slow_SSE4_2, CPUID_OFFSET+index_Slow_SSE4_2+__cpu_features
93         jnz     2f
94         leal    __STRCMP_SSE4_2, %eax
95 2:      ret
96 END(STRCMP)
97 # endif
99 # undef ENTRY
100 # define ENTRY(name) \
101         .type __STRCMP_IA32, @function; \
102         .p2align 4; \
103         .globl __STRCMP_IA32; \
104         .hidden __STRCMP_IA32; \
105         __STRCMP_IA32: cfi_startproc; \
106         CALL_MCOUNT
107 # undef END
108 # define END(name) \
109         cfi_endproc; .size __STRCMP_IA32, .-__STRCMP_IA32
111 # ifdef SHARED
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
115    used by IFUNC.  */
116 #  define libc_hidden_builtin_def(name) \
117         .globl __GI_STRCMP; __GI_STRCMP = __STRCMP_IA32
118 # endif
119 #endif
121 #if !defined USE_AS_STRNCMP && !defined USE_AS_STRCASECMP_L \
122     && !defined USE_AS_STRNCASECMP_L
123 # include "../strcmp.S"
124 #endif