| 1 | /* Multiple versions of memmove. |
| 2 | All versions must be listed in ifunc-impl-list.c. |
| 3 | Copyright (C) 2010-2016 Free Software Foundation, Inc. |
| 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 |
| 17 | License along with the GNU C Library; if not, see |
| 18 | <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | #if IS_IN (libc) |
| 21 | # define MEMMOVE __memmove_sse2 |
| 22 | # ifdef SHARED |
| 23 | # undef libc_hidden_builtin_def |
| 24 | # define libc_hidden_builtin_def(name) \ |
| 25 | __hidden_ver1 (__memmove_sse2, __GI_memmove, __memmove_sse2); |
| 26 | # endif |
| 27 | |
| 28 | /* Redefine memmove so that the compiler won't complain about the type |
| 29 | mismatch with the IFUNC selector in strong_alias, below. */ |
| 30 | # undef memmove |
| 31 | # define memmove __redirect_memmove |
| 32 | # include <string.h> |
| 33 | # undef memmove |
| 34 | |
| 35 | extern __typeof (__redirect_memmove) __memmove_sse2 attribute_hidden; |
| 36 | extern __typeof (__redirect_memmove) __memmove_ssse3 attribute_hidden; |
| 37 | extern __typeof (__redirect_memmove) __memmove_ssse3_back attribute_hidden; |
| 38 | extern __typeof (__redirect_memmove) __memmove_avx_unaligned attribute_hidden; |
| 39 | # ifdef HAVE_AVX512_ASM_SUPPORT |
| 40 | extern __typeof (__redirect_memmove) __memmove_avx512_no_vzeroupper attribute_hidden; |
| 41 | # endif |
| 42 | |
| 43 | #endif |
| 44 | |
| 45 | #include "string/memmove.c" |
| 46 | |
| 47 | #if IS_IN (libc) |
| 48 | # include <shlib-compat.h> |
| 49 | # include "init-arch.h" |
| 50 | |
| 51 | /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle |
| 52 | ifunc symbol properly. */ |
| 53 | extern __typeof (__redirect_memmove) __libc_memmove; |
| 54 | libc_ifunc (__libc_memmove, |
| 55 | #ifdef HAVE_AVX512_ASM_SUPPORT |
| 56 | HAS_ARCH_FEATURE (AVX512F_Usable) |
| 57 | && HAS_ARCH_FEATURE (Prefer_No_VZEROUPPER) |
| 58 | ? __memmove_avx512_no_vzeroupper |
| 59 | : |
| 60 | #endif |
| 61 | (HAS_ARCH_FEATURE (AVX_Fast_Unaligned_Load) |
| 62 | ? __memmove_avx_unaligned |
| 63 | : (HAS_CPU_FEATURE (SSSE3) |
| 64 | ? (HAS_ARCH_FEATURE (Fast_Copy_Backward) |
| 65 | ? __memmove_ssse3_back : __memmove_ssse3) |
| 66 | : __memmove_sse2))); |
| 67 | |
| 68 | strong_alias (__libc_memmove, memmove) |
| 69 | |
| 70 | # if SHLIB_COMPAT (libc, GLIBC_2_2_5, GLIBC_2_14) |
| 71 | compat_symbol (libc, memmove, memcpy, GLIBC_2_2_5); |
| 72 | # endif |
| 73 | #endif |
| 74 | |