@@ -40,53 +40,46 @@
".machine pop" "\n" \
: "=QS" (STFLE_BITS), "+d" (reg0) \
: : "cc");
+#define s390_libc_ifunc_init() \
+ unsigned long long stfle_bits = 0ULL; \
+ if (__glibc_likely((dl_hwcap & HWCAP_S390_STFLE) \
+ && (dl_hwcap & HWCAP_S390_ZARCH) \
+ && (dl_hwcap & HWCAP_S390_HIGH_GPRS))) \
+ { \
+ S390_STORE_STFLE (stfle_bits); \
+ }
-#define s390_libc_ifunc(FUNC) \
- __asm__ (".globl " #FUNC "\n\t" \
- ".type " #FUNC ",@gnu_indirect_function\n\t" \
- ".set " #FUNC ",__resolve_" #FUNC "\n\t"); \
- \
+#define s390_libc_ifunc(TYPE_FUNC, RESOLVERFUNC, FUNC) \
/* Make the declarations of the optimized functions hidden in order
to prevent GOT slots being generated for them. */ \
- extern void *__##FUNC##_z196 attribute_hidden; \
- extern void *__##FUNC##_z10 attribute_hidden; \
- extern void *__##FUNC##_default attribute_hidden; \
- \
- void *__resolve_##FUNC (unsigned long int dl_hwcap) \
- { \
- if ((dl_hwcap & HWCAP_S390_STFLE) \
- && (dl_hwcap & HWCAP_S390_ZARCH) \
- && (dl_hwcap & HWCAP_S390_HIGH_GPRS)) \
- { \
- unsigned long long stfle_bits; \
- S390_STORE_STFLE (stfle_bits); \
- \
- if (S390_IS_Z196 (stfle_bits)) \
- return &__##FUNC##_z196; \
- else if (S390_IS_Z10 (stfle_bits)) \
- return &__##FUNC##_z10; \
- else \
- return &__##FUNC##_default; \
- } \
- else \
- return &__##FUNC##_default; \
- }
+ extern __typeof (TYPE_FUNC) RESOLVERFUNC##_z196 attribute_hidden; \
+ extern __typeof (TYPE_FUNC) RESOLVERFUNC##_z10 attribute_hidden; \
+ extern __typeof (TYPE_FUNC) RESOLVERFUNC##_default attribute_hidden; \
+ __ifunc (TYPE_FUNC, FUNC, \
+ __glibc_likely (S390_IS_Z196 (stfle_bits)) \
+ ? RESOLVERFUNC##_z196 \
+ : __glibc_likely (S390_IS_Z10 (stfle_bits)) \
+ ? RESOLVERFUNC##_z10 \
+ : RESOLVERFUNC##_default, \
+ unsigned long int dl_hwcap, s390_libc_ifunc_init);
#define s390_vx_libc_ifunc(FUNC) \
- s390_vx_libc_ifunc2(FUNC, FUNC)
+ s390_vx_libc_ifunc2_redirected(FUNC, FUNC, FUNC)
-#define s390_vx_libc_ifunc2(RESOLVERFUNC, FUNC) \
+#define s390_vx_libc_ifunc_redirected(TYPE_FUNC, FUNC) \
+ s390_vx_libc_ifunc2_redirected(TYPE_FUNC, FUNC, FUNC)
+
+#define s390_vx_libc_ifunc2(RESOLVERFUNC, FUNC) \
+ s390_vx_libc_ifunc2_redirected(FUNC, RESOLVERFUNC, FUNC)
+
+#define s390_vx_libc_ifunc_init()
+#define s390_vx_libc_ifunc2_redirected(TYPE_FUNC, RESOLVERFUNC, FUNC) \
/* Make the declarations of the optimized functions hidden in order
to prevent GOT slots being generated for them. */ \
- extern __typeof (FUNC) RESOLVERFUNC##_vx attribute_hidden; \
- extern __typeof (FUNC) RESOLVERFUNC##_c attribute_hidden; \
- extern void *__resolve_##RESOLVERFUNC (unsigned long int) __asm__ (#FUNC); \
- \
- void *__resolve_##RESOLVERFUNC (unsigned long int dl_hwcap) \
- { \
- if (dl_hwcap & HWCAP_S390_VX) \
- return &RESOLVERFUNC##_vx; \
- else \
- return &RESOLVERFUNC##_c; \
- } \
- __asm__ (".type " #FUNC ", %gnu_indirect_function");
+ extern __typeof (TYPE_FUNC) RESOLVERFUNC##_vx attribute_hidden; \
+ extern __typeof (TYPE_FUNC) RESOLVERFUNC##_c attribute_hidden; \
+ __ifunc (TYPE_FUNC, FUNC, \
+ (dl_hwcap & HWCAP_S390_VX) \
+ ? RESOLVERFUNC##_vx \
+ : RESOLVERFUNC##_c, \
+ unsigned long int dl_hwcap, s390_vx_libc_ifunc_init);
@@ -17,8 +17,11 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define memchr __redirect_memchr
# include <string.h>
+# undef memchr
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__memchr, memchr)
+s390_vx_libc_ifunc2_redirected (__redirect_memchr, __memchr, memchr)
+
#endif
@@ -18,9 +18,15 @@
#if defined SHARED && IS_IN (libc)
+# define mempcpy __redirect_mempcpy
+# define __mempcpy __redirect___mempcpy
+/* Omit the mempcpy inline definitions because it would redefine mempcpy. */
+# define _HAVE_STRING_ARCH_mempcpy 1
+# include <string.h>
+# undef mempcpy
+# undef __mempcpy
# include <ifunc-resolve.h>
-s390_libc_ifunc (__mempcpy)
-__asm__ (".weak mempcpy\n\t"
- ".set mempcpy,__mempcpy\n\t");
+s390_libc_ifunc (__redirect___mempcpy, ____mempcpy, __mempcpy)
+weak_alias (__mempcpy, mempcpy);
#endif
@@ -17,10 +17,13 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define __rawmemchr __redirect___rawmemchr
# include <string.h>
+# undef __rawmemchr
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc (__rawmemchr)
+s390_vx_libc_ifunc2_redirected (__redirect___rawmemchr, __rawmemchr
+ , __rawmemchr)
weak_alias (__rawmemchr, rawmemchr)
#else
@@ -17,13 +17,18 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define stpcpy __redirect_stpcpy
+# define __stpcpy __redirect___stpcpy
+/* Omit the stpcpy inline definitions because it would redefine stpcpy. */
+# define __NO_STRING_INLINES
# define NO_MEMPCPY_STPCPY_REDIRECT
# include <string.h>
+# undef stpcpy
+# undef __stpcpy
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc (__stpcpy)
+s390_vx_libc_ifunc_redirected (__redirect___stpcpy, __stpcpy);
weak_alias (__stpcpy, stpcpy)
-libc_hidden_builtin_def (stpcpy)
#else
# include <string/stpcpy.c>
@@ -17,10 +17,14 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define stpncpy __redirect_stpncpy
+# define __stpncpy __redirect___stpncpy
# include <string.h>
+# undef stpncpy
+# undef __stpncpy
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc (__stpncpy)
+s390_vx_libc_ifunc_redirected (__redirect___stpncpy, __stpncpy)
weak_alias (__stpncpy, stpncpy)
#else
@@ -17,10 +17,12 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strcat __redirect_strcat
# include <string.h>
+# undef strcat
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__strcat, strcat)
+s390_vx_libc_ifunc2_redirected (__redirect_strcat, __strcat, strcat)
#else
# include <string/strcat.c>
@@ -17,10 +17,14 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strchr __redirect_strchr
+/* Omit the strchr inline definitions because it would redefine strchr. */
+# define __NO_STRING_INLINES
# include <string.h>
+# undef strchr
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__strchr, strchr)
+s390_vx_libc_ifunc2_redirected (__redirect_strchr, __strchr, strchr)
weak_alias (strchr, index)
#else
@@ -17,10 +17,13 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strcmp __redirect_strcmp
+/* Omit the strcmp inline definitions because it would redefine strcmp. */
+# define __NO_STRING_INLINES
# include <string.h>
# include <ifunc-resolve.h>
+# undef strcmp
+s390_vx_libc_ifunc2_redirected (__redirect_strcmp, __strcmp, strcmp)
-# undef strcmp
-s390_vx_libc_ifunc2 (__strcmp, strcmp)
#endif
@@ -17,8 +17,11 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strcpy __redirect_strcpy
# include <string.h>
+# undef strcpy
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__strcpy, strcpy)
+s390_vx_libc_ifunc2_redirected (__redirect_strcpy, __strcpy, strcpy)
+
#endif
@@ -17,10 +17,14 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strcspn __redirect_strcspn
+/* Omit the strcspn inline definitions because it would redefine strcspn. */
+# define __NO_STRING_INLINES
# include <string.h>
+# undef strcspn
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__strcspn, strcspn)
+s390_vx_libc_ifunc2_redirected (__redirect_strcspn, __strcspn, strcspn)
#else
# include <string/strcspn.c>
@@ -17,10 +17,12 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strlen __redirect_strlen
# include <string.h>
# include <ifunc-resolve.h>
+# undef strlen
-s390_vx_libc_ifunc2 (__strlen, strlen)
+s390_vx_libc_ifunc2_redirected (__redirect_strlen, __strlen, strlen)
#else
# include <string/strlen.c>
@@ -17,13 +17,14 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strncmp __redirect_strncmp
+/* Omit the strncmp inline definitions because it would redefine strncmp. */
+# define __NO_STRING_INLINES
# include <string.h>
+# undef strncmp
# include <ifunc-resolve.h>
-
-# undef strcmp
-extern __typeof (strncmp) __strncmp;
-s390_vx_libc_ifunc2 (__strncmp, strncmp)
+s390_vx_libc_ifunc2_redirected (__redirect_strncmp, __strncmp, strncmp)
#else
# include <string/strncmp.c>
@@ -17,8 +17,13 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strncpy __redirect_strncpy
+/* Omit the strncpy inline definitions because it would redefine strncpy. */
+# define __NO_STRING_INLINES
# include <string.h>
+# undef strncpy
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__strncpy, strncpy)
+s390_vx_libc_ifunc2_redirected (__redirect_strncpy, __strncpy, strncpy);
+
#endif
@@ -17,12 +17,15 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strnlen __redirect_strnlen
+# define __strnlen __redirect___strnlen
# include <string.h>
+# undef strnlen
+# undef __strnlen
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc (__strnlen)
+s390_vx_libc_ifunc_redirected (__redirect___strnlen, __strnlen)
weak_alias (__strnlen, strnlen)
-libc_hidden_def (strnlen)
#else
# include <string/strnlen.c>
@@ -17,10 +17,14 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strpbrk __redirect_strpbrk
+/* Omit the strpbrk inline definitions because it would redefine strpbrk. */
+# define __NO_STRING_INLINES
# include <string.h>
+# undef strpbrk
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__strpbrk, strpbrk)
+s390_vx_libc_ifunc2_redirected (__redirect_strpbrk, __strpbrk, strpbrk)
#else
# include <string/strpbrk.c>
@@ -17,11 +17,13 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strrchr __redirect_strrchr
# include <string.h>
+# undef strrchr
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__strrchr, strrchr)
-weak_alias (strrchr, rindex)
+s390_vx_libc_ifunc2_redirected (__redirect_strrchr, __strrchr, strrchr)
+weak_alias (strrchr, rindex);
#else
# include <string/strrchr.c>
@@ -17,10 +17,14 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define strspn __redirect_strspn
+/* Omit the strspn inline definitions because it would redefine strspn. */
+# define __NO_STRING_INLINES
# include <string.h>
+# undef strspn
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__strspn, strspn)
+s390_vx_libc_ifunc2_redirected (__redirect_strspn, __strspn, strspn)
#else
# include <string/strspn.c>
@@ -17,12 +17,15 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define wcschr __redirect_wcschr
+# define __wcschr __redirect___wcschr
# include <wchar.h>
+# undef wcschr
+# undef __wcschr
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc (__wcschr)
+s390_vx_libc_ifunc_redirected (__redirect___wcschr, __wcschr)
weak_alias (__wcschr, wcschr)
-libc_hidden_weak (wcschr)
#else
# include <wcsmbs/wcschr.c>
@@ -17,10 +17,12 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define __wcscmp __redirect___wcscmp
# include <wchar.h>
+# undef __wcscmp
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc (__wcscmp)
+s390_vx_libc_ifunc_redirected (__redirect___wcscmp, __wcscmp)
weak_alias (__wcscmp, wcscmp)
#else
@@ -17,10 +17,12 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define wcspbrk __redirect_wcspbrk
# include <wchar.h>
+# undef wcspbrk
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__wcspbrk, wcspbrk)
+s390_vx_libc_ifunc2_redirected (__redirect_wcspbrk, __wcspbrk, wcspbrk)
#else
# include <wcsmbs/wcspbrk.c>
@@ -17,10 +17,12 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define wcsspn __redirect_wcsspn
# include <wchar.h>
+# undef wcsspn
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc2 (__wcsspn, wcsspn)
+s390_vx_libc_ifunc2_redirected (__redirect_wcsspn, __wcsspn, wcsspn)
#else
# include <wcsmbs/wcsspn.c>
@@ -17,12 +17,15 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define wmemchr __redirect_wmemchr
+# define __wmemchr __redirect___wmemchr
# include <wchar.h>
+# undef wmemchr
+# undef __wmemchr
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc (__wmemchr)
+s390_vx_libc_ifunc_redirected (__redirect___wmemchr, __wmemchr)
weak_alias (__wmemchr, wmemchr)
-libc_hidden_weak (wmemchr)
#else
# include <wcsmbs/wmemchr.c>
@@ -17,12 +17,15 @@
<http://www.gnu.org/licenses/>. */
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
+# define wmemset __redirect_wmemset
+# define __wmemset __redirect___wmemset
# include <wchar.h>
+# undef wmemset
+# undef __wmemset
# include <ifunc-resolve.h>
-s390_vx_libc_ifunc (__wmemset)
+s390_vx_libc_ifunc_redirected (__redirect___wmemset, __wmemset)
weak_alias (__wmemset, wmemset)
-libc_hidden_weak (wmemset)
#else
# include <wcsmbs/wmemset.c>
@@ -17,8 +17,11 @@
<http://www.gnu.org/licenses/>. */
#if IS_IN (libc)
+# define memcmp __redirect_memcmp
+# include <string.h>
+# undef memcmp
# include <ifunc-resolve.h>
-s390_libc_ifunc (memcmp)
-__asm__(".weak bcmp ; bcmp = memcmp");
+s390_libc_ifunc (__redirect_memcmp, __memcmp, memcmp)
+weak_alias (memcmp, bcmp);
#endif
@@ -18,7 +18,10 @@
/* In the static lib memcpy is needed before the reloc is resolved. */
#if defined SHARED && IS_IN (libc)
+# define memcpy __redirect_memcpy
+# include <string.h>
+# undef memcpy
# include <ifunc-resolve.h>
-s390_libc_ifunc (memcpy)
+s390_libc_ifunc (__redirect_memcpy, __memcpy, memcpy)
#endif
@@ -17,7 +17,10 @@
<http://www.gnu.org/licenses/>. */
#if IS_IN (libc)
+# define memset __redirect_memset
+# include <string.h>
+# undef memset
# include <ifunc-resolve.h>
-s390_libc_ifunc (memset)
+s390_libc_ifunc (__redirect_memset, __memset, memset)
#endif
@@ -17,8 +17,11 @@
<http://www.gnu.org/licenses/>. */
#if IS_IN (libc)
+# define memcmp __redirect_memcmp
+# include <string.h>
+# undef memcmp
# include <ifunc-resolve.h>
-s390_libc_ifunc (memcmp)
-__asm__(".weak bcmp ; bcmp = memcmp");
+s390_libc_ifunc (__redirect_memcmp, __memcmp, memcmp)
+weak_alias (memcmp, bcmp);
#endif
@@ -18,7 +18,10 @@
/* In the static lib memcpy is needed before the reloc is resolved. */
#if defined SHARED && IS_IN (libc)
+# define memcpy __redirect_memcpy
+# include <string.h>
+# undef memcpy
# include <ifunc-resolve.h>
-s390_libc_ifunc (memcpy)
+s390_libc_ifunc (__redirect_memcpy, __memcpy, memcpy)
#endif
@@ -17,7 +17,10 @@
<http://www.gnu.org/licenses/>. */
#if IS_IN (libc)
+# define memset __redirect_memset
+# include <string.h>
+# undef memset
# include <ifunc-resolve.h>
-s390_libc_ifunc (memset)
+s390_libc_ifunc (__redirect_memset, __memset, memset)
#endif