| 1 | /* Multiple versions of strcspn |
| 2 | All versions must be listed in ifunc-impl-list.c. |
| 3 | Copyright (C) 2009-2016 Free Software Foundation, Inc. |
| 4 | Contributed by Intel Corporation. |
| 5 | This file is part of the GNU C Library. |
| 6 | |
| 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. |
| 11 | |
| 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. |
| 16 | |
| 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/>. */ |
| 20 | |
| 21 | #include <config.h> |
| 22 | #include <sysdep.h> |
| 23 | #include <init-arch.h> |
| 24 | |
| 25 | #ifdef USE_AS_STRPBRK |
| 26 | #define STRCSPN_SSE42 __strpbrk_sse42 |
| 27 | #define STRCSPN_SSE2 __strpbrk_sse2 |
| 28 | #define __GI_STRCSPN __GI_strpbrk |
| 29 | #else |
| 30 | #ifndef STRCSPN |
| 31 | #define STRCSPN strcspn |
| 32 | #define STRCSPN_SSE42 __strcspn_sse42 |
| 33 | #define STRCSPN_SSE2 __strcspn_sse2 |
| 34 | #define __GI_STRCSPN __GI_strcspn |
| 35 | #endif |
| 36 | #endif |
| 37 | |
| 38 | /* Define multiple versions only for the definition in libc. Don't |
| 39 | define multiple versions for strpbrk in static library since we |
| 40 | need strpbrk before the initialization happened. */ |
| 41 | #if (defined SHARED || !defined USE_AS_STRPBRK) && IS_IN (libc) |
| 42 | .text |
| 43 | ENTRY(STRCSPN) |
| 44 | .type STRCSPN, @gnu_indirect_function |
| 45 | LOAD_RTLD_GLOBAL_RO_RDX |
| 46 | leaq STRCSPN_SSE2(%rip), %rax |
| 47 | HAS_CPU_FEATURE (SSE4_2) |
| 48 | jz 2f |
| 49 | leaq STRCSPN_SSE42(%rip), %rax |
| 50 | 2: ret |
| 51 | END(STRCSPN) |
| 52 | |
| 53 | # undef ENTRY |
| 54 | # define ENTRY(name) \ |
| 55 | .type STRCSPN_SSE2, @function; \ |
| 56 | .globl STRCSPN_SSE2; \ |
| 57 | .align 16; \ |
| 58 | STRCSPN_SSE2: cfi_startproc; \ |
| 59 | CALL_MCOUNT |
| 60 | # undef END |
| 61 | # define END(name) \ |
| 62 | cfi_endproc; .size STRCSPN_SSE2, .-STRCSPN_SSE2 |
| 63 | #endif |
| 64 | |
| 65 | #ifdef USE_AS_STRPBRK |
| 66 | #include "../strpbrk.S" |
| 67 | #else |
| 68 | #include "../strcspn.S" |
| 69 | #endif |
| 70 | |