| 1 | /* Enumerate available IFUNC implementations of a function LoongArch64 version. |
| 2 | Copyright (C) 2023-2024 Free Software Foundation, Inc. |
| 3 | This file is part of the GNU C Library. |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library; if not, see |
| 17 | <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #include <assert.h> |
| 20 | #include <string.h> |
| 21 | #include <wchar.h> |
| 22 | #include <ldsodefs.h> |
| 23 | #include <ifunc-impl-list.h> |
| 24 | #include <stdio.h> |
| 25 | |
| 26 | size_t |
| 27 | __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, |
| 28 | size_t max) |
| 29 | { |
| 30 | |
| 31 | size_t i = max; |
| 32 | |
| 33 | IFUNC_IMPL (i, name, strlen, |
| 34 | #if !defined __loongarch_soft_float |
| 35 | IFUNC_IMPL_ADD (array, i, strlen, SUPPORT_LASX, __strlen_lasx) |
| 36 | IFUNC_IMPL_ADD (array, i, strlen, SUPPORT_LSX, __strlen_lsx) |
| 37 | #endif |
| 38 | IFUNC_IMPL_ADD (array, i, strlen, 1, __strlen_aligned) |
| 39 | ) |
| 40 | |
| 41 | IFUNC_IMPL (i, name, strnlen, |
| 42 | #if !defined __loongarch_soft_float |
| 43 | IFUNC_IMPL_ADD (array, i, strnlen, SUPPORT_LASX, __strnlen_lasx) |
| 44 | IFUNC_IMPL_ADD (array, i, strnlen, SUPPORT_LSX, __strnlen_lsx) |
| 45 | #endif |
| 46 | IFUNC_IMPL_ADD (array, i, strnlen, 1, __strnlen_aligned) |
| 47 | ) |
| 48 | |
| 49 | IFUNC_IMPL (i, name, strchr, |
| 50 | #if !defined __loongarch_soft_float |
| 51 | IFUNC_IMPL_ADD (array, i, strchr, SUPPORT_LASX, __strchr_lasx) |
| 52 | IFUNC_IMPL_ADD (array, i, strchr, SUPPORT_LSX, __strchr_lsx) |
| 53 | #endif |
| 54 | IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_aligned) |
| 55 | ) |
| 56 | |
| 57 | IFUNC_IMPL (i, name, strchrnul, |
| 58 | #if !defined __loongarch_soft_float |
| 59 | IFUNC_IMPL_ADD (array, i, strchrnul, SUPPORT_LASX, __strchrnul_lasx) |
| 60 | IFUNC_IMPL_ADD (array, i, strchrnul, SUPPORT_LSX, __strchrnul_lsx) |
| 61 | #endif |
| 62 | IFUNC_IMPL_ADD (array, i, strchrnul, 1, __strchrnul_aligned) |
| 63 | ) |
| 64 | |
| 65 | IFUNC_IMPL (i, name, strcmp, |
| 66 | #if !defined __loongarch_soft_float |
| 67 | IFUNC_IMPL_ADD (array, i, strcmp, SUPPORT_LSX, __strcmp_lsx) |
| 68 | #endif |
| 69 | IFUNC_IMPL_ADD (array, i, strcmp, 1, __strcmp_aligned) |
| 70 | ) |
| 71 | |
| 72 | IFUNC_IMPL (i, name, strncmp, |
| 73 | #if !defined __loongarch_soft_float |
| 74 | IFUNC_IMPL_ADD (array, i, strncmp, SUPPORT_LSX, __strncmp_lsx) |
| 75 | #endif |
| 76 | IFUNC_IMPL_ADD (array, i, strncmp, 1, __strncmp_aligned) |
| 77 | ) |
| 78 | |
| 79 | IFUNC_IMPL (i, name, strcpy, |
| 80 | #if !defined __loongarch_soft_float |
| 81 | IFUNC_IMPL_ADD (array, i, strcpy, SUPPORT_LASX, __strcpy_lasx) |
| 82 | IFUNC_IMPL_ADD (array, i, strcpy, SUPPORT_LSX, __strcpy_lsx) |
| 83 | #endif |
| 84 | IFUNC_IMPL_ADD (array, i, strcpy, SUPPORT_UAL, __strcpy_unaligned) |
| 85 | IFUNC_IMPL_ADD (array, i, strcpy, 1, __strcpy_aligned) |
| 86 | ) |
| 87 | |
| 88 | IFUNC_IMPL (i, name, stpcpy, |
| 89 | #if !defined __loongarch_soft_float |
| 90 | IFUNC_IMPL_ADD (array, i, stpcpy, SUPPORT_LASX, __stpcpy_lasx) |
| 91 | IFUNC_IMPL_ADD (array, i, stpcpy, SUPPORT_LSX, __stpcpy_lsx) |
| 92 | #endif |
| 93 | IFUNC_IMPL_ADD (array, i, stpcpy, SUPPORT_UAL, __stpcpy_unaligned) |
| 94 | IFUNC_IMPL_ADD (array, i, stpcpy, 1, __stpcpy_aligned) |
| 95 | ) |
| 96 | |
| 97 | IFUNC_IMPL (i, name, strrchr, |
| 98 | #if !defined __loongarch_soft_float |
| 99 | IFUNC_IMPL_ADD (array, i, strrchr, SUPPORT_LASX, __strrchr_lasx) |
| 100 | IFUNC_IMPL_ADD (array, i, strrchr, SUPPORT_LSX, __strrchr_lsx) |
| 101 | #endif |
| 102 | IFUNC_IMPL_ADD (array, i, strrchr, 1, __strrchr_aligned) |
| 103 | ) |
| 104 | |
| 105 | IFUNC_IMPL (i, name, memcpy, |
| 106 | #if !defined __loongarch_soft_float |
| 107 | IFUNC_IMPL_ADD (array, i, memcpy, SUPPORT_LASX, __memcpy_lasx) |
| 108 | IFUNC_IMPL_ADD (array, i, memcpy, SUPPORT_LSX, __memcpy_lsx) |
| 109 | #endif |
| 110 | IFUNC_IMPL_ADD (array, i, memcpy, SUPPORT_UAL, __memcpy_unaligned) |
| 111 | IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_aligned) |
| 112 | ) |
| 113 | |
| 114 | IFUNC_IMPL (i, name, memmove, |
| 115 | #if !defined __loongarch_soft_float |
| 116 | IFUNC_IMPL_ADD (array, i, memmove, SUPPORT_LASX, __memmove_lasx) |
| 117 | IFUNC_IMPL_ADD (array, i, memmove, SUPPORT_LSX, __memmove_lsx) |
| 118 | #endif |
| 119 | IFUNC_IMPL_ADD (array, i, memmove, SUPPORT_UAL, __memmove_unaligned) |
| 120 | IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_aligned) |
| 121 | ) |
| 122 | |
| 123 | IFUNC_IMPL (i, name, rawmemchr, |
| 124 | #if !defined __loongarch_soft_float |
| 125 | IFUNC_IMPL_ADD (array, i, rawmemchr, SUPPORT_LASX, __rawmemchr_lasx) |
| 126 | IFUNC_IMPL_ADD (array, i, rawmemchr, SUPPORT_LSX, __rawmemchr_lsx) |
| 127 | #endif |
| 128 | IFUNC_IMPL_ADD (array, i, rawmemchr, 1, __rawmemchr_aligned) |
| 129 | ) |
| 130 | |
| 131 | IFUNC_IMPL (i, name, memchr, |
| 132 | #if !defined __loongarch_soft_float |
| 133 | IFUNC_IMPL_ADD (array, i, memchr, SUPPORT_LASX, __memchr_lasx) |
| 134 | IFUNC_IMPL_ADD (array, i, memchr, SUPPORT_LSX, __memchr_lsx) |
| 135 | #endif |
| 136 | IFUNC_IMPL_ADD (array, i, memchr, 1, __memchr_aligned) |
| 137 | ) |
| 138 | |
| 139 | IFUNC_IMPL (i, name, memrchr, |
| 140 | #if !defined __loongarch_soft_float |
| 141 | IFUNC_IMPL_ADD (array, i, memrchr, SUPPORT_LASX, __memrchr_lasx) |
| 142 | IFUNC_IMPL_ADD (array, i, memrchr, SUPPORT_LSX, __memrchr_lsx) |
| 143 | #endif |
| 144 | IFUNC_IMPL_ADD (array, i, memrchr, 1, __memrchr_generic) |
| 145 | ) |
| 146 | |
| 147 | IFUNC_IMPL (i, name, memset, |
| 148 | #if !defined __loongarch_soft_float |
| 149 | IFUNC_IMPL_ADD (array, i, memset, SUPPORT_LASX, __memset_lasx) |
| 150 | IFUNC_IMPL_ADD (array, i, memset, SUPPORT_LSX, __memset_lsx) |
| 151 | #endif |
| 152 | IFUNC_IMPL_ADD (array, i, memset, SUPPORT_UAL, __memset_unaligned) |
| 153 | IFUNC_IMPL_ADD (array, i, memset, 1, __memset_aligned) |
| 154 | ) |
| 155 | |
| 156 | IFUNC_IMPL (i, name, memcmp, |
| 157 | #if !defined __loongarch_soft_float |
| 158 | IFUNC_IMPL_ADD (array, i, memcmp, SUPPORT_LASX, __memcmp_lasx) |
| 159 | IFUNC_IMPL_ADD (array, i, memcmp, SUPPORT_LSX, __memcmp_lsx) |
| 160 | #endif |
| 161 | IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_aligned) |
| 162 | ) |
| 163 | return i; |
| 164 | } |
| 165 | |