aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-08-20 08:20:41 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-08-20 16:25:21 -0700
commite16d4bb2027bb2e4a2aa21684e1133dfb403ada1 (patch)
treedd0d0eeeb522d33772b2c2704c0024ad4cd021e1
parent59ab12e45f78aec00851dd3bd76351cd74ebf9fb (diff)
downloadglibc-e16d4bb2027bb2e4a2aa21684e1133dfb403ada1.tar
glibc-e16d4bb2027bb2e4a2aa21684e1133dfb403ada1.tar.gz
glibc-e16d4bb2027bb2e4a2aa21684e1133dfb403ada1.tar.bz2
glibc-e16d4bb2027bb2e4a2aa21684e1133dfb403ada1.zip
Add i386 memcmp multiarch functions
-rw-r--r--sysdeps/i386/multiarch/Makefile3
-rw-r--r--sysdeps/i386/multiarch/ifunc-impl-list.c6
-rw-r--r--sysdeps/i386/multiarch/memcmp-i386.S15
-rw-r--r--sysdeps/i386/multiarch/memcmp-i686.S13
-rw-r--r--sysdeps/i386/multiarch/memcmp-sse4.S (renamed from sysdeps/i386/i686/multiarch/memcmp-sse4.S)0
-rw-r--r--sysdeps/i386/multiarch/memcmp-ssse3.S (renamed from sysdeps/i386/i686/multiarch/memcmp-ssse3.S)0
-rw-r--r--sysdeps/i386/multiarch/memcmp.c57
-rw-r--r--sysdeps/i386/multiarch/rtld-memcmp.S24
8 files changed, 115 insertions, 3 deletions
diff --git a/sysdeps/i386/multiarch/Makefile b/sysdeps/i386/multiarch/Makefile
index c9508a26a5..375f66ccc4 100644
--- a/sysdeps/i386/multiarch/Makefile
+++ b/sysdeps/i386/multiarch/Makefile
@@ -18,5 +18,6 @@ sysdep_routines += bcopy-i386 bcopy-i686 bcopy-sse2-unaligned \
bzero-sse2 bzero-sse2-rep \
memset-i386 memset-i586 memset-i686 \
memset-sse2 memset-sse2-rep \
- memchr-sse2-bsf memchr-sse2
+ memchr-sse2-bsf memchr-sse2 \
+ memcmp-i386 memcmp-i686 memcmp-ssse3 memcmp-sse4
endif
diff --git a/sysdeps/i386/multiarch/ifunc-impl-list.c b/sysdeps/i386/multiarch/ifunc-impl-list.c
index 680e46797b..1c9ae6a9cc 100644
--- a/sysdeps/i386/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/multiarch/ifunc-impl-list.c
@@ -73,15 +73,17 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
__memchr_sse2)
IFUNC_IMPL_ADD (array, i, memchr, 1, __memchr_i386))
-#if 0
/* Support sysdeps/i386/i686/multiarch/memcmp.S. */
IFUNC_IMPL (i, name, memcmp,
IFUNC_IMPL_ADD (array, i, memcmp, HAS_CPU_FEATURE (SSE4_2),
__memcmp_sse4_2)
IFUNC_IMPL_ADD (array, i, memcmp, HAS_CPU_FEATURE (SSSE3),
__memcmp_ssse3)
- IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_ia32))
+ IFUNC_IMPL_ADD (array, i, memcmp, HAS_I686, __memcmp_i686)
+#if !SUPPORT_I686
+ IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_i386)
#endif
+ )
/* Support sysdeps/i386/i686/multiarch/memmove_chk.S. */
IFUNC_IMPL (i, name, __memmove_chk,
diff --git a/sysdeps/i386/multiarch/memcmp-i386.S b/sysdeps/i386/multiarch/memcmp-i386.S
new file mode 100644
index 0000000000..bdc1b1da5b
--- /dev/null
+++ b/sysdeps/i386/multiarch/memcmp-i386.S
@@ -0,0 +1,15 @@
+#include <init-arch.h>
+#if !SUPPORT_I686
+# define memcmp __memcmp_i386
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)
+# undef weak_alias
+# define weak_alias(name, aliasname)
+# include <sysdeps/i386/memcmp.S>
+
+# ifdef SHARED
+ .globl __GI_memcmp
+ .hidden __GI_memcmp
+ __GI_memcmp = __memcmp_i386
+# endif
+#endif
diff --git a/sysdeps/i386/multiarch/memcmp-i686.S b/sysdeps/i386/multiarch/memcmp-i686.S
new file mode 100644
index 0000000000..18c682a189
--- /dev/null
+++ b/sysdeps/i386/multiarch/memcmp-i686.S
@@ -0,0 +1,13 @@
+#include <init-arch.h>
+#define memcmp __memcmp_i686
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+#undef weak_alias
+#define weak_alias(name, aliasname)
+# include <sysdeps/i386/i686/memcmp.S>
+
+#if defined SHARED && SUPPORT_I686
+ .globl __GI_memcmp
+ .hidden __GI_memcmp
+ __GI_memcmp = __memcmp_i686
+#endif
diff --git a/sysdeps/i386/i686/multiarch/memcmp-sse4.S b/sysdeps/i386/multiarch/memcmp-sse4.S
index b3756f4a00..b3756f4a00 100644
--- a/sysdeps/i386/i686/multiarch/memcmp-sse4.S
+++ b/sysdeps/i386/multiarch/memcmp-sse4.S
diff --git a/sysdeps/i386/i686/multiarch/memcmp-ssse3.S b/sysdeps/i386/multiarch/memcmp-ssse3.S
index ea2a25b216..ea2a25b216 100644
--- a/sysdeps/i386/i686/multiarch/memcmp-ssse3.S
+++ b/sysdeps/i386/multiarch/memcmp-ssse3.S
diff --git a/sysdeps/i386/multiarch/memcmp.c b/sysdeps/i386/multiarch/memcmp.c
new file mode 100644
index 0000000000..a0cd039fce
--- /dev/null
+++ b/sysdeps/i386/multiarch/memcmp.c
@@ -0,0 +1,57 @@
+/* Multiple versions of memcmp.
+ All versions must be listed in ifunc-impl-list.c.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Define multiple versions only for the definition in lib. */
+#if IS_IN (libc)
+/* Redefine memcmp so that the compiler won't complain about the type
+ mismatch with the IFUNC selector in strong_alias, below. */
+# undef memcmp
+# define memcmp __redirect_memcmp
+# include <string.h>
+# undef memcmp
+
+# include <init-arch.h>
+
+extern __typeof (__redirect_memcmp) __memcmp_i386 attribute_hidden;
+extern __typeof (__redirect_memcmp) __memcmp_i686 attribute_hidden;
+extern __typeof (__redirect_memcmp) __memcmp_ssse3 attribute_hidden;
+extern __typeof (__redirect_memcmp) __memcmp_sse4_2 attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+ ifunc symbol properly. */
+extern __typeof (__redirect_memcmp) memcmp;
+extern void *memcmp_ifunc (void) __asm__ ("memcmp");
+
+void *
+memcmp_ifunc (void)
+{
+ if (HAS_CPU_FEATURE (SSE4_2))
+ return __memcmp_sse4_2;
+ else if (HAS_CPU_FEATURE (SSSE3))
+ return __memcmp_ssse3;
+
+ if (HAS_I686)
+ return __memcmp_i686;
+ else
+ return __memcmp_i386;
+}
+__asm__ (".type memcmp, %gnu_indirect_function");
+
+weak_alias (memcmp, bcmp)
+#endif
diff --git a/sysdeps/i386/multiarch/rtld-memcmp.S b/sysdeps/i386/multiarch/rtld-memcmp.S
new file mode 100644
index 0000000000..89466a5e62
--- /dev/null
+++ b/sysdeps/i386/multiarch/rtld-memcmp.S
@@ -0,0 +1,24 @@
+/* memcmp for ld.so
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <init-arch.h>
+#if SUPPORT_I686
+# include <sysdeps/i386/i686/memcmp.S>
+#else
+# include <sysdeps/i386/memcmp.S>
+#endif