|
|
bdc76f |
commit c62534ae524111eae48b2c2adf3f9a2ca90824f5
|
|
|
bdc76f |
Author: Stefan Liebler <stli@linux.ibm.com>
|
|
|
bdc76f |
Date: Tue Dec 18 13:57:24 2018 +0100
|
|
|
bdc76f |
|
|
|
bdc76f |
S390: Refactor wmemchr ifunc handling.
|
|
|
bdc76f |
|
|
|
bdc76f |
The ifunc handling for wmemchr is adjusted in order to omit ifunc
|
|
|
bdc76f |
if the minimum architecture level already supports newer CPUs by default.
|
|
|
bdc76f |
Unfortunately the c ifunc variant can't be omitted at all as it is used
|
|
|
bdc76f |
by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned.
|
|
|
bdc76f |
Glibc internal calls will use the "newer" ifunc variant.
|
|
|
bdc76f |
|
|
|
bdc76f |
ChangeLog:
|
|
|
bdc76f |
|
|
|
bdc76f |
* sysdeps/s390/multiarch/Makefile
|
|
|
bdc76f |
(sysdep_routines): Remove wmemchr variants.
|
|
|
bdc76f |
* sysdeps/s390/Makefile (sysdep_routines): Add wmemchr variants.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
(__libc_ifunc_impl_list): Refactor ifunc handling for wmemchr.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/wmemchr-c.c: Move to ...
|
|
|
bdc76f |
* sysdeps/s390/wmemchr-c.c: ... here and adjust ifunc handling.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/wmemchr-vx.S: Move to ...
|
|
|
bdc76f |
* sysdeps/s390/wmemchr-vx.S: ... here and adjust ifunc handling.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/wmemchr.c: Move to ...
|
|
|
bdc76f |
* sysdeps/s390/wmemchr.c: ... here and adjust ifunc handling.
|
|
|
bdc76f |
* sysdeps/s390/ifunc-wmemchr.h: New file.
|
|
|
bdc76f |
|
|
|
bdc76f |
diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile
|
|
|
bdc76f |
index da96ac3a36bd7f4e..fdfd1c605c28ddc7 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/Makefile
|
|
|
bdc76f |
+++ b/sysdeps/s390/Makefile
|
|
|
bdc76f |
@@ -75,5 +75,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
|
|
|
bdc76f |
wcsrchr wcsrchr-vx wcsrchr-c \
|
|
|
bdc76f |
wcsspn wcsspn-vx wcsspn-c \
|
|
|
bdc76f |
wcspbrk wcspbrk-vx wcspbrk-c \
|
|
|
bdc76f |
- wcscspn wcscspn-vx wcscspn-c
|
|
|
bdc76f |
+ wcscspn wcscspn-vx wcscspn-c \
|
|
|
bdc76f |
+ wmemchr wmemchr-vx wmemchr-c
|
|
|
bdc76f |
endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/ifunc-wmemchr.h b/sysdeps/s390/ifunc-wmemchr.h
|
|
|
bdc76f |
new file mode 100644
|
|
|
bdc76f |
index 0000000000000000..0610cfb5d4a7fb18
|
|
|
bdc76f |
--- /dev/null
|
|
|
bdc76f |
+++ b/sysdeps/s390/ifunc-wmemchr.h
|
|
|
bdc76f |
@@ -0,0 +1,53 @@
|
|
|
bdc76f |
+/* wmemchr 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_WMEMCHR_IFUNC 1
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define HAVE_WMEMCHR_IFUNC 0
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
|
bdc76f |
+# define HAVE_WMEMCHR_IFUNC_AND_VX_SUPPORT HAVE_WMEMCHR_IFUNC
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define HAVE_WMEMCHR_IFUNC_AND_VX_SUPPORT 0
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
|
|
|
bdc76f |
+# define WMEMCHR_DEFAULT WMEMCHR_Z13
|
|
|
bdc76f |
+/* The z13 ifunc variant is using the common code variant as fallback! */
|
|
|
bdc76f |
+# define HAVE_WMEMCHR_C 1
|
|
|
bdc76f |
+# define HAVE_WMEMCHR_Z13 1
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define WMEMCHR_DEFAULT WMEMCHR_C
|
|
|
bdc76f |
+# define HAVE_WMEMCHR_C 1
|
|
|
bdc76f |
+# define HAVE_WMEMCHR_Z13 HAVE_WMEMCHR_IFUNC_AND_VX_SUPPORT
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_WMEMCHR_C
|
|
|
bdc76f |
+# define WMEMCHR_C __wmemchr_c
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define WMEMCHR_C NULL
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_WMEMCHR_Z13
|
|
|
bdc76f |
+# define WMEMCHR_Z13 __wmemchr_vx
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define WMEMCHR_Z13 NULL
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
|
|
|
bdc76f |
index 5be635542361b355..92e28dc45ddbae37 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/Makefile
|
|
|
bdc76f |
+++ b/sysdeps/s390/multiarch/Makefile
|
|
|
bdc76f |
@@ -1,6 +1,5 @@
|
|
|
bdc76f |
ifeq ($(subdir),wcsmbs)
|
|
|
bdc76f |
-sysdep_routines += wmemchr wmemchr-vx wmemchr-c \
|
|
|
bdc76f |
- wmemset wmemset-vx wmemset-c \
|
|
|
bdc76f |
+sysdep_routines += wmemset wmemset-vx wmemset-c \
|
|
|
bdc76f |
wmemcmp wmemcmp-vx wmemcmp-c
|
|
|
bdc76f |
endif
|
|
|
bdc76f |
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
index 7d8031a069bd23ba..b5f55deb7faae9c4 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
@@ -62,6 +62,7 @@
|
|
|
bdc76f |
#include <ifunc-wcsspn.h>
|
|
|
bdc76f |
#include <ifunc-wcspbrk.h>
|
|
|
bdc76f |
#include <ifunc-wcscspn.h>
|
|
|
bdc76f |
+#include <ifunc-wmemchr.h>
|
|
|
bdc76f |
|
|
|
bdc76f |
/* Maximum number of IFUNC implementations. */
|
|
|
bdc76f |
#define MAX_IFUNC 3
|
|
|
bdc76f |
@@ -632,6 +633,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
bdc76f |
)
|
|
|
bdc76f |
#endif /* HAVE_WCSCSPN_IFUNC */
|
|
|
bdc76f |
|
|
|
bdc76f |
+#if HAVE_WMEMCHR_IFUNC
|
|
|
bdc76f |
+ IFUNC_IMPL (i, name, wmemchr,
|
|
|
bdc76f |
+# if HAVE_WMEMCHR_Z13
|
|
|
bdc76f |
+ IFUNC_IMPL_ADD (array, i, wmemchr,
|
|
|
bdc76f |
+ dl_hwcap & HWCAP_S390_VX, WMEMCHR_Z13)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+# if HAVE_WMEMCHR_C
|
|
|
bdc76f |
+ IFUNC_IMPL_ADD (array, i, wmemchr, 1, WMEMCHR_C)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+ )
|
|
|
bdc76f |
+#endif /* HAVE_WMEMCHR_IFUNC */
|
|
|
bdc76f |
+
|
|
|
bdc76f |
#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
|
bdc76f |
|
|
|
bdc76f |
# define IFUNC_VX_IMPL(FUNC) \
|
|
|
bdc76f |
@@ -640,8 +653,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
bdc76f |
__##FUNC##_vx) \
|
|
|
bdc76f |
IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c))
|
|
|
bdc76f |
|
|
|
bdc76f |
- IFUNC_VX_IMPL (wmemchr);
|
|
|
bdc76f |
-
|
|
|
bdc76f |
IFUNC_VX_IMPL (wmemset);
|
|
|
bdc76f |
|
|
|
bdc76f |
IFUNC_VX_IMPL (wmemcmp);
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/wmemchr-c.c b/sysdeps/s390/wmemchr-c.c
|
|
|
bdc76f |
similarity index 59%
|
|
|
bdc76f |
rename from sysdeps/s390/multiarch/wmemchr-c.c
|
|
|
bdc76f |
rename to sysdeps/s390/wmemchr-c.c
|
|
|
bdc76f |
index 089392b512d29187..bb2526e76c41d0c7 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/wmemchr-c.c
|
|
|
bdc76f |
+++ b/sysdeps/s390/wmemchr-c.c
|
|
|
bdc76f |
@@ -16,22 +16,29 @@
|
|
|
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 WMEMCHR __wmemchr_c
|
|
|
bdc76f |
-
|
|
|
bdc76f |
-# include <wchar.h>
|
|
|
bdc76f |
-extern __typeof (wmemchr) __wmemchr_c;
|
|
|
bdc76f |
-# undef weak_alias
|
|
|
bdc76f |
-# define weak_alias(name, alias)
|
|
|
bdc76f |
-# ifdef SHARED
|
|
|
bdc76f |
-# undef libc_hidden_def
|
|
|
bdc76f |
-# define libc_hidden_def(name) \
|
|
|
bdc76f |
- __hidden_ver1 (__wmemchr_c, __GI___wmemchr, __wmemchr_c);
|
|
|
bdc76f |
-# undef libc_hidden_weak
|
|
|
bdc76f |
-# define libc_hidden_weak(name) \
|
|
|
bdc76f |
+#include <ifunc-wmemchr.h>
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_WMEMCHR_C
|
|
|
bdc76f |
+# if HAVE_WMEMCHR_IFUNC || HAVE_WMEMCHR_Z13
|
|
|
bdc76f |
+# define WMEMCHR WMEMCHR_C
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+# undef weak_alias
|
|
|
bdc76f |
+# define weak_alias(name, alias)
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+# if defined SHARED && IS_IN (libc)
|
|
|
bdc76f |
+# undef libc_hidden_weak
|
|
|
bdc76f |
+# define libc_hidden_weak(name)
|
|
|
bdc76f |
+# undef libc_hidden_def
|
|
|
bdc76f |
+# if ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
|
|
|
bdc76f |
+# define libc_hidden_def(name) \
|
|
|
bdc76f |
+ __hidden_ver1 (__wmemchr_c, __GI_wmemchr, __wmemchr_c) __attribute__((weak)); \
|
|
|
bdc76f |
strong_alias (__wmemchr_c, __wmemchr_c_1); \
|
|
|
bdc76f |
- __hidden_ver1 (__wmemchr_c_1, __GI_wmemchr, __wmemchr_c_1);
|
|
|
bdc76f |
-# endif /* SHARED */
|
|
|
bdc76f |
+ __hidden_ver1 (__wmemchr_c_1, __GI___wmemchr, __wmemchr_c_1);
|
|
|
bdc76f |
+# else
|
|
|
bdc76f |
+# define libc_hidden_def(name)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
|
|
|
bdc76f |
# include <wcsmbs/wmemchr.c>
|
|
|
bdc76f |
-#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/wmemchr-vx.S b/sysdeps/s390/wmemchr-vx.S
|
|
|
bdc76f |
similarity index 92%
|
|
|
bdc76f |
rename from sysdeps/s390/multiarch/wmemchr-vx.S
|
|
|
bdc76f |
rename to sysdeps/s390/wmemchr-vx.S
|
|
|
bdc76f |
index db057b579a7230f0..72e9ef59af77b8f7 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/wmemchr-vx.S
|
|
|
bdc76f |
+++ b/sysdeps/s390/wmemchr-vx.S
|
|
|
bdc76f |
@@ -16,7 +16,8 @@
|
|
|
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-wmemchr.h>
|
|
|
bdc76f |
+#if HAVE_WMEMCHR_Z13
|
|
|
bdc76f |
|
|
|
bdc76f |
# include "sysdep.h"
|
|
|
bdc76f |
# include "asm-syntax.h"
|
|
|
bdc76f |
@@ -38,7 +39,7 @@
|
|
|
bdc76f |
-v17=index of found c
|
|
|
bdc76f |
-v18=c replicated
|
|
|
bdc76f |
*/
|
|
|
bdc76f |
-ENTRY(__wmemchr_vx)
|
|
|
bdc76f |
+ENTRY(WMEMCHR_Z13)
|
|
|
bdc76f |
.machine "z13"
|
|
|
bdc76f |
.machinemode "zarch_nohighgprs"
|
|
|
bdc76f |
|
|
|
bdc76f |
@@ -161,6 +162,17 @@ ENTRY(__wmemchr_vx)
|
|
|
bdc76f |
|
|
|
bdc76f |
j .Llt64
|
|
|
bdc76f |
.Lfallback:
|
|
|
bdc76f |
- jg __wmemchr_c
|
|
|
bdc76f |
-END(__wmemchr_vx)
|
|
|
bdc76f |
-#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */
|
|
|
bdc76f |
+ jg WMEMCHR_C
|
|
|
bdc76f |
+END(WMEMCHR_Z13)
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+# if ! HAVE_WMEMCHR_IFUNC
|
|
|
bdc76f |
+strong_alias (WMEMCHR_Z13, __wmemchr)
|
|
|
bdc76f |
+weak_alias (__wmemchr, wmemchr)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+# if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT \
|
|
|
bdc76f |
+ && defined SHARED && IS_IN (libc)
|
|
|
bdc76f |
+strong_alias (WMEMCHR_Z13, __GI___wmemchr)
|
|
|
bdc76f |
+weak_alias (WMEMCHR_Z13, __GI_wmemchr)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/wmemchr.c b/sysdeps/s390/wmemchr.c
|
|
|
bdc76f |
similarity index 70%
|
|
|
bdc76f |
rename from sysdeps/s390/multiarch/wmemchr.c
|
|
|
bdc76f |
rename to sysdeps/s390/wmemchr.c
|
|
|
bdc76f |
index 6b55c1d7fa10afb9..0d2fbb22c6d65a97 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/wmemchr.c
|
|
|
bdc76f |
+++ b/sysdeps/s390/wmemchr.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-wmemchr.h>
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_WMEMCHR_IFUNC
|
|
|
bdc76f |
# define wmemchr __redirect_wmemchr
|
|
|
bdc76f |
# define __wmemchr __redirect___wmemchr
|
|
|
bdc76f |
# include <wchar.h>
|
|
|
bdc76f |
@@ -24,9 +26,18 @@
|
|
|
bdc76f |
# undef __wmemchr
|
|
|
bdc76f |
# include <ifunc-resolve.h>
|
|
|
bdc76f |
|
|
|
bdc76f |
-s390_vx_libc_ifunc_redirected (__redirect___wmemchr, __wmemchr)
|
|
|
bdc76f |
-weak_alias (__wmemchr, wmemchr)
|
|
|
bdc76f |
+# if HAVE_WMEMCHR_C
|
|
|
bdc76f |
+extern __typeof (__redirect___wmemchr) WMEMCHR_C attribute_hidden;
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
|
|
|
bdc76f |
-#else
|
|
|
bdc76f |
-# include <wcsmbs/wmemchr.c>
|
|
|
bdc76f |
-#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */
|
|
|
bdc76f |
+# if HAVE_WMEMCHR_Z13
|
|
|
bdc76f |
+extern __typeof (__redirect___wmemchr) WMEMCHR_Z13 attribute_hidden;
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+s390_libc_ifunc_expr (__redirect___wmemchr, __wmemchr,
|
|
|
bdc76f |
+ (HAVE_WMEMCHR_Z13 && (hwcap & HWCAP_S390_VX))
|
|
|
bdc76f |
+ ? WMEMCHR_Z13
|
|
|
bdc76f |
+ : WMEMCHR_DEFAULT
|
|
|
bdc76f |
+ )
|
|
|
bdc76f |
+weak_alias (__wmemchr, wmemchr)
|
|
|
bdc76f |
+#endif
|