1 /* Enumerate available IFUNC implementations of a function.  sparc version.
2    Copyright (C) 2012-2021 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 <sysdep.h>
24 #include <ifunc-impl-list.h>
25 
26 /* Fill ARRAY of MAX elements with IFUNC implementations for function
27    NAME and return the number of valid entries.  */
28 
29 size_t
__libc_ifunc_impl_list(const char * name,struct libc_ifunc_impl * array,size_t max)30 __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
31 			size_t max)
32 {
33   size_t i = 0;
34   int hwcap;
35 
36   hwcap = GLRO(dl_hwcap);
37 
38   IFUNC_IMPL (i, name, memcpy,
39 	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_SPARC_ADP,
40 			      __memcpy_niagara7)
41 	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_SPARC_CRYPTO,
42 			      __memcpy_niagara4)
43 	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_SPARC_N2,
44 			      __memcpy_niagara2)
45 	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_SPARC_BLKINIT,
46 			      __memcpy_niagara1)
47 	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_SPARC_ULTRA3,
48 			      __memcpy_ultra3)
49 	      IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ultra1));
50 
51   IFUNC_IMPL (i, name, mempcpy,
52 	      IFUNC_IMPL_ADD (array, i, mempcpy, hwcap & HWCAP_SPARC_ADP,
53 			      __mempcpy_niagara7)
54 	      IFUNC_IMPL_ADD (array, i, mempcpy, hwcap & HWCAP_SPARC_CRYPTO,
55 			      __mempcpy_niagara4)
56 	      IFUNC_IMPL_ADD (array, i, mempcpy, hwcap & HWCAP_SPARC_N2,
57 			      __mempcpy_niagara2)
58 	      IFUNC_IMPL_ADD (array, i, mempcpy, hwcap & HWCAP_SPARC_BLKINIT,
59 			      __mempcpy_niagara1)
60 	      IFUNC_IMPL_ADD (array, i, mempcpy, hwcap & HWCAP_SPARC_ULTRA3,
61 			      __mempcpy_ultra3)
62 	      IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_ultra1));
63 
64   IFUNC_IMPL (i, name, bzero,
65 	      IFUNC_IMPL_ADD (array, i, bzero, hwcap & HWCAP_SPARC_ADP,
66 			      __bzero_niagara7)
67 	      IFUNC_IMPL_ADD (array, i, bzero, hwcap & HWCAP_SPARC_CRYPTO,
68 			      __bzero_niagara4)
69 	      IFUNC_IMPL_ADD (array, i, bzero, hwcap & HWCAP_SPARC_BLKINIT,
70 			      __bzero_niagara1)
71 	      IFUNC_IMPL_ADD (array, i, bzero, 1, __bzero_ultra1));
72 
73   IFUNC_IMPL (i, name, memset,
74 	      IFUNC_IMPL_ADD (array, i, memset, hwcap & HWCAP_SPARC_ADP,
75 			      __memset_niagara7)
76 	      IFUNC_IMPL_ADD (array, i, memset, hwcap & HWCAP_SPARC_CRYPTO,
77 			      __memset_niagara4)
78 	      IFUNC_IMPL_ADD (array, i, memset, hwcap & HWCAP_SPARC_BLKINIT,
79 			      __memset_niagara1)
80 	      IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ultra1));
81 
82   IFUNC_IMPL (i, name, memmove,
83 	      IFUNC_IMPL_ADD (array, i, memmove, hwcap & HWCAP_SPARC_ADP,
84 			      __memmove_niagara7)
85 	      IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_ultra1));
86 
87   return i;
88 }
89