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

Packit Service 82fcde
/* Enumerate available IFUNC implementations of a function. s390/s390x version.
Packit Service 82fcde
   Copyright (C) 2015-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#include <assert.h>
Packit Service 82fcde
#include <string.h>
Packit Service 82fcde
#include <wchar.h>
Packit Service 82fcde
#include <ifunc-impl-list.h>
Packit Service 82fcde
#include <ifunc-resolve.h>
Packit Service 88e0ef
#include <ifunc-memset.h>
Packit Service 72cf12
#include <ifunc-memcmp.h>
Packit Service a245ad
#include <ifunc-memcpy.h>
Packit Service eac944
#include <ifunc-strstr.h>
Packit Service 03e699
#include <ifunc-memmem.h>
Packit Service 720eed
#include <ifunc-strlen.h>
Packit Service a28822
#include <ifunc-strnlen.h>
Packit Service b9339e
#include <ifunc-strcpy.h>
Packit Service cbaa14
#include <ifunc-stpcpy.h>
Packit Service 143dd1
#include <ifunc-strncpy.h>
Packit Service 3fb31a
#include <ifunc-stpncpy.h>
Packit Service db853b
#include <ifunc-strcat.h>
Packit Service c41a74
#include <ifunc-strncat.h>
Packit Service 82fcde
Packit Service 82fcde
/* Maximum number of IFUNC implementations.  */
Packit Service 82fcde
#define MAX_IFUNC	3
Packit Service 82fcde
Packit Service 82fcde
/* Fill ARRAY of MAX elements with IFUNC implementations for function
Packit Service 82fcde
   NAME supported on target machine and return the number of valid
Packit Service 82fcde
   entries.  */
Packit Service 82fcde
size_t
Packit Service 82fcde
__libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
Packit Service 82fcde
			size_t max)
Packit Service 82fcde
{
Packit Service 82fcde
  assert (max >= MAX_IFUNC);
Packit Service 82fcde
Packit Service 82fcde
  size_t i = 0;
Packit Service 82fcde
Packit Service 82fcde
  /* Get hardware information.  */
Packit Service 82fcde
  unsigned long int dl_hwcap = GLRO (dl_hwcap);
Packit Service 82fcde
  unsigned long long stfle_bits = 0ULL;
Packit Service 82fcde
  if ((dl_hwcap & HWCAP_S390_STFLE)
Packit Service 82fcde
	&& (dl_hwcap & HWCAP_S390_ZARCH)
Packit Service 82fcde
	&& (dl_hwcap & HWCAP_S390_HIGH_GPRS))
Packit Service 82fcde
    {
Packit Service 82fcde
      S390_STORE_STFLE (stfle_bits);
Packit Service 82fcde
    }
Packit Service 82fcde
Packit Service 88e0ef
#if HAVE_MEMSET_IFUNC
Packit Service 82fcde
  IFUNC_IMPL (i, name, memset,
Packit Service 88e0ef
# if HAVE_MEMSET_Z196
Packit Service 82fcde
	      IFUNC_IMPL_ADD (array, i, memset,
Packit Service 88e0ef
			      S390_IS_Z196 (stfle_bits), MEMSET_Z196)
Packit Service 88e0ef
# endif
Packit Service 88e0ef
# if HAVE_MEMSET_Z10
Packit Service 82fcde
	      IFUNC_IMPL_ADD (array, i, memset,
Packit Service 88e0ef
			      S390_IS_Z10 (stfle_bits), MEMSET_Z10)
Packit Service 88e0ef
# endif
Packit Service 88e0ef
# if HAVE_MEMSET_Z900_G5
Packit Service 88e0ef
	      IFUNC_IMPL_ADD (array, i, memset, 1, MEMSET_Z900_G5)
Packit Service 88e0ef
# endif
Packit Service 88e0ef
	      )
Packit Service 878e1f
Packit Service 878e1f
  /* Note: bzero is implemented in memset.  */
Packit Service 878e1f
  IFUNC_IMPL (i, name, bzero,
Packit Service 878e1f
# if HAVE_MEMSET_Z196
Packit Service 878e1f
	      IFUNC_IMPL_ADD (array, i, bzero,
Packit Service 878e1f
			      S390_IS_Z196 (stfle_bits), BZERO_Z196)
Packit Service 878e1f
# endif
Packit Service 878e1f
# if HAVE_MEMSET_Z10
Packit Service 878e1f
	      IFUNC_IMPL_ADD (array, i, bzero,
Packit Service 878e1f
			      S390_IS_Z10 (stfle_bits), BZERO_Z10)
Packit Service 878e1f
# endif
Packit Service 878e1f
# if HAVE_MEMSET_Z900_G5
Packit Service 878e1f
	      IFUNC_IMPL_ADD (array, i, bzero, 1, BZERO_Z900_G5)
Packit Service 878e1f
# endif
Packit Service 878e1f
	      )
Packit Service 88e0ef
#endif /* HAVE_MEMSET_IFUNC */
Packit Service 1c5418
Packit Service 72cf12
#if HAVE_MEMCMP_IFUNC
Packit Service 82fcde
  IFUNC_IMPL (i, name, memcmp,
Packit Service 72cf12
# if HAVE_MEMCMP_Z196
Packit Service 82fcde
	      IFUNC_IMPL_ADD (array, i, memcmp,
Packit Service 72cf12
			      S390_IS_Z196 (stfle_bits), MEMCMP_Z196)
Packit Service 72cf12
# endif
Packit Service 72cf12
# if HAVE_MEMCMP_Z10
Packit Service 82fcde
	      IFUNC_IMPL_ADD (array, i, memcmp,
Packit Service 72cf12
			      S390_IS_Z10 (stfle_bits), MEMCMP_Z10)
Packit Service 72cf12
# endif
Packit Service 72cf12
# if HAVE_MEMCMP_Z900_G5
Packit Service 72cf12
	      IFUNC_IMPL_ADD (array, i, memcmp, 1, MEMCMP_Z900_G5)
Packit Service 72cf12
# endif
Packit Service 72cf12
	      )
Packit Service 72cf12
#endif /* HAVE_MEMCMP_IFUNC */
Packit Service 1c5418
Packit Service a245ad
#if HAVE_MEMCPY_IFUNC
Packit Service 82fcde
  IFUNC_IMPL (i, name, memcpy,
Packit Service a245ad
# if HAVE_MEMCPY_Z196
Packit Service 82fcde
	      IFUNC_IMPL_ADD (array, i, memcpy,
Packit Service a245ad
			      S390_IS_Z196 (stfle_bits), MEMCPY_Z196)
Packit Service a245ad
# endif
Packit Service a245ad
# if HAVE_MEMCPY_Z10
Packit Service 82fcde
	      IFUNC_IMPL_ADD (array, i, memcpy,
Packit Service a245ad
			      S390_IS_Z10 (stfle_bits), MEMCPY_Z10)
Packit Service a245ad
# endif
Packit Service a245ad
# if HAVE_MEMCPY_Z900_G5
Packit Service a245ad
	      IFUNC_IMPL_ADD (array, i, memcpy, 1, MEMCPY_Z900_G5)
Packit Service a245ad
# endif
Packit Service a245ad
	      )
Packit Service 82fcde
Packit Service 82fcde
  IFUNC_IMPL (i, name, mempcpy,
Packit Service a245ad
# if HAVE_MEMCPY_Z196
Packit Service 82fcde
	      IFUNC_IMPL_ADD (array, i, mempcpy,
Packit Service a245ad
			      S390_IS_Z196 (stfle_bits), MEMPCPY_Z196)
Packit Service a245ad
# endif
Packit Service a245ad
# if HAVE_MEMCPY_Z10
Packit Service 82fcde
	      IFUNC_IMPL_ADD (array, i, mempcpy,
Packit Service a245ad
			      S390_IS_Z10 (stfle_bits), MEMPCPY_Z10)
Packit Service a245ad
# endif
Packit Service a245ad
# if HAVE_MEMCPY_Z900_G5
Packit Service a245ad
	      IFUNC_IMPL_ADD (array, i, mempcpy, 1, MEMPCPY_Z900_G5)
Packit Service a245ad
# endif
Packit Service a245ad
	      )
Packit Service a245ad
#endif /* HAVE_MEMCPY_IFUNC  */
Packit Service 1c5418
Packit Service 470baf
#if HAVE_MEMMOVE_IFUNC
Packit Service 470baf
    IFUNC_IMPL (i, name, memmove,
Packit Service 470baf
# if HAVE_MEMMOVE_Z13
Packit Service 470baf
		IFUNC_IMPL_ADD (array, i, memmove,
Packit Service 470baf
				dl_hwcap & HWCAP_S390_VX, MEMMOVE_Z13)
Packit Service 470baf
# endif
Packit Service 470baf
# if HAVE_MEMMOVE_C
Packit Service 470baf
		IFUNC_IMPL_ADD (array, i, memmove, 1, MEMMOVE_C)
Packit Service 470baf
# endif
Packit Service 470baf
		)
Packit Service 470baf
#endif /* HAVE_MEMMOVE_IFUNC  */
Packit Service 470baf
Packit Service eac944
#if HAVE_STRSTR_IFUNC
Packit Service eac944
    IFUNC_IMPL (i, name, strstr,
Packit Service eac944
# if HAVE_STRSTR_Z13
Packit Service eac944
		IFUNC_IMPL_ADD (array, i, strstr,
Packit Service eac944
				dl_hwcap & HWCAP_S390_VX, STRSTR_Z13)
Packit Service eac944
# endif
Packit Service eac944
# if HAVE_STRSTR_C
Packit Service eac944
		IFUNC_IMPL_ADD (array, i, strstr, 1, STRSTR_C)
Packit Service eac944
# endif
Packit Service eac944
		)
Packit Service eac944
#endif /* HAVE_STRSTR_IFUNC  */
Packit Service eac944
Packit Service 03e699
#if HAVE_MEMMEM_IFUNC
Packit Service 03e699
    IFUNC_IMPL (i, name, memmem,
Packit Service 03e699
# if HAVE_MEMMEM_Z13
Packit Service 03e699
		IFUNC_IMPL_ADD (array, i, memmem,
Packit Service 03e699
				dl_hwcap & HWCAP_S390_VX, MEMMEM_Z13)
Packit Service 03e699
# endif
Packit Service 03e699
# if HAVE_MEMMEM_C
Packit Service 03e699
		IFUNC_IMPL_ADD (array, i, memmem, 1, MEMMEM_C)
Packit Service 03e699
# endif
Packit Service 03e699
		)
Packit Service 03e699
#endif /* HAVE_MEMMEM_IFUNC  */
Packit Service 03e699
Packit Service 720eed
#if HAVE_STRLEN_IFUNC
Packit Service 720eed
    IFUNC_IMPL (i, name, strlen,
Packit Service 720eed
# if HAVE_STRLEN_Z13
Packit Service 720eed
		IFUNC_IMPL_ADD (array, i, strlen,
Packit Service 720eed
				dl_hwcap & HWCAP_S390_VX, STRLEN_Z13)
Packit Service 720eed
# endif
Packit Service 720eed
# if HAVE_STRLEN_C
Packit Service 720eed
		IFUNC_IMPL_ADD (array, i, strlen, 1, STRLEN_C)
Packit Service 720eed
# endif
Packit Service 720eed
		)
Packit Service 720eed
#endif /* HAVE_STRLEN_IFUNC  */
Packit Service 720eed
Packit Service a28822
#if HAVE_STRNLEN_IFUNC
Packit Service a28822
    IFUNC_IMPL (i, name, strnlen,
Packit Service a28822
# if HAVE_STRNLEN_Z13
Packit Service a28822
		IFUNC_IMPL_ADD (array, i, strnlen,
Packit Service a28822
				dl_hwcap & HWCAP_S390_VX, STRNLEN_Z13)
Packit Service a28822
# endif
Packit Service a28822
# if HAVE_STRNLEN_C
Packit Service a28822
		IFUNC_IMPL_ADD (array, i, strnlen, 1, STRNLEN_C)
Packit Service a28822
# endif
Packit Service a28822
		)
Packit Service a28822
#endif /* HAVE_STRNLEN_IFUNC  */
Packit Service a28822
Packit Service b9339e
#if HAVE_STRCPY_IFUNC
Packit Service b9339e
    IFUNC_IMPL (i, name, strcpy,
Packit Service b9339e
# if HAVE_STRCPY_Z13
Packit Service b9339e
		IFUNC_IMPL_ADD (array, i, strcpy,
Packit Service b9339e
				dl_hwcap & HWCAP_S390_VX, STRCPY_Z13)
Packit Service b9339e
# endif
Packit Service b9339e
# if HAVE_STRCPY_Z900_G5
Packit Service b9339e
		IFUNC_IMPL_ADD (array, i, strcpy, 1, STRCPY_Z900_G5)
Packit Service b9339e
# endif
Packit Service b9339e
		)
Packit Service b9339e
#endif /* HAVE_STRCPY_IFUNC  */
Packit Service b9339e
Packit Service cbaa14
#if HAVE_STPCPY_IFUNC
Packit Service cbaa14
    IFUNC_IMPL (i, name, stpcpy,
Packit Service cbaa14
# if HAVE_STPCPY_Z13
Packit Service cbaa14
		IFUNC_IMPL_ADD (array, i, stpcpy,
Packit Service cbaa14
				dl_hwcap & HWCAP_S390_VX, STPCPY_Z13)
Packit Service cbaa14
# endif
Packit Service cbaa14
# if HAVE_STPCPY_C
Packit Service cbaa14
		IFUNC_IMPL_ADD (array, i, stpcpy, 1, STPCPY_C)
Packit Service cbaa14
# endif
Packit Service cbaa14
		)
Packit Service cbaa14
#endif /* HAVE_STPCPY_IFUNC  */
Packit Service cbaa14
Packit Service 143dd1
#if HAVE_STRNCPY_IFUNC
Packit Service 143dd1
    IFUNC_IMPL (i, name, strncpy,
Packit Service 143dd1
# if HAVE_STRNCPY_Z13
Packit Service 143dd1
		IFUNC_IMPL_ADD (array, i, strncpy,
Packit Service 143dd1
				dl_hwcap & HWCAP_S390_VX, STRNCPY_Z13)
Packit Service 143dd1
# endif
Packit Service 143dd1
# if HAVE_STRNCPY_Z900_G5
Packit Service 143dd1
		IFUNC_IMPL_ADD (array, i, strncpy, 1, STRNCPY_Z900_G5)
Packit Service 143dd1
# endif
Packit Service 143dd1
		)
Packit Service 143dd1
#endif /* HAVE_STRNCPY_IFUNC  */
Packit Service 143dd1
Packit Service 3fb31a
#if HAVE_STPNCPY_IFUNC
Packit Service 3fb31a
    IFUNC_IMPL (i, name, stpncpy,
Packit Service 3fb31a
# if HAVE_STPNCPY_Z13
Packit Service 3fb31a
		IFUNC_IMPL_ADD (array, i, stpncpy,
Packit Service 3fb31a
				dl_hwcap & HWCAP_S390_VX, STPNCPY_Z13)
Packit Service 3fb31a
# endif
Packit Service 3fb31a
# if HAVE_STPNCPY_C
Packit Service 3fb31a
		IFUNC_IMPL_ADD (array, i, stpncpy, 1, STPNCPY_C)
Packit Service 3fb31a
# endif
Packit Service 3fb31a
		)
Packit Service 3fb31a
#endif /* HAVE_STPNCPY_IFUNC  */
Packit Service 3fb31a
Packit Service db853b
#if HAVE_STRCAT_IFUNC
Packit Service db853b
    IFUNC_IMPL (i, name, strcat,
Packit Service db853b
# if HAVE_STRCAT_Z13
Packit Service db853b
		IFUNC_IMPL_ADD (array, i, strcat,
Packit Service db853b
				dl_hwcap & HWCAP_S390_VX, STRCAT_Z13)
Packit Service db853b
# endif
Packit Service db853b
# if HAVE_STRCAT_C
Packit Service db853b
		IFUNC_IMPL_ADD (array, i, strcat, 1, STRCAT_C)
Packit Service db853b
# endif
Packit Service db853b
		)
Packit Service db853b
#endif /* HAVE_STRCAT_IFUNC  */
Packit Service 143dd1
Packit Service c41a74
#if HAVE_STRNCAT_IFUNC
Packit Service c41a74
    IFUNC_IMPL (i, name, strncat,
Packit Service c41a74
# if HAVE_STRNCAT_Z13
Packit Service c41a74
		IFUNC_IMPL_ADD (array, i, strncat,
Packit Service c41a74
				dl_hwcap & HWCAP_S390_VX, STRNCAT_Z13)
Packit Service c41a74
# endif
Packit Service c41a74
# if HAVE_STRNCAT_C
Packit Service c41a74
		IFUNC_IMPL_ADD (array, i, strncat, 1, STRNCAT_C)
Packit Service c41a74
# endif
Packit Service c41a74
		)
Packit Service c41a74
#endif /* HAVE_STRNCAT_IFUNC  */
Packit Service c41a74
Packit Service 1c5418
#ifdef HAVE_S390_VX_ASM_SUPPORT
Packit Service 1c5418
Packit Service 1c5418
# define IFUNC_VX_IMPL(FUNC)						\
Packit Service 1c5418
  IFUNC_IMPL (i, name, FUNC,						\
Packit Service 1c5418
	      IFUNC_IMPL_ADD (array, i, FUNC, dl_hwcap & HWCAP_S390_VX, \
Packit Service 1c5418
			      __##FUNC##_vx)				\
Packit Service 1c5418
	      IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c))
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wcslen);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wcsnlen);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wcscpy);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wcpcpy);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wcsncpy);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wcpncpy);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wcscat);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wcsncat);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (strcmp);
Packit Service 1c5418
  IFUNC_VX_IMPL (wcscmp);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (strncmp);
Packit Service 1c5418
  IFUNC_VX_IMPL (wcsncmp);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (strchr);
Packit Service 1c5418
  IFUNC_VX_IMPL (wcschr);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (strchrnul);
Packit Service 1c5418
  IFUNC_VX_IMPL (wcschrnul);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (strrchr);
Packit Service 1c5418
  IFUNC_VX_IMPL (wcsrchr);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (strspn);
Packit Service 1c5418
  IFUNC_VX_IMPL (wcsspn);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (strpbrk);
Packit Service 1c5418
  IFUNC_VX_IMPL (wcspbrk);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (strcspn);
Packit Service 1c5418
  IFUNC_VX_IMPL (wcscspn);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (memchr);
Packit Service 1c5418
  IFUNC_VX_IMPL (wmemchr);
Packit Service 1c5418
  IFUNC_VX_IMPL (rawmemchr);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (memccpy);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wmemset);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (wmemcmp);
Packit Service 1c5418
Packit Service 1c5418
  IFUNC_VX_IMPL (memrchr);
Packit Service 1c5418
Packit Service 1c5418
#endif /* HAVE_S390_VX_ASM_SUPPORT */
Packit Service 82fcde
Packit Service 82fcde
  return i;
Packit Service 82fcde
}