]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/s390/multiarch/ifunc-impl-list.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / s390 / multiarch / ifunc-impl-list.c
1 /* Enumerate available IFUNC implementations of a function. s390/s390x version.
2 Copyright (C) 2015-2018 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 <ifunc-impl-list.h>
23 #include <ifunc-resolve.h>
24
25 /* Maximum number of IFUNC implementations. */
26 #define MAX_IFUNC 3
27
28 /* Fill ARRAY of MAX elements with IFUNC implementations for function
29 NAME supported on target machine and return the number of valid
30 entries. */
31 size_t
32 __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
33 size_t max)
34 {
35 assert (max >= MAX_IFUNC);
36
37 size_t i = 0;
38
39 /* Get hardware information. */
40 unsigned long int dl_hwcap = GLRO (dl_hwcap);
41 unsigned long long stfle_bits = 0ULL;
42 if ((dl_hwcap & HWCAP_S390_STFLE)
43 && (dl_hwcap & HWCAP_S390_ZARCH)
44 && (dl_hwcap & HWCAP_S390_HIGH_GPRS))
45 {
46 S390_STORE_STFLE (stfle_bits);
47 }
48
49 IFUNC_IMPL (i, name, memset,
50 IFUNC_IMPL_ADD (array, i, memset,
51 S390_IS_Z196 (stfle_bits), __memset_z196)
52 IFUNC_IMPL_ADD (array, i, memset,
53 S390_IS_Z10 (stfle_bits), __memset_z10)
54 IFUNC_IMPL_ADD (array, i, memset, 1, __memset_default))
55
56 IFUNC_IMPL (i, name, memcmp,
57 IFUNC_IMPL_ADD (array, i, memcmp,
58 S390_IS_Z196 (stfle_bits), __memcmp_z196)
59 IFUNC_IMPL_ADD (array, i, memcmp,
60 S390_IS_Z10 (stfle_bits), __memcmp_z10)
61 IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_default))
62
63 #ifdef SHARED
64
65 IFUNC_IMPL (i, name, memcpy,
66 IFUNC_IMPL_ADD (array, i, memcpy,
67 S390_IS_Z196 (stfle_bits), __memcpy_z196)
68 IFUNC_IMPL_ADD (array, i, memcpy,
69 S390_IS_Z10 (stfle_bits), __memcpy_z10)
70 IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_default))
71
72 IFUNC_IMPL (i, name, mempcpy,
73 IFUNC_IMPL_ADD (array, i, mempcpy,
74 S390_IS_Z196 (stfle_bits), ____mempcpy_z196)
75 IFUNC_IMPL_ADD (array, i, mempcpy,
76 S390_IS_Z10 (stfle_bits), ____mempcpy_z10)
77 IFUNC_IMPL_ADD (array, i, mempcpy, 1, ____mempcpy_default))
78
79 #endif /* SHARED */
80
81 #ifdef HAVE_S390_VX_ASM_SUPPORT
82
83 # define IFUNC_VX_IMPL(FUNC) \
84 IFUNC_IMPL (i, name, FUNC, \
85 IFUNC_IMPL_ADD (array, i, FUNC, dl_hwcap & HWCAP_S390_VX, \
86 __##FUNC##_vx) \
87 IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c))
88
89 IFUNC_VX_IMPL (strlen);
90 IFUNC_VX_IMPL (wcslen);
91
92 IFUNC_VX_IMPL (strnlen);
93 IFUNC_VX_IMPL (wcsnlen);
94
95 IFUNC_VX_IMPL (strcpy);
96 IFUNC_VX_IMPL (wcscpy);
97
98 IFUNC_VX_IMPL (stpcpy);
99 IFUNC_VX_IMPL (wcpcpy);
100
101 IFUNC_VX_IMPL (strncpy);
102 IFUNC_VX_IMPL (wcsncpy);
103
104 IFUNC_VX_IMPL (stpncpy);
105 IFUNC_VX_IMPL (wcpncpy);
106
107 IFUNC_VX_IMPL (strcat);
108 IFUNC_VX_IMPL (wcscat);
109
110 IFUNC_VX_IMPL (strncat);
111 IFUNC_VX_IMPL (wcsncat);
112
113 IFUNC_VX_IMPL (strcmp);
114 IFUNC_VX_IMPL (wcscmp);
115
116 IFUNC_VX_IMPL (strncmp);
117 IFUNC_VX_IMPL (wcsncmp);
118
119 IFUNC_VX_IMPL (strchr);
120 IFUNC_VX_IMPL (wcschr);
121
122 IFUNC_VX_IMPL (strchrnul);
123 IFUNC_VX_IMPL (wcschrnul);
124
125 IFUNC_VX_IMPL (strrchr);
126 IFUNC_VX_IMPL (wcsrchr);
127
128 IFUNC_VX_IMPL (strspn);
129 IFUNC_VX_IMPL (wcsspn);
130
131 IFUNC_VX_IMPL (strpbrk);
132 IFUNC_VX_IMPL (wcspbrk);
133
134 IFUNC_VX_IMPL (strcspn);
135 IFUNC_VX_IMPL (wcscspn);
136
137 IFUNC_VX_IMPL (memchr);
138 IFUNC_VX_IMPL (wmemchr);
139 IFUNC_VX_IMPL (rawmemchr);
140
141 IFUNC_VX_IMPL (memccpy);
142
143 IFUNC_VX_IMPL (wmemset);
144
145 IFUNC_VX_IMPL (wmemcmp);
146
147 IFUNC_VX_IMPL (memrchr);
148
149 #endif /* HAVE_S390_VX_ASM_SUPPORT */
150
151 return i;
152 }