|
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 |
891b27 |
#include <ifunc-memset.h>
|
|
Packit Service |
24eae6 |
#include <ifunc-memcmp.h>
|
|
Packit Service |
8dcd58 |
#include <ifunc-memcpy.h>
|
|
Packit Service |
c1a30a |
#include <ifunc-strstr.h>
|
|
Packit Service |
ae60be |
#include <ifunc-memmem.h>
|
|
Packit Service |
f08bdf |
#include <ifunc-strlen.h>
|
|
Packit Service |
0ebf48 |
#include <ifunc-strnlen.h>
|
|
Packit Service |
297929 |
#include <ifunc-strcpy.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 |
891b27 |
#if HAVE_MEMSET_IFUNC
|
|
Packit |
6c4009 |
IFUNC_IMPL (i, name, memset,
|
|
Packit Service |
891b27 |
# if HAVE_MEMSET_Z196
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memset,
|
|
Packit Service |
891b27 |
S390_IS_Z196 (stfle_bits), MEMSET_Z196)
|
|
Packit Service |
891b27 |
# endif
|
|
Packit Service |
891b27 |
# if HAVE_MEMSET_Z10
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memset,
|
|
Packit Service |
891b27 |
S390_IS_Z10 (stfle_bits), MEMSET_Z10)
|
|
Packit Service |
891b27 |
# endif
|
|
Packit Service |
891b27 |
# if HAVE_MEMSET_Z900_G5
|
|
Packit Service |
891b27 |
IFUNC_IMPL_ADD (array, i, memset, 1, MEMSET_Z900_G5)
|
|
Packit Service |
891b27 |
# endif
|
|
Packit Service |
891b27 |
)
|
|
Packit Service |
c413bc |
|
|
Packit Service |
c413bc |
/* Note: bzero is implemented in memset. */
|
|
Packit Service |
c413bc |
IFUNC_IMPL (i, name, bzero,
|
|
Packit Service |
c413bc |
# if HAVE_MEMSET_Z196
|
|
Packit Service |
c413bc |
IFUNC_IMPL_ADD (array, i, bzero,
|
|
Packit Service |
c413bc |
S390_IS_Z196 (stfle_bits), BZERO_Z196)
|
|
Packit Service |
c413bc |
# endif
|
|
Packit Service |
c413bc |
# if HAVE_MEMSET_Z10
|
|
Packit Service |
c413bc |
IFUNC_IMPL_ADD (array, i, bzero,
|
|
Packit Service |
c413bc |
S390_IS_Z10 (stfle_bits), BZERO_Z10)
|
|
Packit Service |
c413bc |
# endif
|
|
Packit Service |
c413bc |
# if HAVE_MEMSET_Z900_G5
|
|
Packit Service |
c413bc |
IFUNC_IMPL_ADD (array, i, bzero, 1, BZERO_Z900_G5)
|
|
Packit Service |
c413bc |
# endif
|
|
Packit Service |
c413bc |
)
|
|
Packit Service |
891b27 |
#endif /* HAVE_MEMSET_IFUNC */
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
24eae6 |
#if HAVE_MEMCMP_IFUNC
|
|
Packit |
6c4009 |
IFUNC_IMPL (i, name, memcmp,
|
|
Packit Service |
24eae6 |
# if HAVE_MEMCMP_Z196
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memcmp,
|
|
Packit Service |
24eae6 |
S390_IS_Z196 (stfle_bits), MEMCMP_Z196)
|
|
Packit Service |
24eae6 |
# endif
|
|
Packit Service |
24eae6 |
# if HAVE_MEMCMP_Z10
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memcmp,
|
|
Packit Service |
24eae6 |
S390_IS_Z10 (stfle_bits), MEMCMP_Z10)
|
|
Packit Service |
24eae6 |
# endif
|
|
Packit Service |
24eae6 |
# if HAVE_MEMCMP_Z900_G5
|
|
Packit Service |
24eae6 |
IFUNC_IMPL_ADD (array, i, memcmp, 1, MEMCMP_Z900_G5)
|
|
Packit Service |
24eae6 |
# endif
|
|
Packit Service |
24eae6 |
)
|
|
Packit Service |
24eae6 |
#endif /* HAVE_MEMCMP_IFUNC */
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8dcd58 |
#if HAVE_MEMCPY_IFUNC
|
|
Packit |
6c4009 |
IFUNC_IMPL (i, name, memcpy,
|
|
Packit Service |
8dcd58 |
# if HAVE_MEMCPY_Z196
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memcpy,
|
|
Packit Service |
8dcd58 |
S390_IS_Z196 (stfle_bits), MEMCPY_Z196)
|
|
Packit Service |
8dcd58 |
# endif
|
|
Packit Service |
8dcd58 |
# if HAVE_MEMCPY_Z10
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, memcpy,
|
|
Packit Service |
8dcd58 |
S390_IS_Z10 (stfle_bits), MEMCPY_Z10)
|
|
Packit Service |
8dcd58 |
# endif
|
|
Packit Service |
8dcd58 |
# if HAVE_MEMCPY_Z900_G5
|
|
Packit Service |
8dcd58 |
IFUNC_IMPL_ADD (array, i, memcpy, 1, MEMCPY_Z900_G5)
|
|
Packit Service |
8dcd58 |
# endif
|
|
Packit Service |
8dcd58 |
)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
IFUNC_IMPL (i, name, mempcpy,
|
|
Packit Service |
8dcd58 |
# if HAVE_MEMCPY_Z196
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, mempcpy,
|
|
Packit Service |
8dcd58 |
S390_IS_Z196 (stfle_bits), MEMPCPY_Z196)
|
|
Packit Service |
8dcd58 |
# endif
|
|
Packit Service |
8dcd58 |
# if HAVE_MEMCPY_Z10
|
|
Packit |
6c4009 |
IFUNC_IMPL_ADD (array, i, mempcpy,
|
|
Packit Service |
8dcd58 |
S390_IS_Z10 (stfle_bits), MEMPCPY_Z10)
|
|
Packit Service |
8dcd58 |
# endif
|
|
Packit Service |
8dcd58 |
# if HAVE_MEMCPY_Z900_G5
|
|
Packit Service |
8dcd58 |
IFUNC_IMPL_ADD (array, i, mempcpy, 1, MEMPCPY_Z900_G5)
|
|
Packit Service |
8dcd58 |
# endif
|
|
Packit Service |
8dcd58 |
)
|
|
Packit Service |
8dcd58 |
#endif /* HAVE_MEMCPY_IFUNC */
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
e721db |
#if HAVE_MEMMOVE_IFUNC
|
|
Packit Service |
e721db |
IFUNC_IMPL (i, name, memmove,
|
|
Packit Service |
e721db |
# if HAVE_MEMMOVE_Z13
|
|
Packit Service |
e721db |
IFUNC_IMPL_ADD (array, i, memmove,
|
|
Packit Service |
e721db |
dl_hwcap & HWCAP_S390_VX, MEMMOVE_Z13)
|
|
Packit Service |
e721db |
# endif
|
|
Packit Service |
e721db |
# if HAVE_MEMMOVE_C
|
|
Packit Service |
e721db |
IFUNC_IMPL_ADD (array, i, memmove, 1, MEMMOVE_C)
|
|
Packit Service |
e721db |
# endif
|
|
Packit Service |
e721db |
)
|
|
Packit Service |
e721db |
#endif /* HAVE_MEMMOVE_IFUNC */
|
|
Packit Service |
e721db |
|
|
Packit Service |
c1a30a |
#if HAVE_STRSTR_IFUNC
|
|
Packit Service |
c1a30a |
IFUNC_IMPL (i, name, strstr,
|
|
Packit Service |
c1a30a |
# if HAVE_STRSTR_Z13
|
|
Packit Service |
c1a30a |
IFUNC_IMPL_ADD (array, i, strstr,
|
|
Packit Service |
c1a30a |
dl_hwcap & HWCAP_S390_VX, STRSTR_Z13)
|
|
Packit Service |
c1a30a |
# endif
|
|
Packit Service |
c1a30a |
# if HAVE_STRSTR_C
|
|
Packit Service |
c1a30a |
IFUNC_IMPL_ADD (array, i, strstr, 1, STRSTR_C)
|
|
Packit Service |
c1a30a |
# endif
|
|
Packit Service |
c1a30a |
)
|
|
Packit Service |
c1a30a |
#endif /* HAVE_STRSTR_IFUNC */
|
|
Packit Service |
c1a30a |
|
|
Packit Service |
ae60be |
#if HAVE_MEMMEM_IFUNC
|
|
Packit Service |
ae60be |
IFUNC_IMPL (i, name, memmem,
|
|
Packit Service |
ae60be |
# if HAVE_MEMMEM_Z13
|
|
Packit Service |
ae60be |
IFUNC_IMPL_ADD (array, i, memmem,
|
|
Packit Service |
ae60be |
dl_hwcap & HWCAP_S390_VX, MEMMEM_Z13)
|
|
Packit Service |
ae60be |
# endif
|
|
Packit Service |
ae60be |
# if HAVE_MEMMEM_C
|
|
Packit Service |
ae60be |
IFUNC_IMPL_ADD (array, i, memmem, 1, MEMMEM_C)
|
|
Packit Service |
ae60be |
# endif
|
|
Packit Service |
ae60be |
)
|
|
Packit Service |
ae60be |
#endif /* HAVE_MEMMEM_IFUNC */
|
|
Packit Service |
ae60be |
|
|
Packit Service |
f08bdf |
#if HAVE_STRLEN_IFUNC
|
|
Packit Service |
f08bdf |
IFUNC_IMPL (i, name, strlen,
|
|
Packit Service |
f08bdf |
# if HAVE_STRLEN_Z13
|
|
Packit Service |
f08bdf |
IFUNC_IMPL_ADD (array, i, strlen,
|
|
Packit Service |
f08bdf |
dl_hwcap & HWCAP_S390_VX, STRLEN_Z13)
|
|
Packit Service |
f08bdf |
# endif
|
|
Packit Service |
f08bdf |
# if HAVE_STRLEN_C
|
|
Packit Service |
f08bdf |
IFUNC_IMPL_ADD (array, i, strlen, 1, STRLEN_C)
|
|
Packit Service |
f08bdf |
# endif
|
|
Packit Service |
f08bdf |
)
|
|
Packit Service |
f08bdf |
#endif /* HAVE_STRLEN_IFUNC */
|
|
Packit Service |
f08bdf |
|
|
Packit Service |
0ebf48 |
#if HAVE_STRNLEN_IFUNC
|
|
Packit Service |
0ebf48 |
IFUNC_IMPL (i, name, strnlen,
|
|
Packit Service |
0ebf48 |
# if HAVE_STRNLEN_Z13
|
|
Packit Service |
0ebf48 |
IFUNC_IMPL_ADD (array, i, strnlen,
|
|
Packit Service |
0ebf48 |
dl_hwcap & HWCAP_S390_VX, STRNLEN_Z13)
|
|
Packit Service |
0ebf48 |
# endif
|
|
Packit Service |
0ebf48 |
# if HAVE_STRNLEN_C
|
|
Packit Service |
0ebf48 |
IFUNC_IMPL_ADD (array, i, strnlen, 1, STRNLEN_C)
|
|
Packit Service |
0ebf48 |
# endif
|
|
Packit Service |
0ebf48 |
)
|
|
Packit Service |
0ebf48 |
#endif /* HAVE_STRNLEN_IFUNC */
|
|
Packit Service |
0ebf48 |
|
|
Packit Service |
297929 |
#if HAVE_STRCPY_IFUNC
|
|
Packit Service |
297929 |
IFUNC_IMPL (i, name, strcpy,
|
|
Packit Service |
297929 |
# if HAVE_STRCPY_Z13
|
|
Packit Service |
297929 |
IFUNC_IMPL_ADD (array, i, strcpy,
|
|
Packit Service |
297929 |
dl_hwcap & HWCAP_S390_VX, STRCPY_Z13)
|
|
Packit Service |
297929 |
# endif
|
|
Packit Service |
297929 |
# if HAVE_STRCPY_Z900_G5
|
|
Packit Service |
297929 |
IFUNC_IMPL_ADD (array, i, strcpy, 1, STRCPY_Z900_G5)
|
|
Packit Service |
297929 |
# endif
|
|
Packit Service |
297929 |
)
|
|
Packit Service |
297929 |
#endif /* HAVE_STRCPY_IFUNC */
|
|
Packit Service |
297929 |
|
|
Packit Service |
8bbac7 |
#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
# define IFUNC_VX_IMPL(FUNC) \
|
|
Packit Service |
8bbac7 |
IFUNC_IMPL (i, name, FUNC, \
|
|
Packit Service |
8bbac7 |
IFUNC_IMPL_ADD (array, i, FUNC, dl_hwcap & HWCAP_S390_VX, \
|
|
Packit Service |
8bbac7 |
__##FUNC##_vx) \
|
|
Packit Service |
8bbac7 |
IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c))
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcslen);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcsnlen);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcscpy);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (stpcpy);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcpcpy);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strncpy);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcsncpy);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (stpncpy);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcpncpy);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strcat);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcscat);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strncat);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcsncat);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strcmp);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcscmp);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strncmp);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcsncmp);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strchr);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcschr);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strchrnul);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcschrnul);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strrchr);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcsrchr);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strspn);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcsspn);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strpbrk);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcspbrk);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (strcspn);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wcscspn);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (memchr);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wmemchr);
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (rawmemchr);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (memccpy);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wmemset);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (wmemcmp);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
IFUNC_VX_IMPL (memrchr);
|
|
Packit Service |
8bbac7 |
|
|
Packit Service |
8bbac7 |
#endif /* HAVE_S390_VX_ASM_SUPPORT */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return i;
|
|
Packit |
6c4009 |
}
|