1 /* Enumerate available IFUNC implementations of a function. PowerPC32 version.
2 Copyright (C) 2013-2022 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 <https://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
25 size_t
__libc_ifunc_impl_list(const char * name,struct libc_ifunc_impl * array,size_t max)26 __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
27 size_t max)
28 {
29 size_t i = max;
30
31 unsigned long int hwcap = GLRO(dl_hwcap);
32 /* hwcap contains only the latest supported ISA, the code checks which is
33 and fills the previous supported ones. */
34 if (hwcap & PPC_FEATURE_ARCH_2_06)
35 hwcap |= PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_POWER5_PLUS |
36 PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
37 else if (hwcap & PPC_FEATURE_ARCH_2_05)
38 hwcap |= PPC_FEATURE_POWER5_PLUS | PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
39 else if (hwcap & PPC_FEATURE_POWER5_PLUS)
40 hwcap |= PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
41 else if (hwcap & PPC_FEATURE_POWER5)
42 hwcap |= PPC_FEATURE_POWER4;
43
44 #ifdef SHARED
45 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memcpy.c. */
46 IFUNC_IMPL (i, name, memcpy,
47 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_HAS_VSX,
48 __memcpy_power7)
49 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_06,
50 __memcpy_a2)
51 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_05,
52 __memcpy_power6)
53 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_CELL_BE,
54 __memcpy_cell)
55 IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ppc))
56
57 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memmove.c. */
58 IFUNC_IMPL (i, name, memmove,
59 IFUNC_IMPL_ADD (array, i, memmove, hwcap & PPC_FEATURE_HAS_VSX,
60 __memmove_power7)
61 IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_ppc))
62
63 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memset.c. */
64 IFUNC_IMPL (i, name, memset,
65 IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_HAS_VSX,
66 __memset_power7)
67 IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_ARCH_2_05,
68 __memset_power6)
69 IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ppc))
70
71 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strlen.c. */
72 IFUNC_IMPL (i, name, strlen,
73 IFUNC_IMPL_ADD (array, i, strlen, hwcap & PPC_FEATURE_HAS_VSX,
74 __strlen_power7)
75 IFUNC_IMPL_ADD (array, i, strlen, 1,
76 __strlen_ppc))
77
78 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strnlen.c. */
79 IFUNC_IMPL (i, name, strnlen,
80 IFUNC_IMPL_ADD (array, i, strnlen, hwcap & PPC_FEATURE_HAS_VSX,
81 __strnlen_power7)
82 IFUNC_IMPL_ADD (array, i, strnlen, 1,
83 __strnlen_ppc))
84
85 /* Support sysdeps/powerpc/powerpc32/multiarch/strncmp.c. */
86 IFUNC_IMPL (i, name, strncmp,
87 IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
88 __strncmp_power7)
89 IFUNC_IMPL_ADD (array, i, strncmp, 1,
90 __strncmp_ppc))
91 #endif
92
93 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memcmp.c. */
94 IFUNC_IMPL (i, name, memcmp,
95 IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_HAS_VSX,
96 __memcmp_power7)
97 IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_ppc))
98
99 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy.c. */
100 IFUNC_IMPL (i, name, mempcpy,
101 IFUNC_IMPL_ADD (array, i, mempcpy,
102 hwcap & PPC_FEATURE_HAS_VSX,
103 __mempcpy_power7)
104 IFUNC_IMPL_ADD (array, i, mempcpy, 1,
105 __mempcpy_ppc))
106
107 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memchr.c. */
108 IFUNC_IMPL (i, name, memchr,
109 IFUNC_IMPL_ADD (array, i, memchr,
110 hwcap & PPC_FEATURE_HAS_VSX,
111 __memchr_power7)
112 IFUNC_IMPL_ADD (array, i, memchr, 1,
113 __memchr_ppc))
114
115 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memrchr.c. */
116 IFUNC_IMPL (i, name, memrchr,
117 IFUNC_IMPL_ADD (array, i, memrchr,
118 hwcap & PPC_FEATURE_HAS_VSX,
119 __memrchr_power7)
120 IFUNC_IMPL_ADD (array, i, memrchr, 1,
121 __memrchr_ppc))
122
123 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr.c. */
124 IFUNC_IMPL (i, name, rawmemchr,
125 IFUNC_IMPL_ADD (array, i, rawmemchr,
126 hwcap & PPC_FEATURE_HAS_VSX,
127 __rawmemchr_power7)
128 IFUNC_IMPL_ADD (array, i, rawmemchr, 1,
129 __rawmemchr_ppc))
130
131 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strcasecmp.c. */
132 IFUNC_IMPL (i, name, strcasecmp,
133 IFUNC_IMPL_ADD (array, i, strcasecmp,
134 hwcap & PPC_FEATURE_HAS_VSX,
135 __strcasecmp_power7)
136 IFUNC_IMPL_ADD (array, i, strcasecmp, 1, __strcasecmp_ppc))
137
138 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strcasecmp_l.c. */
139 IFUNC_IMPL (i, name, strcasecmp_l,
140 IFUNC_IMPL_ADD (array, i, strcasecmp_l,
141 hwcap & PPC_FEATURE_HAS_VSX,
142 __strcasecmp_l_power7)
143 IFUNC_IMPL_ADD (array, i, strcasecmp_l, 1,
144 __strcasecmp_l_ppc))
145
146 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strncase.c. */
147 IFUNC_IMPL (i, name, strncasecmp,
148 IFUNC_IMPL_ADD (array, i, strncasecmp,
149 hwcap & PPC_FEATURE_HAS_VSX,
150 __strncasecmp_power7)
151 IFUNC_IMPL_ADD (array, i, strncasecmp, 1, __strncasecmp_ppc))
152
153 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strncase_l.c. */
154 IFUNC_IMPL (i, name, strncasecmp_l,
155 IFUNC_IMPL_ADD (array, i, strncasecmp_l,
156 hwcap & PPC_FEATURE_HAS_VSX,
157 __strncasecmp_l_power7)
158 IFUNC_IMPL_ADD (array, i, strncasecmp_l, 1,
159 __strncasecmp_l_ppc))
160
161 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul.c. */
162 IFUNC_IMPL (i, name, strchrnul,
163 IFUNC_IMPL_ADD (array, i, strchrnul,
164 hwcap & PPC_FEATURE_HAS_VSX,
165 __strchrnul_power7)
166 IFUNC_IMPL_ADD (array, i, strchrnul, 1,
167 __strchrnul_ppc))
168
169 /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strchr.c. */
170 IFUNC_IMPL (i, name, strchr,
171 IFUNC_IMPL_ADD (array, i, strchr,
172 hwcap & PPC_FEATURE_HAS_VSX,
173 __strchr_power7)
174 IFUNC_IMPL_ADD (array, i, strchr, 1,
175 __strchr_ppc))
176
177 return 0;
178 }
179