|
|
bdc76f |
commit 32f12653d4ea2fbff409351bf8067f9a0b4a3963
|
|
|
bdc76f |
Author: Stefan Liebler <stli@linux.ibm.com>
|
|
|
bdc76f |
Date: Tue Dec 18 13:57:14 2018 +0100
|
|
|
bdc76f |
|
|
|
bdc76f |
S390: Refactor strchr ifunc handling.
|
|
|
bdc76f |
|
|
|
bdc76f |
The ifunc handling for strchr is adjusted in order to omit ifunc
|
|
|
bdc76f |
variants if those will never be used as the minimum architecture level
|
|
|
bdc76f |
already supports newer CPUs by default.
|
|
|
bdc76f |
Glibc internal calls will then also use the "newer" ifunc variant.
|
|
|
bdc76f |
|
|
|
bdc76f |
ChangeLog:
|
|
|
bdc76f |
|
|
|
bdc76f |
* sysdeps/s390/multiarch/Makefile
|
|
|
bdc76f |
(sysdep_routines): Remove strchr variants.
|
|
|
bdc76f |
* sysdeps/s390/Makefile (sysdep_routines): Add strchr variants.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
(__libc_ifunc_impl_list): Refactor ifunc handling for strchr.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/strchr-c.c: Move to ...
|
|
|
bdc76f |
* sysdeps/s390/strchr-c.c: ... here and adjust ifunc handling.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/strchr-vx.S: Move to ...
|
|
|
bdc76f |
* sysdeps/s390/strchr-vx.S: ... here and adjust ifunc handling.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/strchr.c: Move to ...
|
|
|
bdc76f |
* sysdeps/s390/strchr.c: ... here and adjust ifunc handling.
|
|
|
bdc76f |
* sysdeps/s390/ifunc-strchr.h: New file.
|
|
|
bdc76f |
|
|
|
bdc76f |
diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile
|
|
|
bdc76f |
index adf3521876725ac8..8bb396f498e0b0b0 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/Makefile
|
|
|
bdc76f |
+++ b/sysdeps/s390/Makefile
|
|
|
bdc76f |
@@ -46,5 +46,6 @@ sysdep_routines += bzero memset memset-z900 \
|
|
|
bdc76f |
strcat strcat-vx strcat-c \
|
|
|
bdc76f |
strncat strncat-vx strncat-c \
|
|
|
bdc76f |
strcmp strcmp-vx strcmp-z900 \
|
|
|
bdc76f |
- strncmp strncmp-vx strncmp-c
|
|
|
bdc76f |
+ strncmp strncmp-vx strncmp-c \
|
|
|
bdc76f |
+ strchr strchr-vx strchr-c
|
|
|
bdc76f |
endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/ifunc-strchr.h b/sysdeps/s390/ifunc-strchr.h
|
|
|
bdc76f |
new file mode 100644
|
|
|
bdc76f |
index 0000000000000000..cfeb00eeda890512
|
|
|
bdc76f |
--- /dev/null
|
|
|
bdc76f |
+++ b/sysdeps/s390/ifunc-strchr.h
|
|
|
bdc76f |
@@ -0,0 +1,52 @@
|
|
|
bdc76f |
+/* strchr variant information on S/390 version.
|
|
|
bdc76f |
+ Copyright (C) 2018 Free Software Foundation, Inc.
|
|
|
bdc76f |
+ This file is part of the GNU C Library.
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
bdc76f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
bdc76f |
+ License as published by the Free Software Foundation; either
|
|
|
bdc76f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
bdc76f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
bdc76f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
bdc76f |
+ Lesser General Public License for more details.
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
bdc76f |
+ License along with the GNU C Library; if not, see
|
|
|
bdc76f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if defined USE_MULTIARCH && IS_IN (libc) \
|
|
|
bdc76f |
+ && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
|
|
|
bdc76f |
+# define HAVE_STRCHR_IFUNC 1
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define HAVE_STRCHR_IFUNC 0
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
|
bdc76f |
+# define HAVE_STRCHR_IFUNC_AND_VX_SUPPORT HAVE_STRCHR_IFUNC
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define HAVE_STRCHR_IFUNC_AND_VX_SUPPORT 0
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
|
|
|
bdc76f |
+# define STRCHR_DEFAULT STRCHR_Z13
|
|
|
bdc76f |
+# define HAVE_STRCHR_C 0
|
|
|
bdc76f |
+# define HAVE_STRCHR_Z13 1
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define STRCHR_DEFAULT STRCHR_C
|
|
|
bdc76f |
+# define HAVE_STRCHR_C 1
|
|
|
bdc76f |
+# define HAVE_STRCHR_Z13 HAVE_STRCHR_IFUNC_AND_VX_SUPPORT
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_STRCHR_C
|
|
|
bdc76f |
+# define STRCHR_C __strchr_c
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define STRCHR_C NULL
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_STRCHR_Z13
|
|
|
bdc76f |
+# define STRCHR_Z13 __strchr_vx
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define STRCHR_Z13 NULL
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
|
|
|
bdc76f |
index 381376bf9fcb0f58..a8e9d0acd9ebf986 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/Makefile
|
|
|
bdc76f |
+++ b/sysdeps/s390/multiarch/Makefile
|
|
|
bdc76f |
@@ -1,6 +1,5 @@
|
|
|
bdc76f |
ifeq ($(subdir),string)
|
|
|
bdc76f |
-sysdep_routines += strchr strchr-vx strchr-c \
|
|
|
bdc76f |
- strchrnul strchrnul-vx strchrnul-c \
|
|
|
bdc76f |
+sysdep_routines += strchrnul strchrnul-vx strchrnul-c \
|
|
|
bdc76f |
strrchr strrchr-vx strrchr-c \
|
|
|
bdc76f |
strspn strspn-vx strspn-c \
|
|
|
bdc76f |
strpbrk strpbrk-vx strpbrk-c \
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
index d982de5788c0b5d5..e809ca3bacb18aa9 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
@@ -36,6 +36,7 @@
|
|
|
bdc76f |
#include <ifunc-strncat.h>
|
|
|
bdc76f |
#include <ifunc-strcmp.h>
|
|
|
bdc76f |
#include <ifunc-strncmp.h>
|
|
|
bdc76f |
+#include <ifunc-strchr.h>
|
|
|
bdc76f |
|
|
|
bdc76f |
/* Maximum number of IFUNC implementations. */
|
|
|
bdc76f |
#define MAX_IFUNC 3
|
|
|
bdc76f |
@@ -294,6 +295,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
bdc76f |
)
|
|
|
bdc76f |
#endif /* HAVE_STRNCMP_IFUNC */
|
|
|
bdc76f |
|
|
|
bdc76f |
+#if HAVE_STRCHR_IFUNC
|
|
|
bdc76f |
+ IFUNC_IMPL (i, name, strchr,
|
|
|
bdc76f |
+# if HAVE_STRCHR_Z13
|
|
|
bdc76f |
+ IFUNC_IMPL_ADD (array, i, strchr,
|
|
|
bdc76f |
+ dl_hwcap & HWCAP_S390_VX, STRCHR_Z13)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+# if HAVE_STRCHR_C
|
|
|
bdc76f |
+ IFUNC_IMPL_ADD (array, i, strchr, 1, STRCHR_C)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+ )
|
|
|
bdc76f |
+#endif /* HAVE_STRCHR_IFUNC */
|
|
|
bdc76f |
+
|
|
|
bdc76f |
#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
|
bdc76f |
|
|
|
bdc76f |
# define IFUNC_VX_IMPL(FUNC) \
|
|
|
bdc76f |
@@ -322,7 +335,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
bdc76f |
|
|
|
bdc76f |
IFUNC_VX_IMPL (wcsncmp);
|
|
|
bdc76f |
|
|
|
bdc76f |
- IFUNC_VX_IMPL (strchr);
|
|
|
bdc76f |
IFUNC_VX_IMPL (wcschr);
|
|
|
bdc76f |
|
|
|
bdc76f |
IFUNC_VX_IMPL (strchrnul);
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/strchr-c.c b/sysdeps/s390/strchr-c.c
|
|
|
bdc76f |
similarity index 77%
|
|
|
bdc76f |
rename from sysdeps/s390/multiarch/strchr-c.c
|
|
|
bdc76f |
rename to sysdeps/s390/strchr-c.c
|
|
|
bdc76f |
index 606cb56788966153..3d3579a1d3bc06d0 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/strchr-c.c
|
|
|
bdc76f |
+++ b/sysdeps/s390/strchr-c.c
|
|
|
bdc76f |
@@ -16,14 +16,18 @@
|
|
|
bdc76f |
License along with the GNU C Library; if not, see
|
|
|
bdc76f |
<http://www.gnu.org/licenses/>. */
|
|
|
bdc76f |
|
|
|
bdc76f |
-#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
|
|
|
bdc76f |
-# define STRCHR __strchr_c
|
|
|
bdc76f |
-# undef weak_alias
|
|
|
bdc76f |
-# ifdef SHARED
|
|
|
bdc76f |
-# undef libc_hidden_builtin_def
|
|
|
bdc76f |
-# define libc_hidden_builtin_def(name) \
|
|
|
bdc76f |
+#include <ifunc-strchr.h>
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_STRCHR_C
|
|
|
bdc76f |
+# if HAVE_STRCHR_IFUNC
|
|
|
bdc76f |
+# define STRCHR STRCHR_C
|
|
|
bdc76f |
+# undef weak_alias
|
|
|
bdc76f |
+# if defined SHARED && IS_IN (libc)
|
|
|
bdc76f |
+# undef libc_hidden_builtin_def
|
|
|
bdc76f |
+# define libc_hidden_builtin_def(name) \
|
|
|
bdc76f |
__hidden_ver1 (__strchr_c, __GI_strchr, __strchr_c);
|
|
|
bdc76f |
-# endif /* SHARED */
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
|
|
|
bdc76f |
# include <string/strchr.c>
|
|
|
bdc76f |
-#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/strchr-vx.S b/sysdeps/s390/strchr-vx.S
|
|
|
bdc76f |
similarity index 90%
|
|
|
bdc76f |
rename from sysdeps/s390/multiarch/strchr-vx.S
|
|
|
bdc76f |
rename to sysdeps/s390/strchr-vx.S
|
|
|
bdc76f |
index 6e744fb82f3249a6..6ffa06f78c14c8da 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/strchr-vx.S
|
|
|
bdc76f |
+++ b/sysdeps/s390/strchr-vx.S
|
|
|
bdc76f |
@@ -16,7 +16,9 @@
|
|
|
bdc76f |
License along with the GNU C Library; if not, see
|
|
|
bdc76f |
<http://www.gnu.org/licenses/>. */
|
|
|
bdc76f |
|
|
|
bdc76f |
-#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
|
|
|
bdc76f |
+#include <ifunc-strchr.h>
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_STRCHR_Z13
|
|
|
bdc76f |
|
|
|
bdc76f |
# include "sysdep.h"
|
|
|
bdc76f |
# include "asm-syntax.h"
|
|
|
bdc76f |
@@ -36,7 +38,7 @@
|
|
|
bdc76f |
-v17=index of unequal
|
|
|
bdc76f |
-v18=replicated c
|
|
|
bdc76f |
*/
|
|
|
bdc76f |
-ENTRY(__strchr_vx)
|
|
|
bdc76f |
+ENTRY(STRCHR_Z13)
|
|
|
bdc76f |
.machine "z13"
|
|
|
bdc76f |
.machinemode "zarch_nohighgprs"
|
|
|
bdc76f |
|
|
|
bdc76f |
@@ -96,5 +98,15 @@ ENTRY(__strchr_vx)
|
|
|
bdc76f |
clije %r3,0,.Lcharacter /* Found zero and c is zero. */
|
|
|
bdc76f |
lghi %r2,0 /* Return null if character not found. */
|
|
|
bdc76f |
br %r14
|
|
|
bdc76f |
-END(__strchr_vx)
|
|
|
bdc76f |
-#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */
|
|
|
bdc76f |
+END(STRCHR_Z13)
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+# if ! HAVE_STRCHR_IFUNC
|
|
|
bdc76f |
+strong_alias (STRCHR_Z13, strchr)
|
|
|
bdc76f |
+weak_alias (strchr, index)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+# if ! HAVE_STRCHR_C && defined SHARED && IS_IN (libc)
|
|
|
bdc76f |
+strong_alias (STRCHR_Z13, __GI_strchr)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#endif /* HAVE_STRCHR_Z13 */
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/strchr.c b/sysdeps/s390/strchr.c
|
|
|
bdc76f |
similarity index 71%
|
|
|
bdc76f |
rename from sysdeps/s390/multiarch/strchr.c
|
|
|
bdc76f |
rename to sysdeps/s390/strchr.c
|
|
|
bdc76f |
index 8aa33a51cc7e91de..a106c6106dcd5307 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/strchr.c
|
|
|
bdc76f |
+++ b/sysdeps/s390/strchr.c
|
|
|
bdc76f |
@@ -16,7 +16,9 @@
|
|
|
bdc76f |
License along with the GNU C Library; if not, see
|
|
|
bdc76f |
<http://www.gnu.org/licenses/>. */
|
|
|
bdc76f |
|
|
|
bdc76f |
-#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
|
|
|
bdc76f |
+#include <ifunc-strchr.h>
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_STRCHR_IFUNC
|
|
|
bdc76f |
# define strchr __redirect_strchr
|
|
|
bdc76f |
/* Omit the strchr inline definitions because it would redefine strchr. */
|
|
|
bdc76f |
# define __NO_STRING_INLINES
|
|
|
bdc76f |
@@ -24,9 +26,18 @@
|
|
|
bdc76f |
# undef strchr
|
|
|
bdc76f |
# include <ifunc-resolve.h>
|
|
|
bdc76f |
|
|
|
bdc76f |
-s390_vx_libc_ifunc2_redirected (__redirect_strchr, __strchr, strchr)
|
|
|
bdc76f |
-weak_alias (strchr, index)
|
|
|
bdc76f |
+# if HAVE_STRCHR_C
|
|
|
bdc76f |
+extern __typeof (__redirect_strchr) STRCHR_C attribute_hidden;
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
|
|
|
bdc76f |
-#else
|
|
|
bdc76f |
-# include <string/strchr.c>
|
|
|
bdc76f |
-#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */
|
|
|
bdc76f |
+# if HAVE_STRCHR_Z13
|
|
|
bdc76f |
+extern __typeof (__redirect_strchr) STRCHR_Z13 attribute_hidden;
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+s390_libc_ifunc_expr (__redirect_strchr, strchr,
|
|
|
bdc76f |
+ (HAVE_STRCHR_Z13 && (hwcap & HWCAP_S390_VX))
|
|
|
bdc76f |
+ ? STRCHR_Z13
|
|
|
bdc76f |
+ : STRCHR_DEFAULT
|
|
|
bdc76f |
+ )
|
|
|
bdc76f |
+weak_alias (strchr, index)
|
|
|
bdc76f |
+#endif /* HAVE_STRCHR_IFUNC */
|