about summary refs log tree commit diff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-08-24 16:03:28 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-08-27 09:35:12 -0700
commit77e4166575426d29795e034b126cb6f4744fb34b (patch)
treec7f78fcfb9b2e76b2b7e9834e559007a1b098b82
parent50ec29e549f0be35d80bef70903a210682a1806a (diff)
downloadglibc-77e4166575426d29795e034b126cb6f4744fb34b.tar.gz
glibc-77e4166575426d29795e034b126cb6f4744fb34b.tar.xz
glibc-77e4166575426d29795e034b126cb6f4744fb34b.zip
Add i386 strspn multiarch functions
-rw-r--r--sysdeps/i386/i686/multiarch/Makefile7
-rw-r--r--sysdeps/i386/i686/multiarch/strspn.S61
-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.c (renamed from sysdeps/i386/i686/multiarch/strspn-c.c)2
-rw-r--r--sysdeps/i386/multiarch/strspn.c49
7 files changed, 64 insertions, 73 deletions
diff --git a/sysdeps/i386/i686/multiarch/Makefile b/sysdeps/i386/i686/multiarch/Makefile
index 77f01df193..ff54ee963b 100644
--- a/sysdeps/i386/i686/multiarch/Makefile
+++ b/sysdeps/i386/i686/multiarch/Makefile
@@ -1,10 +1,3 @@
-ifeq ($(subdir),string)
-ifeq (yes,$(config-cflags-sse4))
-sysdep_routines += strspn-c
-CFLAGS-strspn-c.c += -msse4
-endif
-endif
-
 ifeq ($(subdir),wcsmbs)
 sysdep_routines += wcscmp-sse2 wcscmp-c wcslen-sse2 wcslen-c \
 		   wmemcmp-sse4 wmemcmp-ssse3 wmemcmp-c wcschr-sse2 \
diff --git a/sysdeps/i386/i686/multiarch/strspn.S b/sysdeps/i386/i686/multiarch/strspn.S
deleted file mode 100644
index 4ba87be45b..0000000000
--- a/sysdeps/i386/i686/multiarch/strspn.S
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Multiple versions of strspn
-   All versions must be listed in ifunc-impl-list.c.
-   Copyright (C) 2009-2015 Free Software Foundation, Inc.
-   Contributed by Intel Corporation.
-   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 <config.h>
-
-#ifdef HAVE_SSE4_SUPPORT
-
-#include <sysdep.h>
-#include <init-arch.h>
-
-/* Define multiple versions only for the definition in libc.  */
-#if IS_IN (libc)
-	.text
-ENTRY(strspn)
-	.type	strspn, @gnu_indirect_function
-	LOAD_GOT_AND_RTLD_GLOBAL_RO
-	LOAD_FUNC_GOT_EAX (__strspn_ia32)
-	HAS_CPU_FEATURE (SSE4_2)
-	jz	2f
-	LOAD_FUNC_GOT_EAX (__strspn_sse42)
-2:	ret
-END(strspn)
-
-# undef ENTRY
-# define ENTRY(name) \
-	.type __strspn_ia32, @function; \
-	.globl __strspn_ia32; \
-	.p2align 4; \
-__strspn_ia32: cfi_startproc; \
-	CALL_MCOUNT
-# undef END
-# define END(name) \
-	cfi_endproc; .size __strspn_ia32, .-__strspn_ia32
-# undef libc_hidden_builtin_def
-/* IFUNC doesn't work with the hidden functions in shared library since
-   they will be called without setting up EBX needed for PLT which is
-   used by IFUNC.  */
-# define libc_hidden_builtin_def(name) \
-	.globl __GI_strspn; __GI_strspn = __strspn_ia32
-#endif
-
-#endif /* HAVE_SSE4_SUPPORT */
-
-#include "../../strspn.S"
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/i686/multiarch/strspn-c.c b/sysdeps/i386/multiarch/strspn-sse4.c
index bea09dea71..fc84a3dc24 100644
--- a/sysdeps/i386/i686/multiarch/strspn-c.c
+++ b/sysdeps/i386/multiarch/strspn-sse4.c
@@ -1,2 +1,2 @@
-#define __strspn_sse2 __strspn_ia32
+#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