PowerPC: multiarch rawmemchr for PowerPC64
[glibc.git] / sysdeps / powerpc / powerpc64 / multiarch / ifunc-impl-list.c
blob4b64cd6511402c3e81cd69d80e044f2e66256db0
1 /* Enumerate available IFUNC implementations of a function. PowerPC64 version.
2 Copyright (C) 2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #include <assert.h>
20 #include <string.h>
21 #include <wchar.h>
22 #include <ldsodefs.h>
23 #include <ifunc-impl-list.h>
25 /* Maximum number of IFUNC implementations. */
26 #define MAX_IFUNC 6
28 size_t
29 __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
30 size_t max)
32 assert (max >= MAX_IFUNC);
34 size_t i = 0;
36 unsigned long int hwcap = GLRO(dl_hwcap);
37 /* hwcap contains only the latest supported ISA, the code checks which is
38 and fills the previous supported ones. */
39 if (hwcap & PPC_FEATURE_ARCH_2_06)
40 hwcap |= PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_POWER5_PLUS |
41 PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
42 else if (hwcap & PPC_FEATURE_ARCH_2_05)
43 hwcap |= PPC_FEATURE_POWER5_PLUS | PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
44 else if (hwcap & PPC_FEATURE_POWER5_PLUS)
45 hwcap |= PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
46 else if (hwcap & PPC_FEATURE_POWER5)
47 hwcap |= PPC_FEATURE_POWER4;
49 #ifdef SHARED
50 /* Support sysdeps/powerpc/powerpc64/multiarch/memcpy.c. */
51 IFUNC_IMPL (i, name, memcpy,
52 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_HAS_VSX,
53 __memcpy_power7)
54 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_06,
55 __memcpy_a2)
56 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_05,
57 __memcpy_power6)
58 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_CELL_BE,
59 __memcpy_cell)
60 IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_POWER4,
61 __memcpy_power4)
62 IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ppc))
64 /* Support sysdeps/powerpc/powerpc64/multiarch/memset.c. */
65 IFUNC_IMPL (i, name, memset,
66 IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_HAS_VSX,
67 __memset_power7)
68 IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_ARCH_2_05,
69 __memset_power6)
70 IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_POWER4,
71 __memset_power4)
72 IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ppc))
73 #endif
75 /* Support sysdeps/powerpc/powerpc64/multiarch/memcmp.c. */
76 IFUNC_IMPL (i, name, memcmp,
77 IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_HAS_VSX,
78 __memcmp_power7)
79 IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_POWER4,
80 __memcmp_power4)
81 IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_ppc))
83 /* Support sysdeps/powerpc/powerpc64/multiarch/bzero.c. */
84 IFUNC_IMPL (i, name, bzero,
85 IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_FEATURE_HAS_VSX,
86 __bzero_power7)
87 IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_FEATURE_ARCH_2_05,
88 __bzero_power6)
89 IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_FEATURE_POWER4,
90 __bzero_power4)
91 IFUNC_IMPL_ADD (array, i, bzero, 1, __bzero_ppc))
93 /* Support sysdeps/powerpc/powerpc64/multiarch/mempcpy.c. */
94 IFUNC_IMPL (i, name, mempcpy,
95 IFUNC_IMPL_ADD (array, i, mempcpy,
96 hwcap & PPC_FEATURE_HAS_VSX,
97 __mempcpy_power7)
98 IFUNC_IMPL_ADD (array, i, mempcpy, 1,
99 __mempcpy_ppc))
101 /* Support sysdeps/powerpc/powerpc64/multiarch/memchr.c. */
102 IFUNC_IMPL (i, name, memchr,
103 IFUNC_IMPL_ADD (array, i, memchr,
104 hwcap & PPC_FEATURE_HAS_VSX,
105 __memchr_power7)
106 IFUNC_IMPL_ADD (array, i, memchr, 1,
107 __memchr_ppc))
109 /* Support sysdeps/powerpc/powerpc64/multiarch/memrchr.c. */
110 IFUNC_IMPL (i, name, memrchr,
111 IFUNC_IMPL_ADD (array, i, memrchr,
112 hwcap & PPC_FEATURE_HAS_VSX,
113 __memrchr_power7)
114 IFUNC_IMPL_ADD (array, i, memrchr, 1,
115 __memrchr_ppc))
117 /* Support sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c. */
118 IFUNC_IMPL (i, name, rawmemchr,
119 IFUNC_IMPL_ADD (array, i, rawmemchr,
120 hwcap & PPC_FEATURE_HAS_VSX,
121 __rawmemchr_power7)
122 IFUNC_IMPL_ADD (array, i, rawmemchr, 1,
123 __rawmemchr_ppc))
125 return i;