Fix strftime wcschr namespace (bug 17634).
[glibc.git] / sysdeps / i386 / i686 / multiarch / strcspn.S
blobd60874be24c5d0e6c9bff79f2fc1d6e36911f242
1 /* Multiple versions of strcspn
2    All versions must be listed in ifunc-impl-list.c.
3    Copyright (C) 2009-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 <config.h>
23 #ifdef HAVE_SSE4_SUPPORT
25 #include <sysdep.h>
26 #include <init-arch.h>
28 #ifdef USE_AS_STRPBRK
29 #define STRCSPN_SSE42   __strpbrk_sse42
30 #define STRCSPN_IA32    __strpbrk_ia32
31 #define __GI_STRCSPN    __GI_strpbrk
32 #else
33 #ifndef STRCSPN
34 #define STRCSPN         strcspn
35 #define STRCSPN_SSE42   __strcspn_sse42
36 #define STRCSPN_IA32    __strcspn_ia32
37 #define __GI_STRCSPN    __GI_strcspn
38 #endif
39 #endif
41 /* Define multiple versions only for the definition in libc.  Don't
42    define multiple versions for strpbrk in static library since we
43    need strpbrk before the initialization happened.  */
44 #if (defined SHARED || !defined USE_AS_STRPBRK) && IS_IN (libc)
45 # ifdef SHARED
46         .text
47 ENTRY(STRCSPN)
48         .type   STRCSPN, @gnu_indirect_function
49         pushl   %ebx
50         cfi_adjust_cfa_offset (4)
51         cfi_rel_offset (ebx, 0)
52         LOAD_PIC_REG(bx)
53         cmpl    $0, KIND_OFFSET+__cpu_features@GOTOFF(%ebx)
54         jne     1f
55         call    __init_cpu_features
56 1:      leal    STRCSPN_IA32@GOTOFF(%ebx), %eax
57         testl   $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features@GOTOFF(%ebx)
58         jz      2f
59         leal    STRCSPN_SSE42@GOTOFF(%ebx), %eax
60 2:      popl    %ebx
61         cfi_adjust_cfa_offset (-4);
62         cfi_restore (ebx)
63         ret
64 END(STRCSPN)
65 # else
66         .text
67 ENTRY(STRCSPN)
68         .type   STRCSPN, @gnu_indirect_function
69         cmpl    $0, KIND_OFFSET+__cpu_features
70         jne     1f
71         call    __init_cpu_features
72 1:      leal    STRCSPN_IA32, %eax
73         testl   $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features
74         jz      2f
75         leal    STRCSPN_SSE42, %eax
76 2:      ret
77 END(STRCSPN)
78 # endif
80 # undef ENTRY
81 # define ENTRY(name) \
82         .type STRCSPN_IA32, @function; \
83         .globl STRCSPN_IA32; \
84         .p2align 4; \
85         STRCSPN_IA32: cfi_startproc; \
86         CALL_MCOUNT
87 # undef END
88 # define END(name) \
89         cfi_endproc; .size STRCSPN_IA32, .-STRCSPN_IA32
90 # undef libc_hidden_builtin_def
91 /* IFUNC doesn't work with the hidden functions in shared library since
92    they will be called without setting up EBX needed for PLT which is
93    used by IFUNC.  */
94 # define libc_hidden_builtin_def(name) \
95         .globl __GI_STRCSPN; __GI_STRCSPN = STRCSPN_IA32
96 #endif
98 #endif /* HAVE_SSE4_SUPPORT */
100 #ifdef USE_AS_STRPBRK
101 #include "../../strpbrk.S"
102 #else
103 #include "../../strcspn.S"
104 #endif