about summary refs log tree commit diff
path: root/sysdeps/i386/multiarch
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/multiarch')
-rw-r--r--sysdeps/i386/multiarch/Makefile6
-rw-r--r--sysdeps/i386/multiarch/ifunc-impl-list.c4
-rw-r--r--sysdeps/i386/multiarch/strspn-i386.S8
-rw-r--r--sysdeps/i386/multiarch/strspn-sse4.c2
-rw-r--r--sysdeps/i386/multiarch/strspn.c49
5 files changed, 65 insertions, 4 deletions
diff --git a/sysdeps/i386/multiarch/Makefile b/sysdeps/i386/multiarch/Makefile
index 5e636edfa5..89c86b49c4 100644
--- a/sysdeps/i386/multiarch/Makefile
+++ b/sysdeps/i386/multiarch/Makefile
@@ -38,12 +38,14 @@ sysdep_routines += bcopy-i386 bcopy-i686 bcopy-sse2-unaligned \
 		   strcspn-i386 strpbrk-i386 \
 		   strlen-i386 strlen-i586 strlen-sse2 strlen-sse2-bsf \
 		   strnlen-sse2 strnlen-i386 static-strlen \
-		   strrchr-i386 strrchr-sse2-bsf strrchr-sse2
+		   strrchr-i386 strrchr-sse2-bsf strrchr-sse2 \
+		   strspn-i386 strspn-sse4
 ifeq (yes,$(config-cflags-sse4))
-sysdep_routines += varshift strcspn-sse4 strpbrk-sse4
+sysdep_routines += varshift strcspn-sse4 strpbrk-sse4 strspn-sse4
 CFLAGS-varshift.c += -msse4
 CFLAGS-strcspn-sse4.c += -msse4
 CFLAGS-strpbrk-sse4.c += -msse4
+CFLAGS-strspn-sse4.c += -msse4
 endif
 endif
 
diff --git a/sysdeps/i386/multiarch/ifunc-impl-list.c b/sysdeps/i386/multiarch/ifunc-impl-list.c
index a53c49f280..94a376d4e6 100644
--- a/sysdeps/i386/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/multiarch/ifunc-impl-list.c
@@ -310,13 +310,13 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 			      __strrchr_sse2)
 	      IFUNC_IMPL_ADD (array, i, strrchr, 1, __strrchr_i386))
 
-#if 0
   /* Support sysdeps/i386/i686/multiarch/strspn.S.  */
   IFUNC_IMPL (i, name, strspn,
 	      IFUNC_IMPL_ADD (array, i, strspn, HAS_CPU_FEATURE (SSE4_2),
 			      __strspn_sse42)
-	      IFUNC_IMPL_ADD (array, i, strspn, 1, __strspn_ia32))
+	      IFUNC_IMPL_ADD (array, i, strspn, 1, __strspn_i386))
 
+#if 0
   /* Support sysdeps/i386/i686/multiarch/wcschr.S.  */
   IFUNC_IMPL (i, name, wcschr,
 	      IFUNC_IMPL_ADD (array, i, wcschr, HAS_CPU_FEATURE (SSE2),
diff --git a/sysdeps/i386/multiarch/strspn-i386.S b/sysdeps/i386/multiarch/strspn-i386.S
new file mode 100644
index 0000000000..c6d4d67166
--- /dev/null
+++ b/sysdeps/i386/multiarch/strspn-i386.S
@@ -0,0 +1,8 @@
+#define strspn __strspn_i386
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+#include <sysdeps/i386/strspn.S>
+
+	.globl __GI_strspn
+	.hidden __GI_strspn
+	__GI_strspn = __strspn_i386
diff --git a/sysdeps/i386/multiarch/strspn-sse4.c b/sysdeps/i386/multiarch/strspn-sse4.c
new file mode 100644
index 0000000000..fc84a3dc24
--- /dev/null
+++ b/sysdeps/i386/multiarch/strspn-sse4.c
@@ -0,0 +1,2 @@
+#define __strspn_sse2 __strspn_i386
+#include <sysdeps/x86_64/multiarch/strspn-c.c>
diff --git a/sysdeps/i386/multiarch/strspn.c b/sysdeps/i386/multiarch/strspn.c
new file mode 100644
index 0000000000..91d5a5f9e9
--- /dev/null
+++ b/sysdeps/i386/multiarch/strspn.c
@@ -0,0 +1,49 @@
+/* Multiple versions of strspn.
+   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 libc.  */
+#if IS_IN (libc)
+# define _HAVE_STRING_ARCH_strspn
+/* Redefine strspn so that the compiler won't complain about the type
+   mismatch with the IFUNC selector in strong_alias, below.  */
+# undef strspn
+# define strspn __redirect_strspn
+# include <string.h>
+# undef strspn
+
+# include <init-arch.h>
+
+extern __typeof (__redirect_strspn) __strspn_i386 attribute_hidden;
+extern __typeof (__redirect_strspn) __strspn_sse42 attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+extern __typeof (__redirect_strspn) strspn;
+extern void *strspn_ifunc (void) __asm__ ("strspn");
+
+void *
+strspn_ifunc (void)
+{
+  if (HAS_CPU_FEATURE (SSE4_2))
+    return __strspn_sse42;
+
+  return __strspn_i386;
+}
+__asm__ (".type strspn, %gnu_indirect_function");
+#endif