]>
Commit | Line | Data |
---|---|---|
02cea471 | 1 | /* Multiple versions of strcspn |
9a1d9254 | 2 | Copyright (C) 2009, 2012 Free Software Foundation, Inc. |
02cea471 L |
3 | Contributed by Intel Corporation. |
4 | This file is part of the GNU C Library. | |
5 | ||
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. | |
10 | ||
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. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 PE |
17 | License along with the GNU C Library; if not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
02cea471 L |
19 | |
20 | #include <config.h> | |
21 | ||
22 | #ifdef HAVE_SSE4_SUPPORT | |
23 | ||
24 | #include <sysdep.h> | |
2510d01d | 25 | #include <init-arch.h> |
02cea471 L |
26 | |
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 | |
39 | ||
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 | |
fc1870e6 | 44 | # ifdef SHARED |
02cea471 L |
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) | |
9a1d9254 | 51 | LOAD_PIC_REG(bx) |
02cea471 L |
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 | |
2510d01d | 56 | testl $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features@GOTOFF(%ebx) |
02cea471 L |
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) | |
fc1870e6 L |
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 | |
2510d01d | 72 | testl $bit_SSE4_2, CPUID_OFFSET+index_SSE4_2+__cpu_features |
fc1870e6 L |
73 | jz 2f |
74 | leal STRCSPN_SSE42, %eax | |
75 | 2: ret | |
76 | END(STRCSPN) | |
77 | # endif | |
02cea471 L |
78 | |
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 | |
2c709c6f UD |
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. */ | |
02cea471 L |
93 | # define libc_hidden_builtin_def(name) \ |
94 | .globl __GI_STRCSPN; __GI_STRCSPN = STRCSPN_IA32 | |
95 | #endif | |
96 | ||
97 | #endif /* HAVE_SSE4_SUPPORT */ | |
98 | ||
99 | #ifdef USE_AS_STRPBRK | |
100 | #include "../../strpbrk.S" | |
101 | #else | |
102 | #include "../../strcspn.S" | |
103 | #endif |