Fix -D_FORTIFY_SOURCE memmove and bcop
[glibc.git] / sysdeps / i386 / i686 / multiarch / strcmp.S
blob87245948818a08d4607f3236c1d1ef6623eb4500
1 /* Multiple versions of strcmp
2    Copyright (C) 2010 Free Software Foundation, Inc.
3    Contributed by Intel Corporation.
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, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
21 #include <sysdep.h>
22 #include <init-arch.h>
24 #ifndef USE_AS_STRNCMP
25 # define STRCMP                 strcmp
26 # define __GI_STRCMP            __GI_strcmp
27 # define __STRCMP_IA32          __strcmp_ia32
28 # define __STRCMP_SSSE3         __strcmp_ssse3
29 # define __STRCMP_SSE4_2        __strcmp_sse4_2
30 #else
31 # define STRCMP                 strncmp
32 # define __GI_STRCMP            __GI_strncmp
33 # define __STRCMP_IA32          __strncmp_ia32
34 # define __STRCMP_SSSE3         __strncmp_ssse3
35 # define __STRCMP_SSE4_2        __strncmp_sse4_2
36 #endif
38 /* Define multiple versions only for the definition in libc.  Don't
39    define multiple versions for strncmp in static library since we
40    need strncmp before the initialization happened.  */
41 #if (defined SHARED || !defined USE_AS_STRNCMP) && !defined NOT_IN_libc
42 # ifdef SHARED
43         .section        .gnu.linkonce.t.__i686.get_pc_thunk.dx,"ax",@progbits
44         .globl  __i686.get_pc_thunk.dx
45         .hidden __i686.get_pc_thunk.dx
46         .p2align 2
47         .type   __i686.get_pc_thunk.dx,@function
48 __i686.get_pc_thunk.dx:
49         movl    (%esp), %edx
50         ret
51         .size   __i686.get_pc_thunk.dx, .-__i686.get_pc_thunk.dx
53         .text
54 ENTRY(STRCMP)
55         .type   STRCMP, @gnu_indirect_function
56         call    __i686.get_pc_thunk.dx
57         addl    $_GLOBAL_OFFSET_TABLE_, %edx
58         cmpl    $0, KIND_OFFSET+__cpu_features@GOTOFF(%edx)
59         jne     1f
60         call    __init_cpu_features
61 1:      leal    __STRCMP_SSE4_2@GOTOFF(%edx), %eax
62         testl   $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features@GOTOFF(%edx)
63         jnz     2f
64         leal    __STRCMP_SSSE3@GOTOFF(%edx), %eax
65         testl   $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features@GOTOFF(%edx)
66         jnz     2f
67         leal    __STRCMP_IA32@GOTOFF(%edx), %ecx
68 2:      ret
69 END(STRCMP)
70 # else
71         .text
72 ENTRY(STRCMP)
73         .type   STRCMP, @gnu_indirect_function
74         cmpl    $0, KIND_OFFSET+__cpu_features
75         jne     1f
76         call    __init_cpu_features
77 1:      leal    __STRCMP_SSE4_2, %eax
78         testl   $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features
79         jnz     2f
80         leal    __STRCMP_SSSE3, %eax
81         testl   $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features
82         jnz     2f
83         leal    __STRCMP_IA32, %eax
84 2:      ret
85 END(STRCMP)
86 # endif
88 # undef ENTRY
89 # define ENTRY(name) \
90         .type __STRCMP_IA32, @function; \
91         .p2align 4; \
92         __STRCMP_IA32: cfi_startproc; \
93         CALL_MCOUNT
94 # undef END
95 # define END(name) \
96         cfi_endproc; .size __STRCMP_IA32, .-__STRCMP_IA32
98 # ifdef SHARED
99 #  undef libc_hidden_builtin_def
100 /* IFUNC doesn't work with the hidden functions in shared library since
101    they will be called without setting up EBX needed for PLT which is
102    used by IFUNC.  */
103 #  define libc_hidden_builtin_def(name) \
104         .globl __GI_STRCMP; __GI_STRCMP = __STRCMP_IA32
105 # endif
106 #endif
108 #ifndef USE_AS_STRNCMP
109 # include "../strcmp.S"
110 #endif