aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-02-05 17:35:12 -0200
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-02-27 10:00:37 -0300
commit81a14439417552324ec6ca71f65ddf8e7cdd51c7 (patch)
tree3300f5fec6acc1ef4c95c333bf165ebb51248f68 /sysdeps
parent39ef07441910c2d2f8c02579e808862194b9a23b (diff)
downloadglibc-81a14439417552324ec6ca71f65ddf8e7cdd51c7.tar
glibc-81a14439417552324ec6ca71f65ddf8e7cdd51c7.tar.gz
glibc-81a14439417552324ec6ca71f65ddf8e7cdd51c7.tar.bz2
glibc-81a14439417552324ec6ca71f65ddf8e7cdd51c7.zip
wcsmbs: optimize wcscat
This patch rewrites wcscat using wcslen and wcscpy. This is similar to the optimization done on strcat by 6e46de42fe. The strcpy changes are mainly to add the internal alias to avoid PLT calls. Checked on x86_64-linux-gnu and a build against the affected architectures. * include/wchar.h (__wcscpy): New prototype. * sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c (__wcscpy): Route internal symbol to generic implementation. * sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c (wcscpy): Add internal __wcscpy alias. * sysdeps/powerpc/powerpc64/multiarch/wcscpy.c (wcscpy): Likewise. * sysdeps/s390/wcscpy.c (wcscpy): Likewise. * sysdeps/x86_64/multiarch/wcscpy.c (wcscpy): Likewise. * wcsmbs/wcscpy.c (wcscpy): Add * sysdeps/x86_64/multiarch/wcscpy-c.c (WCSCPY): Adjust macro to use generic implementation. * wcsmbs/wcscat.c (wcscat): Rewrite using wcslen and wcscpy.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c9
-rw-r--r--sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c24
-rw-r--r--sysdeps/powerpc/powerpc64/multiarch/wcscpy.c25
-rw-r--r--sysdeps/s390/wcscpy.c4
-rw-r--r--sysdeps/x86_64/multiarch/wcscpy-c.c4
-rw-r--r--sysdeps/x86_64/multiarch/wcscpy.c11
6 files changed, 42 insertions, 35 deletions
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
index 52b692b47b..31e0d81ef0 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
@@ -17,10 +17,11 @@
#include <wchar.h>
-#if IS_IN (libc)
-# define WCSCPY __wcscpy_ppc
-#endif
-
extern __typeof (wcscpy) __wcscpy_ppc;
+#define WCSCPY __wcscpy_ppc
#include <wcsmbs/wcscpy.c>
+
+#ifdef SHARED
+__hidden_ver1 (__wcscpy_ppc, __GI___wcscpy, __wcscpy_ppc);
+#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c
index ecca37d5d6..e87984669e 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c
@@ -17,20 +17,20 @@
<http://www.gnu.org/licenses/>. */
#if IS_IN (libc)
+# define wcscpy __redirect_wcscpy
# include <wchar.h>
-# include <shlib-compat.h>
+# undef wcscpy
# include "init-arch.h"
-extern __typeof (wcscpy) __wcscpy_ppc attribute_hidden;
-extern __typeof (wcscpy) __wcscpy_power6 attribute_hidden;
-extern __typeof (wcscpy) __wcscpy_power7 attribute_hidden;
+extern __typeof (__redirect_wcscpy) __wcscpy_ppc attribute_hidden;
+extern __typeof (__redirect_wcscpy) __wcscpy_power6 attribute_hidden;
+extern __typeof (__redirect_wcscpy) __wcscpy_power7 attribute_hidden;
-libc_ifunc (wcscpy,
- (hwcap & PPC_FEATURE_HAS_VSX)
- ? __wcscpy_power7 :
- (hwcap & PPC_FEATURE_ARCH_2_05)
- ? __wcscpy_power6
- : __wcscpy_ppc);
-#else
-#include <wcsmbs/wcscpy.c>
+libc_ifunc_redirected (__redirect_wcscpy, wcscpy,
+ (hwcap & PPC_FEATURE_HAS_VSX)
+ ? __wcscpy_power7 :
+ (hwcap & PPC_FEATURE_ARCH_2_05)
+ ? __wcscpy_power6
+ : __wcscpy_ppc);
+weak_alias (wcscpy, __wcscpy)
#endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcscpy.c b/sysdeps/powerpc/powerpc64/multiarch/wcscpy.c
index 3cea9a489d..3f918b27c6 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/wcscpy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/wcscpy.c
@@ -16,21 +16,20 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#if IS_IN (libc)
-# include <wchar.h>
-# include <shlib-compat.h>
-# include "init-arch.h"
+#define __wcscpy __redirect___wcscpy
+#include <wchar.h>
+#undef __wcscpy
+#include <shlib-compat.h>
+#include "init-arch.h"
extern __typeof (wcscpy) __wcscpy_ppc attribute_hidden;
extern __typeof (wcscpy) __wcscpy_power6 attribute_hidden;
extern __typeof (wcscpy) __wcscpy_power7 attribute_hidden;
-libc_ifunc (wcscpy,
- (hwcap & PPC_FEATURE_HAS_VSX)
- ? __wcscpy_power7 :
- (hwcap & PPC_FEATURE_ARCH_2_05)
- ? __wcscpy_power6
- : __wcscpy_ppc);
-#else
-#include <wcsmbs/wcscpy.c>
-#endif
+libc_ifunc_redirected (__redirect___wcscpy, __wcscpy,
+ (hwcap & PPC_FEATURE_HAS_VSX)
+ ? __wcscpy_power7 :
+ (hwcap & PPC_FEATURE_ARCH_2_05)
+ ? __wcscpy_power6
+ : __wcscpy_ppc);
+weak_alias (__wcscpy, wcscpy)
diff --git a/sysdeps/s390/wcscpy.c b/sysdeps/s390/wcscpy.c
index 2e8ef5024f..a569f917af 100644
--- a/sysdeps/s390/wcscpy.c
+++ b/sysdeps/s390/wcscpy.c
@@ -30,9 +30,11 @@ extern __typeof (wcscpy) WCSCPY_C attribute_hidden;
extern __typeof (wcscpy) WCSCPY_Z13 attribute_hidden;
# endif
-s390_libc_ifunc_expr (wcscpy, wcscpy,
+s390_libc_ifunc_expr (wcscpy, __wcscpy,
(HAVE_WCSCPY_Z13 && (hwcap & HWCAP_S390_VX))
? WCSCPY_Z13
: WCSCPY_DEFAULT
)
+weak_alias (__wcscpy, wcscpy)
+libc_hidden_def (__wcscpy)
#endif
diff --git a/sysdeps/x86_64/multiarch/wcscpy-c.c b/sysdeps/x86_64/multiarch/wcscpy-c.c
index a51a83a9be..26d6984e9b 100644
--- a/sysdeps/x86_64/multiarch/wcscpy-c.c
+++ b/sysdeps/x86_64/multiarch/wcscpy-c.c
@@ -1,5 +1,5 @@
#if IS_IN (libc)
-# define wcscpy __wcscpy_sse2
+# define WCSCPY __wcscpy_sse2
#endif
-#include "wcsmbs/wcscpy.c"
+#include <wcsmbs/wcscpy.c>
diff --git a/sysdeps/x86_64/multiarch/wcscpy.c b/sysdeps/x86_64/multiarch/wcscpy.c
index 101a585358..96151b4963 100644
--- a/sysdeps/x86_64/multiarch/wcscpy.c
+++ b/sysdeps/x86_64/multiarch/wcscpy.c
@@ -19,9 +19,9 @@
/* Define multiple versions only for the definition in libc. */
#if IS_IN (libc)
-# define wcscpy __redirect_wcscpy
+# define __wcscpy __redirect_wcscpy
# include <wchar.h>
-# undef wcscpy
+# undef __wcscpy
# define SYMBOL_NAME wcscpy
# include <init-arch.h>
@@ -40,5 +40,10 @@ IFUNC_SELECTOR (void)
return OPTIMIZE (sse2);
}
-libc_ifunc_redirected (__redirect_wcscpy, wcscpy, IFUNC_SELECTOR ());
+libc_ifunc_redirected (__redirect_wcscpy, __wcscpy, IFUNC_SELECTOR ());
+weak_alias (__wcscpy, wcscpy)
+# ifdef SHARED
+__hidden_ver1 (__wcscpy, __GI___wcscpy, __redirect_wcscpy)
+ __attribute__((visibility ("hidden"))) __attribute_copy__ (wcscpy);
+# endif
#endif