|
|
bdc76f |
commit c7e7cd266ed123b6dfb722f599934ca5dcfd3e93
|
|
|
bdc76f |
Author: Stefan Liebler <stli@linux.ibm.com>
|
|
|
bdc76f |
Date: Tue Dec 18 13:57:18 2018 +0100
|
|
|
bdc76f |
|
|
|
bdc76f |
S390: Refactor wcsnlen ifunc handling.
|
|
|
bdc76f |
|
|
|
bdc76f |
The ifunc handling for wcsnlen 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 wcsnlen variants.
|
|
|
bdc76f |
* sysdeps/s390/Makefile (sysdep_routines): Add wcsnlen variants.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
(__libc_ifunc_impl_list): Refactor ifunc handling for wcsnlen.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/wcsnlen-c.c: Move to ...
|
|
|
bdc76f |
* sysdeps/s390/wcsnlen-c.c: ... here and adjust ifunc handling.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/wcsnlen-vx.S: Move to ...
|
|
|
bdc76f |
* sysdeps/s390/wcsnlen-vx.S: ... here and adjust ifunc handling.
|
|
|
bdc76f |
* sysdeps/s390/multiarch/wcsnlen.c: Move to ...
|
|
|
bdc76f |
* sysdeps/s390/wcsnlen.c: ... here and adjust ifunc handling.
|
|
|
bdc76f |
* sysdeps/s390/ifunc-wcsnlen.h: New file.
|
|
|
bdc76f |
|
|
|
bdc76f |
diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile
|
|
|
bdc76f |
index 65e89118936bb668..f5983815479a76da 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/Makefile
|
|
|
bdc76f |
+++ b/sysdeps/s390/Makefile
|
|
|
bdc76f |
@@ -60,5 +60,6 @@ sysdep_routines += bzero memset memset-z900 \
|
|
|
bdc76f |
endif
|
|
|
bdc76f |
|
|
|
bdc76f |
ifeq ($(subdir),wcsmbs)
|
|
|
bdc76f |
-sysdep_routines += wcslen wcslen-vx wcslen-c
|
|
|
bdc76f |
+sysdep_routines += wcslen wcslen-vx wcslen-c \
|
|
|
bdc76f |
+ wcsnlen wcsnlen-vx wcsnlen-c
|
|
|
bdc76f |
endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/ifunc-wcsnlen.h b/sysdeps/s390/ifunc-wcsnlen.h
|
|
|
bdc76f |
new file mode 100644
|
|
|
bdc76f |
index 0000000000000000..b5b21da2f17d9cd9
|
|
|
bdc76f |
--- /dev/null
|
|
|
bdc76f |
+++ b/sysdeps/s390/ifunc-wcsnlen.h
|
|
|
bdc76f |
@@ -0,0 +1,53 @@
|
|
|
bdc76f |
+/* wcsnlen 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_WCSNLEN_IFUNC 1
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define HAVE_WCSNLEN_IFUNC 0
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
|
bdc76f |
+# define HAVE_WCSNLEN_IFUNC_AND_VX_SUPPORT HAVE_WCSNLEN_IFUNC
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define HAVE_WCSNLEN_IFUNC_AND_VX_SUPPORT 0
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
|
|
|
bdc76f |
+# define WCSNLEN_DEFAULT WCSNLEN_Z13
|
|
|
bdc76f |
+/* The z13 ifunc variant is using the common code variant as fallback! */
|
|
|
bdc76f |
+# define HAVE_WCSNLEN_C 1
|
|
|
bdc76f |
+# define HAVE_WCSNLEN_Z13 1
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define WCSNLEN_DEFAULT WCSNLEN_C
|
|
|
bdc76f |
+# define HAVE_WCSNLEN_C 1
|
|
|
bdc76f |
+# define HAVE_WCSNLEN_Z13 HAVE_WCSNLEN_IFUNC_AND_VX_SUPPORT
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_WCSNLEN_C
|
|
|
bdc76f |
+# define WCSNLEN_C __wcsnlen_c
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define WCSNLEN_C NULL
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_WCSNLEN_Z13
|
|
|
bdc76f |
+# define WCSNLEN_Z13 __wcsnlen_vx
|
|
|
bdc76f |
+#else
|
|
|
bdc76f |
+# define WCSNLEN_Z13 NULL
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
|
|
|
bdc76f |
index 421d40d020b81560..ce2e7ce5f4eef0fa 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 += wcsnlen wcsnlen-vx wcsnlen-c \
|
|
|
bdc76f |
- wcscpy wcscpy-vx wcscpy-c \
|
|
|
bdc76f |
+sysdep_routines += wcscpy wcscpy-vx wcscpy-c \
|
|
|
bdc76f |
wcpcpy wcpcpy-vx wcpcpy-c \
|
|
|
bdc76f |
wcsncpy wcsncpy-vx wcsncpy-c \
|
|
|
bdc76f |
wcpncpy wcpncpy-vx wcpncpy-c \
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
index 7bf5f14c015b54fe..c199fd0e0b43e4b4 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bdc76f |
@@ -47,6 +47,7 @@
|
|
|
bdc76f |
#include <ifunc-memccpy.h>
|
|
|
bdc76f |
#include <ifunc-memrchr.h>
|
|
|
bdc76f |
#include <ifunc-wcslen.h>
|
|
|
bdc76f |
+#include <ifunc-wcsnlen.h>
|
|
|
bdc76f |
|
|
|
bdc76f |
/* Maximum number of IFUNC implementations. */
|
|
|
bdc76f |
#define MAX_IFUNC 3
|
|
|
bdc76f |
@@ -437,6 +438,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
bdc76f |
)
|
|
|
bdc76f |
#endif /* HAVE_WCSLEN_IFUNC */
|
|
|
bdc76f |
|
|
|
bdc76f |
+#if HAVE_WCSNLEN_IFUNC
|
|
|
bdc76f |
+ IFUNC_IMPL (i, name, wcsnlen,
|
|
|
bdc76f |
+# if HAVE_WCSNLEN_Z13
|
|
|
bdc76f |
+ IFUNC_IMPL_ADD (array, i, wcsnlen,
|
|
|
bdc76f |
+ dl_hwcap & HWCAP_S390_VX, WCSNLEN_Z13)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+# if HAVE_WCSNLEN_C
|
|
|
bdc76f |
+ IFUNC_IMPL_ADD (array, i, wcsnlen, 1, WCSNLEN_C)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+ )
|
|
|
bdc76f |
+#endif /* HAVE_WCSNLEN_IFUNC */
|
|
|
bdc76f |
+
|
|
|
bdc76f |
#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
|
bdc76f |
|
|
|
bdc76f |
# define IFUNC_VX_IMPL(FUNC) \
|
|
|
bdc76f |
@@ -445,8 +458,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 (wcsnlen);
|
|
|
bdc76f |
-
|
|
|
bdc76f |
IFUNC_VX_IMPL (wcscpy);
|
|
|
bdc76f |
|
|
|
bdc76f |
IFUNC_VX_IMPL (wcpcpy);
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/wcsnlen-c.c b/sysdeps/s390/wcsnlen-c.c
|
|
|
bdc76f |
similarity index 85%
|
|
|
bdc76f |
rename from sysdeps/s390/multiarch/wcsnlen-c.c
|
|
|
bdc76f |
rename to sysdeps/s390/wcsnlen-c.c
|
|
|
bdc76f |
index 8f43f5104f2eab3f..7495a6f97cfeca62 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/wcsnlen-c.c
|
|
|
bdc76f |
+++ b/sysdeps/s390/wcsnlen-c.c
|
|
|
bdc76f |
@@ -16,10 +16,12 @@
|
|
|
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 WCSNLEN __wcsnlen_c
|
|
|
bdc76f |
+#include <ifunc-wcsnlen.h>
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_WCSNLEN_C
|
|
|
bdc76f |
+# if HAVE_WCSNLEN_IFUNC || HAVE_WCSNLEN_Z13
|
|
|
bdc76f |
+# define WCSNLEN WCSNLEN_C
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
|
|
|
bdc76f |
-# include <wchar.h>
|
|
|
bdc76f |
-extern __typeof (__wcsnlen) __wcsnlen_c;
|
|
|
bdc76f |
# include <wcsmbs/wcsnlen.c>
|
|
|
bdc76f |
#endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/wcsnlen-vx.S b/sysdeps/s390/wcsnlen-vx.S
|
|
|
bdc76f |
similarity index 95%
|
|
|
bdc76f |
rename from sysdeps/s390/multiarch/wcsnlen-vx.S
|
|
|
bdc76f |
rename to sysdeps/s390/wcsnlen-vx.S
|
|
|
bdc76f |
index 420f29fbc0d2965a..47f4ca82840538d9 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/wcsnlen-vx.S
|
|
|
bdc76f |
+++ b/sysdeps/s390/wcsnlen-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-wcsnlen.h>
|
|
|
bdc76f |
+#if HAVE_WCSNLEN_Z13
|
|
|
bdc76f |
|
|
|
bdc76f |
# include "sysdep.h"
|
|
|
bdc76f |
# include "asm-syntax.h"
|
|
|
bdc76f |
@@ -34,7 +35,7 @@
|
|
|
bdc76f |
-r5=current_len and return_value
|
|
|
bdc76f |
-v16=part of s
|
|
|
bdc76f |
*/
|
|
|
bdc76f |
-ENTRY(__wcsnlen_vx)
|
|
|
bdc76f |
+ENTRY(WCSNLEN_Z13)
|
|
|
bdc76f |
|
|
|
bdc76f |
.machine "z13"
|
|
|
bdc76f |
.machinemode "zarch_nohighgprs"
|
|
|
bdc76f |
@@ -146,6 +147,11 @@ ENTRY(__wcsnlen_vx)
|
|
|
bdc76f |
j .Llt64
|
|
|
bdc76f |
|
|
|
bdc76f |
.Lfallback:
|
|
|
bdc76f |
- jg __wcsnlen_c
|
|
|
bdc76f |
-END(__wcsnlen_vx)
|
|
|
bdc76f |
-#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */
|
|
|
bdc76f |
+ jg WCSNLEN_C
|
|
|
bdc76f |
+END(WCSNLEN_Z13)
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+# if ! HAVE_WCSNLEN_IFUNC
|
|
|
bdc76f |
+strong_alias (WCSNLEN_Z13, __wcsnlen)
|
|
|
bdc76f |
+weak_alias (__wcsnlen, wcsnlen)
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+#endif
|
|
|
bdc76f |
diff --git a/sysdeps/s390/multiarch/wcsnlen.c b/sysdeps/s390/wcsnlen.c
|
|
|
bdc76f |
similarity index 70%
|
|
|
bdc76f |
rename from sysdeps/s390/multiarch/wcsnlen.c
|
|
|
bdc76f |
rename to sysdeps/s390/wcsnlen.c
|
|
|
bdc76f |
index 5234074b1fce8ca1..b5c8ad9fde5a9752 100644
|
|
|
bdc76f |
--- a/sysdeps/s390/multiarch/wcsnlen.c
|
|
|
bdc76f |
+++ b/sysdeps/s390/wcsnlen.c
|
|
|
bdc76f |
@@ -16,13 +16,24 @@
|
|
|
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-wcsnlen.h>
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+#if HAVE_WCSNLEN_IFUNC
|
|
|
bdc76f |
# include <wchar.h>
|
|
|
bdc76f |
# include <ifunc-resolve.h>
|
|
|
bdc76f |
|
|
|
bdc76f |
-s390_vx_libc_ifunc (__wcsnlen)
|
|
|
bdc76f |
-weak_alias (__wcsnlen, wcsnlen)
|
|
|
bdc76f |
+# if HAVE_WCSNLEN_C
|
|
|
bdc76f |
+extern __typeof (__wcsnlen) WCSNLEN_C attribute_hidden;
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
|
|
|
bdc76f |
-#else
|
|
|
bdc76f |
-# include <wcsmbs/wcsnlen.c>
|
|
|
bdc76f |
-#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */
|
|
|
bdc76f |
+# if HAVE_WCSNLEN_Z13
|
|
|
bdc76f |
+extern __typeof (__wcsnlen) WCSNLEN_Z13 attribute_hidden;
|
|
|
bdc76f |
+# endif
|
|
|
bdc76f |
+
|
|
|
bdc76f |
+s390_libc_ifunc_expr (__wcsnlen, __wcsnlen,
|
|
|
bdc76f |
+ (HAVE_WCSNLEN_Z13 && (hwcap & HWCAP_S390_VX))
|
|
|
bdc76f |
+ ? WCSNLEN_Z13
|
|
|
bdc76f |
+ : WCSNLEN_DEFAULT
|
|
|
bdc76f |
+ )
|
|
|
bdc76f |
+weak_alias (__wcsnlen, wcsnlen)
|
|
|
bdc76f |
+#endif
|