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