S390: Optimize wmemset.
[glibc.git] / sysdeps / s390 / multiarch / ifunc-impl-list.c
blob93789acbbe8a4c52c22c9b158a1879960cd8f4c9
1 /* Enumerate available IFUNC implementations of a function. s390/s390x version.
2 Copyright (C) 2015 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 <ifunc-impl-list.h>
23 #include <ifunc-resolve.h>
25 /* Maximum number of IFUNC implementations. */
26 #define MAX_IFUNC 3
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)
35 assert (max >= MAX_IFUNC);
37 size_t i = 0;
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))
46 S390_STORE_STFLE (stfle_bits);
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))
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))
63 #ifdef SHARED
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))
72 #endif /* SHARED */
74 #ifdef HAVE_S390_VX_ASM_SUPPORT
76 # define IFUNC_VX_IMPL(FUNC) \
77 IFUNC_IMPL (i, name, FUNC, \
78 IFUNC_IMPL_ADD (array, i, FUNC, dl_hwcap & HWCAP_S390_VX, \
79 __##FUNC##_vx) \
80 IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c))
82 IFUNC_VX_IMPL (strlen);
83 IFUNC_VX_IMPL (wcslen);
85 IFUNC_VX_IMPL (strnlen);
86 IFUNC_VX_IMPL (wcsnlen);
88 IFUNC_VX_IMPL (strcpy);
89 IFUNC_VX_IMPL (wcscpy);
91 IFUNC_VX_IMPL (stpcpy);
92 IFUNC_VX_IMPL (wcpcpy);
94 IFUNC_VX_IMPL (strncpy);
95 IFUNC_VX_IMPL (wcsncpy);
97 IFUNC_VX_IMPL (stpncpy);
98 IFUNC_VX_IMPL (wcpncpy);
100 IFUNC_VX_IMPL (strcat);
101 IFUNC_VX_IMPL (wcscat);
103 IFUNC_VX_IMPL (strncat);
104 IFUNC_VX_IMPL (wcsncat);
106 IFUNC_VX_IMPL (strcmp);
107 IFUNC_VX_IMPL (wcscmp);
109 IFUNC_VX_IMPL (strncmp);
110 IFUNC_VX_IMPL (wcsncmp);
112 IFUNC_VX_IMPL (strchr);
113 IFUNC_VX_IMPL (wcschr);
115 IFUNC_VX_IMPL (strchrnul);
116 IFUNC_VX_IMPL (wcschrnul);
118 IFUNC_VX_IMPL (strrchr);
119 IFUNC_VX_IMPL (wcsrchr);
121 IFUNC_VX_IMPL (strspn);
122 IFUNC_VX_IMPL (wcsspn);
124 IFUNC_VX_IMPL (strpbrk);
125 IFUNC_VX_IMPL (wcspbrk);
127 IFUNC_VX_IMPL (strcspn);
128 IFUNC_VX_IMPL (wcscspn);
130 IFUNC_VX_IMPL (memchr);
131 IFUNC_VX_IMPL (wmemchr);
132 IFUNC_VX_IMPL (rawmemchr);
134 IFUNC_VX_IMPL (memccpy);
136 IFUNC_VX_IMPL (wmemset);
137 #endif /* HAVE_S390_VX_ASM_SUPPORT */
139 return i;