|
Packit |
6c4009 |
/* Enumerate available IFUNC implementations of a function. s390/s390x version.
|
|
Packit |
6c4009 |
Copyright (C) 2015-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <assert.h>
|
|
Packit |
6c4009 |
#include <string.h>
|
|
Packit |
6c4009 |
#include <wchar.h>
|
|
Packit |
6c4009 |
#include <ifunc-impl-list.h>
|
|
Packit |
6c4009 |
#include <ifunc-resolve.h>
|
|
Packit Service |
5d5063 |
#include <ifunc-memset.h>
|
|
Packit Service |
d9ef1b |
#include <ifunc-memcmp.h>
|
|
Packit Service |
29031e |
#include <ifunc-memcpy.h>
|
|
Packit Service |
04a158 |
#include <ifunc-strstr.h>
|
|
Packit Service |
72e31c |
#include <ifunc-memmem.h>
|
|
Packit Service |
7e7614 |
#include <ifunc-strlen.h>
|
|
Packit Service |
caf8d1 |
#include <ifunc-strnlen.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Maximum number of IFUNC implementations. */
|
|
Packit |
6c4009 |
#define MAX_IFUNC 3
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Fill ARRAY of MAX elements with IFUNC implementations for function
|
|
Packit |
6c4009 |
NAME supported on target machine and return the number of valid
|
|
Packit |
6c4009 |
entries. */
|
|
Packit |
6c4009 |
size_t
|
|
Packit |
6c4009 |
__libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
Packit |
6c4009 |
size_t max)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
assert (max >= MAX_IFUNC);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
size_t i = 0;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Get hardware information. */
|
|
Packit |
6c4009 |
unsigned long int dl_hwcap = GLRO (dl_hwcap);
|
|
Packit |
6c4009 |
unsigned long long stfle_bits = 0ULL;
|
|
Packit |
6c4009 |
if ((dl_hwcap & HWCAP_S390_STFLE)
|
|
Packit |
6c4009 |
&& (dl_hwcap & HWCAP_S390_ZARCH)
|
|
Packit |
6c4009 |
&& (dl_hwcap & HWCAP_S390_HIGH_GPRS))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
S390_STORE_STFLE (stfle_bits);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit Service |
5d5063 |
#if HAVE_MEMSET_IFUNC
|
|
Packit |
6c4009 |
IFUNC_IMPL (i, name, memset,
|
|
Packit Service |
5d5063 |
# if HAVE_MEMSET_Z196
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memset,
|
|
Packit Service |
5d5063 |
S390_IS_Z196 (stfle_bits), MEMSET_Z196)
|
|
Packit Service |
5d5063 |
# endif
|
|
Packit Service |
5d5063 |
# if HAVE_MEMSET_Z10
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memset,
|
|
Packit Service |
5d5063 |
S390_IS_Z10 (stfle_bits), MEMSET_Z10)
|
|
Packit Service |
5d5063 |
# endif
|
|
Packit Service |
5d5063 |
# if HAVE_MEMSET_Z900_G5
|
|
Packit Service |
5d5063 |
IFUNC_IMPL_ADD (array, i, memset, 1, MEMSET_Z900_G5)
|
|
Packit Service |
5d5063 |
# endif
|
|
Packit Service |
5d5063 |
)
|
|
Packit Service |
311b6e |
|
|
Packit Service |
311b6e |
/* Note: bzero is implemented in memset. */
|
|
Packit Service |
311b6e |
IFUNC_IMPL (i, name, bzero,
|
|
Packit Service |
311b6e |
# if HAVE_MEMSET_Z196
|
|
Packit Service |
311b6e |
IFUNC_IMPL_ADD (array, i, bzero,
|
|
Packit Service |
311b6e |
S390_IS_Z196 (stfle_bits), BZERO_Z196)
|
|
Packit Service |
311b6e |
# endif
|
|
Packit Service |
311b6e |
# if HAVE_MEMSET_Z10
|
|
Packit Service |
311b6e |
IFUNC_IMPL_ADD (array, i, bzero,
|
|
Packit Service |
311b6e |
S390_IS_Z10 (stfle_bits), BZERO_Z10)
|
|
Packit Service |
311b6e |
# endif
|
|
Packit Service |
311b6e |
# if HAVE_MEMSET_Z900_G5
|
|
Packit Service |
311b6e |
IFUNC_IMPL_ADD (array, i, bzero, 1, BZERO_Z900_G5)
|
|
Packit Service |
311b6e |
# endif
|
|
Packit Service |
311b6e |
)
|
|
Packit Service |
5d5063 |
#endif /* HAVE_MEMSET_IFUNC */
|
|
Packit Service |
6de65a |
|
|
Packit Service |
d9ef1b |
#if HAVE_MEMCMP_IFUNC
|
|
Packit |
6c4009 |
IFUNC_IMPL (i, name, memcmp,
|
|
Packit Service |
d9ef1b |
# if HAVE_MEMCMP_Z196
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memcmp,
|
|
Packit Service |
d9ef1b |
S390_IS_Z196 (stfle_bits), MEMCMP_Z196)
|
|
Packit Service |
d9ef1b |
# endif
|
|
Packit Service |
d9ef1b |
# if HAVE_MEMCMP_Z10
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memcmp,
|
|
Packit Service |
d9ef1b |
S390_IS_Z10 (stfle_bits), MEMCMP_Z10)
|
|
Packit Service |
d9ef1b |
# endif
|
|
Packit Service |
d9ef1b |
# if HAVE_MEMCMP_Z900_G5
|
|
Packit Service |
d9ef1b |
IFUNC_IMPL_ADD (array, i, memcmp, 1, MEMCMP_Z900_G5)
|
|
Packit Service |
d9ef1b |
# endif
|
|
Packit Service |
d9ef1b |
)
|
|
Packit Service |
d9ef1b |
#endif /* HAVE_MEMCMP_IFUNC */
|
|
Packit Service |
6de65a |
|
|
Packit Service |
29031e |
#if HAVE_MEMCPY_IFUNC
|
|
Packit |
6c4009 |
IFUNC_IMPL (i, name, memcpy,
|
|
Packit Service |
29031e |
# if HAVE_MEMCPY_Z196
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memcpy,
|
|
Packit Service |
29031e |
S390_IS_Z196 (stfle_bits), MEMCPY_Z196)
|
|
Packit Service |
29031e |
# endif
|
|
Packit Service |
29031e |
# if HAVE_MEMCPY_Z10
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memcpy,
|
|
Packit Service |
29031e |
S390_IS_Z10 (stfle_bits), MEMCPY_Z10)
|
|
Packit Service |
29031e |
# endif
|
|
Packit Service |
29031e |
# if HAVE_MEMCPY_Z900_G5
|
|
Packit Service |
29031e |
IFUNC_IMPL_ADD (array, i, memcpy, 1, MEMCPY_Z900_G5)
|
|
Packit Service |
29031e |
# endif
|
|
Packit Service |
29031e |
)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
IFUNC_IMPL (i, name, mempcpy,
|
|
Packit Service |
29031e |
# if HAVE_MEMCPY_Z196
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, mempcpy,
|
|
Packit Service |
29031e |
S390_IS_Z196 (stfle_bits), MEMPCPY_Z196)
|
|
Packit Service |
29031e |
# endif
|
|
Packit Service |
29031e |
# if HAVE_MEMCPY_Z10
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, mempcpy,
|
|
Packit Service |
29031e |
S390_IS_Z10 (stfle_bits), MEMPCPY_Z10)
|
|
Packit Service |
29031e |
# endif
|
|
Packit Service |
29031e |
# if HAVE_MEMCPY_Z900_G5
|
|
Packit Service |
29031e |
IFUNC_IMPL_ADD (array, i, mempcpy, 1, MEMPCPY_Z900_G5)
|
|
Packit Service |
29031e |
# endif
|
|
Packit Service |
29031e |
)
|
|
Packit Service |
29031e |
#endif /* HAVE_MEMCPY_IFUNC */
|
|
Packit Service |
6de65a |
|
|
Packit Service |
dd06b0 |
#if HAVE_MEMMOVE_IFUNC
|
|
Packit Service |
dd06b0 |
IFUNC_IMPL (i, name, memmove,
|
|
Packit Service |
dd06b0 |
# if HAVE_MEMMOVE_Z13
|
|
Packit Service |
dd06b0 |
IFUNC_IMPL_ADD (array, i, memmove,
|
|
Packit Service |
dd06b0 |
dl_hwcap & HWCAP_S390_VX, MEMMOVE_Z13)
|
|
Packit Service |
dd06b0 |
# endif
|
|
Packit Service |
dd06b0 |
# if HAVE_MEMMOVE_C
|
|
Packit Service |
dd06b0 |
IFUNC_IMPL_ADD (array, i, memmove, 1, MEMMOVE_C)
|
|
Packit Service |
dd06b0 |
# endif
|
|
Packit Service |
dd06b0 |
)
|
|
Packit Service |
dd06b0 |
#endif /* HAVE_MEMMOVE_IFUNC */
|
|
Packit Service |
dd06b0 |
|
|
Packit Service |
04a158 |
#if HAVE_STRSTR_IFUNC
|
|
Packit Service |
04a158 |
IFUNC_IMPL (i, name, strstr,
|
|
Packit Service |
04a158 |
# if HAVE_STRSTR_Z13
|
|
Packit Service |
04a158 |
IFUNC_IMPL_ADD (array, i, strstr,
|
|
Packit Service |
04a158 |
dl_hwcap & HWCAP_S390_VX, STRSTR_Z13)
|
|
Packit Service |
04a158 |
# endif
|
|
Packit Service |
04a158 |
# if HAVE_STRSTR_C
|
|
Packit Service |
04a158 |
IFUNC_IMPL_ADD (array, i, strstr, 1, STRSTR_C)
|
|
Packit Service |
04a158 |
# endif
|
|
Packit Service |
04a158 |
)
|
|
Packit Service |
04a158 |
#endif /* HAVE_STRSTR_IFUNC */
|
|
Packit Service |
04a158 |
|
|
Packit Service |
72e31c |
#if HAVE_MEMMEM_IFUNC
|
|
Packit Service |
72e31c |
IFUNC_IMPL (i, name, memmem,
|
|
Packit Service |
72e31c |
# if HAVE_MEMMEM_Z13
|
|
Packit Service |
72e31c |
IFUNC_IMPL_ADD (array, i, memmem,
|
|
Packit Service |
72e31c |
dl_hwcap & HWCAP_S390_VX, MEMMEM_Z13)
|
|
Packit Service |
72e31c |
# endif
|
|
Packit Service |
72e31c |
# if HAVE_MEMMEM_C
|
|
Packit Service |
72e31c |
IFUNC_IMPL_ADD (array, i, memmem, 1, MEMMEM_C)
|
|
Packit Service |
72e31c |
# endif
|
|
Packit Service |
72e31c |
)
|
|
Packit Service |
72e31c |
#endif /* HAVE_MEMMEM_IFUNC */
|
|
Packit Service |
72e31c |
|
|
Packit Service |
7e7614 |
#if HAVE_STRLEN_IFUNC
|
|
Packit Service |
7e7614 |
IFUNC_IMPL (i, name, strlen,
|
|
Packit Service |
7e7614 |
# if HAVE_STRLEN_Z13
|
|
Packit Service |
7e7614 |
IFUNC_IMPL_ADD (array, i, strlen,
|
|
Packit Service |
7e7614 |
dl_hwcap & HWCAP_S390_VX, STRLEN_Z13)
|
|
Packit Service |
7e7614 |
# endif
|
|
Packit Service |
7e7614 |
# if HAVE_STRLEN_C
|
|
Packit Service |
7e7614 |
IFUNC_IMPL_ADD (array, i, strlen, 1, STRLEN_C)
|
|
Packit Service |
7e7614 |
# endif
|
|
Packit Service |
7e7614 |
)
|
|
Packit Service |
7e7614 |
#endif /* HAVE_STRLEN_IFUNC */
|
|
Packit Service |
7e7614 |
|
|
Packit Service |
caf8d1 |
#if HAVE_STRNLEN_IFUNC
|
|
Packit Service |
caf8d1 |
IFUNC_IMPL (i, name, strnlen,
|
|
Packit Service |
caf8d1 |
# if HAVE_STRNLEN_Z13
|
|
Packit Service |
caf8d1 |
IFUNC_IMPL_ADD (array, i, strnlen,
|
|
Packit Service |
caf8d1 |
dl_hwcap & HWCAP_S390_VX, STRNLEN_Z13)
|
|
Packit Service |
caf8d1 |
# endif
|
|
Packit Service |
caf8d1 |
# if HAVE_STRNLEN_C
|
|
Packit Service |
caf8d1 |
IFUNC_IMPL_ADD (array, i, strnlen, 1, STRNLEN_C)
|
|
Packit Service |
caf8d1 |
# endif
|
|
Packit Service |
caf8d1 |
)
|
|
Packit Service |
caf8d1 |
#endif /* HAVE_STRNLEN_IFUNC */
|
|
Packit Service |
caf8d1 |
|
|
Packit Service |
6de65a |
#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
# define IFUNC_VX_IMPL(FUNC) \
|
|
Packit Service |
6de65a |
IFUNC_IMPL (i, name, FUNC, \
|
|
Packit Service |
6de65a |
IFUNC_IMPL_ADD (array, i, FUNC, dl_hwcap & HWCAP_S390_VX, \
|
|
Packit Service |
6de65a |
__##FUNC##_vx) \
|
|
Packit Service |
6de65a |
IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c))
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcslen);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcsnlen);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strcpy);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcscpy);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (stpcpy);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcpcpy);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strncpy);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcsncpy);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (stpncpy);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcpncpy);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strcat);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcscat);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strncat);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcsncat);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strcmp);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcscmp);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strncmp);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcsncmp);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strchr);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcschr);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strchrnul);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcschrnul);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strrchr);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcsrchr);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strspn);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcsspn);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strpbrk);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcspbrk);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (strcspn);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wcscspn);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (memchr);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wmemchr);
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (rawmemchr);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (memccpy);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wmemset);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (wmemcmp);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
IFUNC_VX_IMPL (memrchr);
|
|
Packit Service |
6de65a |
|
|
Packit Service |
6de65a |
#endif /* HAVE_S390_VX_ASM_SUPPORT */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return i;
|
|
Packit |
6c4009 |
}
|