Blame sysdeps/s390/multiarch/ifunc-impl-list.c

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 051b21
#include <ifunc-memset.h>
Packit Service eb1991
#include <ifunc-memcmp.h>
Packit Service 289aec
#include <ifunc-memcpy.h>
Packit Service f5eb74
#include <ifunc-strstr.h>
Packit Service 857832
#include <ifunc-memmem.h>
Packit Service 7d6e6f
#include <ifunc-strlen.h>
Packit Service 96b00e
#include <ifunc-strnlen.h>
Packit Service afc107
#include <ifunc-strcpy.h>
Packit Service d87820
#include <ifunc-stpcpy.h>
Packit Service 2693da
#include <ifunc-strncpy.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 051b21
#if HAVE_MEMSET_IFUNC
Packit 6c4009
  IFUNC_IMPL (i, name, memset,
Packit Service 051b21
# if HAVE_MEMSET_Z196
Packit 6c4009
	      IFUNC_IMPL_ADD (array, i, memset,
Packit Service 051b21
			      S390_IS_Z196 (stfle_bits), MEMSET_Z196)
Packit Service 051b21
# endif
Packit Service 051b21
# if HAVE_MEMSET_Z10
Packit 6c4009
	      IFUNC_IMPL_ADD (array, i, memset,
Packit Service 051b21
			      S390_IS_Z10 (stfle_bits), MEMSET_Z10)
Packit Service 051b21
# endif
Packit Service 051b21
# if HAVE_MEMSET_Z900_G5
Packit Service 051b21
	      IFUNC_IMPL_ADD (array, i, memset, 1, MEMSET_Z900_G5)
Packit Service 051b21
# endif
Packit Service 051b21
	      )
Packit Service 0d0e7c
Packit Service 0d0e7c
  /* Note: bzero is implemented in memset.  */
Packit Service 0d0e7c
  IFUNC_IMPL (i, name, bzero,
Packit Service 0d0e7c
# if HAVE_MEMSET_Z196
Packit Service 0d0e7c
	      IFUNC_IMPL_ADD (array, i, bzero,
Packit Service 0d0e7c
			      S390_IS_Z196 (stfle_bits), BZERO_Z196)
Packit Service 0d0e7c
# endif
Packit Service 0d0e7c
# if HAVE_MEMSET_Z10
Packit Service 0d0e7c
	      IFUNC_IMPL_ADD (array, i, bzero,
Packit Service 0d0e7c
			      S390_IS_Z10 (stfle_bits), BZERO_Z10)
Packit Service 0d0e7c
# endif
Packit Service 0d0e7c
# if HAVE_MEMSET_Z900_G5
Packit Service 0d0e7c
	      IFUNC_IMPL_ADD (array, i, bzero, 1, BZERO_Z900_G5)
Packit Service 0d0e7c
# endif
Packit Service 0d0e7c
	      )
Packit Service 051b21
#endif /* HAVE_MEMSET_IFUNC */
Packit Service 93dc7a
Packit Service eb1991
#if HAVE_MEMCMP_IFUNC
Packit 6c4009
  IFUNC_IMPL (i, name, memcmp,
Packit Service eb1991
# if HAVE_MEMCMP_Z196
Packit 6c4009
	      IFUNC_IMPL_ADD (array, i, memcmp,
Packit Service eb1991
			      S390_IS_Z196 (stfle_bits), MEMCMP_Z196)
Packit Service eb1991
# endif
Packit Service eb1991
# if HAVE_MEMCMP_Z10
Packit 6c4009
	      IFUNC_IMPL_ADD (array, i, memcmp,
Packit Service eb1991
			      S390_IS_Z10 (stfle_bits), MEMCMP_Z10)
Packit Service eb1991
# endif
Packit Service eb1991
# if HAVE_MEMCMP_Z900_G5
Packit Service eb1991
	      IFUNC_IMPL_ADD (array, i, memcmp, 1, MEMCMP_Z900_G5)
Packit Service eb1991
# endif
Packit Service eb1991
	      )
Packit Service eb1991
#endif /* HAVE_MEMCMP_IFUNC */
Packit Service 93dc7a
Packit Service 289aec
#if HAVE_MEMCPY_IFUNC
Packit 6c4009
  IFUNC_IMPL (i, name, memcpy,
Packit Service 289aec
# if HAVE_MEMCPY_Z196
Packit 6c4009
	      IFUNC_IMPL_ADD (array, i, memcpy,
Packit Service 289aec
			      S390_IS_Z196 (stfle_bits), MEMCPY_Z196)
Packit Service 289aec
# endif
Packit Service 289aec
# if HAVE_MEMCPY_Z10
Packit 6c4009
	      IFUNC_IMPL_ADD (array, i, memcpy,
Packit Service 289aec
			      S390_IS_Z10 (stfle_bits), MEMCPY_Z10)
Packit Service 289aec
# endif
Packit Service 289aec
# if HAVE_MEMCPY_Z900_G5
Packit Service 289aec
	      IFUNC_IMPL_ADD (array, i, memcpy, 1, MEMCPY_Z900_G5)
Packit Service 289aec
# endif
Packit Service 289aec
	      )
Packit 6c4009
Packit 6c4009
  IFUNC_IMPL (i, name, mempcpy,
Packit Service 289aec
# if HAVE_MEMCPY_Z196
Packit 6c4009
	      IFUNC_IMPL_ADD (array, i, mempcpy,
Packit Service 289aec
			      S390_IS_Z196 (stfle_bits), MEMPCPY_Z196)
Packit Service 289aec
# endif
Packit Service 289aec
# if HAVE_MEMCPY_Z10
Packit 6c4009
	      IFUNC_IMPL_ADD (array, i, mempcpy,
Packit Service 289aec
			      S390_IS_Z10 (stfle_bits), MEMPCPY_Z10)
Packit Service 289aec
# endif
Packit Service 289aec
# if HAVE_MEMCPY_Z900_G5
Packit Service 289aec
	      IFUNC_IMPL_ADD (array, i, mempcpy, 1, MEMPCPY_Z900_G5)
Packit Service 289aec
# endif
Packit Service 289aec
	      )
Packit Service 289aec
#endif /* HAVE_MEMCPY_IFUNC  */
Packit Service 93dc7a
Packit Service e16165
#if HAVE_MEMMOVE_IFUNC
Packit Service e16165
    IFUNC_IMPL (i, name, memmove,
Packit Service e16165
# if HAVE_MEMMOVE_Z13
Packit Service e16165
		IFUNC_IMPL_ADD (array, i, memmove,
Packit Service e16165
				dl_hwcap & HWCAP_S390_VX, MEMMOVE_Z13)
Packit Service e16165
# endif
Packit Service e16165
# if HAVE_MEMMOVE_C
Packit Service e16165
		IFUNC_IMPL_ADD (array, i, memmove, 1, MEMMOVE_C)
Packit Service e16165
# endif
Packit Service e16165
		)
Packit Service e16165
#endif /* HAVE_MEMMOVE_IFUNC  */
Packit Service e16165
Packit Service f5eb74
#if HAVE_STRSTR_IFUNC
Packit Service f5eb74
    IFUNC_IMPL (i, name, strstr,
Packit Service f5eb74
# if HAVE_STRSTR_Z13
Packit Service f5eb74
		IFUNC_IMPL_ADD (array, i, strstr,
Packit Service f5eb74
				dl_hwcap & HWCAP_S390_VX, STRSTR_Z13)
Packit Service f5eb74
# endif
Packit Service f5eb74
# if HAVE_STRSTR_C
Packit Service f5eb74
		IFUNC_IMPL_ADD (array, i, strstr, 1, STRSTR_C)
Packit Service f5eb74
# endif
Packit Service f5eb74
		)
Packit Service f5eb74
#endif /* HAVE_STRSTR_IFUNC  */
Packit Service f5eb74
Packit Service 857832
#if HAVE_MEMMEM_IFUNC
Packit Service 857832
    IFUNC_IMPL (i, name, memmem,
Packit Service 857832
# if HAVE_MEMMEM_Z13
Packit Service 857832
		IFUNC_IMPL_ADD (array, i, memmem,
Packit Service 857832
				dl_hwcap & HWCAP_S390_VX, MEMMEM_Z13)
Packit Service 857832
# endif
Packit Service 857832
# if HAVE_MEMMEM_C
Packit Service 857832
		IFUNC_IMPL_ADD (array, i, memmem, 1, MEMMEM_C)
Packit Service 857832
# endif
Packit Service 857832
		)
Packit Service 857832
#endif /* HAVE_MEMMEM_IFUNC  */
Packit Service 857832
Packit Service 7d6e6f
#if HAVE_STRLEN_IFUNC
Packit Service 7d6e6f
    IFUNC_IMPL (i, name, strlen,
Packit Service 7d6e6f
# if HAVE_STRLEN_Z13
Packit Service 7d6e6f
		IFUNC_IMPL_ADD (array, i, strlen,
Packit Service 7d6e6f
				dl_hwcap & HWCAP_S390_VX, STRLEN_Z13)
Packit Service 7d6e6f
# endif
Packit Service 7d6e6f
# if HAVE_STRLEN_C
Packit Service 7d6e6f
		IFUNC_IMPL_ADD (array, i, strlen, 1, STRLEN_C)
Packit Service 7d6e6f
# endif
Packit Service 7d6e6f
		)
Packit Service 7d6e6f
#endif /* HAVE_STRLEN_IFUNC  */
Packit Service 7d6e6f
Packit Service 96b00e
#if HAVE_STRNLEN_IFUNC
Packit Service 96b00e
    IFUNC_IMPL (i, name, strnlen,
Packit Service 96b00e
# if HAVE_STRNLEN_Z13
Packit Service 96b00e
		IFUNC_IMPL_ADD (array, i, strnlen,
Packit Service 96b00e
				dl_hwcap & HWCAP_S390_VX, STRNLEN_Z13)
Packit Service 96b00e
# endif
Packit Service 96b00e
# if HAVE_STRNLEN_C
Packit Service 96b00e
		IFUNC_IMPL_ADD (array, i, strnlen, 1, STRNLEN_C)
Packit Service 96b00e
# endif
Packit Service 96b00e
		)
Packit Service 96b00e
#endif /* HAVE_STRNLEN_IFUNC  */
Packit Service 96b00e
Packit Service afc107
#if HAVE_STRCPY_IFUNC
Packit Service afc107
    IFUNC_IMPL (i, name, strcpy,
Packit Service afc107
# if HAVE_STRCPY_Z13
Packit Service afc107
		IFUNC_IMPL_ADD (array, i, strcpy,
Packit Service afc107
				dl_hwcap & HWCAP_S390_VX, STRCPY_Z13)
Packit Service afc107
# endif
Packit Service afc107
# if HAVE_STRCPY_Z900_G5
Packit Service afc107
		IFUNC_IMPL_ADD (array, i, strcpy, 1, STRCPY_Z900_G5)
Packit Service afc107
# endif
Packit Service afc107
		)
Packit Service afc107
#endif /* HAVE_STRCPY_IFUNC  */
Packit Service afc107
Packit Service d87820
#if HAVE_STPCPY_IFUNC
Packit Service d87820
    IFUNC_IMPL (i, name, stpcpy,
Packit Service d87820
# if HAVE_STPCPY_Z13
Packit Service d87820
		IFUNC_IMPL_ADD (array, i, stpcpy,
Packit Service d87820
				dl_hwcap & HWCAP_S390_VX, STPCPY_Z13)
Packit Service d87820
# endif
Packit Service d87820
# if HAVE_STPCPY_C
Packit Service d87820
		IFUNC_IMPL_ADD (array, i, stpcpy, 1, STPCPY_C)
Packit Service d87820
# endif
Packit Service d87820
		)
Packit Service d87820
#endif /* HAVE_STPCPY_IFUNC  */
Packit Service d87820
Packit Service 2693da
#if HAVE_STRNCPY_IFUNC
Packit Service 2693da
    IFUNC_IMPL (i, name, strncpy,
Packit Service 2693da
# if HAVE_STRNCPY_Z13
Packit Service 2693da
		IFUNC_IMPL_ADD (array, i, strncpy,
Packit Service 2693da
				dl_hwcap & HWCAP_S390_VX, STRNCPY_Z13)
Packit Service 2693da
# endif
Packit Service 2693da
# if HAVE_STRNCPY_Z900_G5
Packit Service 2693da
		IFUNC_IMPL_ADD (array, i, strncpy, 1, STRNCPY_Z900_G5)
Packit Service 2693da
# endif
Packit Service 2693da
		)
Packit Service 2693da
#endif /* HAVE_STRNCPY_IFUNC  */
Packit Service 2693da
Packit Service 2693da
Packit Service 93dc7a
#ifdef HAVE_S390_VX_ASM_SUPPORT
Packit Service 93dc7a
Packit Service 93dc7a
# define IFUNC_VX_IMPL(FUNC)						\
Packit Service 93dc7a
  IFUNC_IMPL (i, name, FUNC,						\
Packit Service 93dc7a
	      IFUNC_IMPL_ADD (array, i, FUNC, dl_hwcap & HWCAP_S390_VX, \
Packit Service 93dc7a
			      __##FUNC##_vx)				\
Packit Service 93dc7a
	      IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c))
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcslen);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcsnlen);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcscpy);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcpcpy);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcsncpy);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (stpncpy);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcpncpy);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strcat);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcscat);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strncat);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcsncat);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strcmp);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcscmp);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strncmp);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcsncmp);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strchr);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcschr);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strchrnul);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcschrnul);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strrchr);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcsrchr);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strspn);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcsspn);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strpbrk);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcspbrk);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (strcspn);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wcscspn);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (memchr);
Packit Service 93dc7a
  IFUNC_VX_IMPL (wmemchr);
Packit Service 93dc7a
  IFUNC_VX_IMPL (rawmemchr);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (memccpy);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (wmemset);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (wmemcmp);
Packit Service 93dc7a
Packit Service 93dc7a
  IFUNC_VX_IMPL (memrchr);
Packit Service 93dc7a
Packit Service 93dc7a
#endif /* HAVE_S390_VX_ASM_SUPPORT */
Packit 6c4009
Packit 6c4009
  return i;
Packit 6c4009
}