This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch azanella/sparc64-ifunc created. glibc-2.26-497-g5175c26


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, azanella/sparc64-ifunc has been created
        at  5175c26e406cc9297a6dba201c76b68fa5f057ce (commit)

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=5175c26e406cc9297a6dba201c76b68fa5f057ce

commit 5175c26e406cc9297a6dba201c76b68fa5f057ce
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Oct 3 10:58:29 2017 -0300

    sparc: Implement memset/bzero ifunc selection in C
    
    This patch refactor the SPARC64 ifunc selector to a C implementation.
    No functional change is expected, including ifunc resolution rules.
    
    Checked on sparc64-linux-gnu, sparcv9-linux-gnu and x86_64-linux-gnu.
    
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
    	[$(subdir) = string] (sysdep_routines): Add memset-ultra1.
    	* sysdeps/sparc/sparc64/multiarch/Makefile [$(subdir) = string]
    	(sysdep_routines): Add memset-ultra1.
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S: New
    	file.
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c: Likewise.
    	* sysdeps/sparc/sparc64/multiarch/ifunc-memset.h: Likewise.
    	* sysdeps/sparc/sparc64/multiarch/memset-ultra1.S: Likewise.
    	* sysdeps/sparc/sparc64/multiarch/memset.c: Likewise.
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S: Remove file.
    	* sysdeps/sparc/sparc64/multiarch/memset.S: Likewise.

diff --git a/ChangeLog b/ChangeLog
index fb954fa..c278a20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2017-10-03  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
+	[$(subdir) = string] (sysdep_routines): Add memset-ultra1.
+	* sysdeps/sparc/sparc64/multiarch/Makefile [$(subdir) = string]
+	(sysdep_routines): Add memset-ultra1.
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S: New
+	file.
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c: Likewise.
+	* sysdeps/sparc/sparc64/multiarch/ifunc-memset.h: Likewise.
+	* sysdeps/sparc/sparc64/multiarch/memset-ultra1.S: Likewise.
+	* sysdeps/sparc/sparc64/multiarch/memset.c: Likewise.
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S: Remove file.
+	* sysdeps/sparc/sparc64/multiarch/memset.S: Likewise.
+
 	* sysdeps/generic/ifunc-init.h: New file.
 	* sysdeps/sparc/init-arch.h: Likewise.
 	* sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-ultra1.S: New
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile b/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
index ca44798..e12636b 100644
--- a/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
@@ -9,5 +9,5 @@ endif
 ifeq ($(subdir),string)
 sysdep_routines += memcpy-ultra3 memcpy-niagara1 memcpy-niagara2 \
 		   memset-niagara1 memcpy-niagara4 memset-niagara4 \
-		   memcpy-ultra1
+		   memcpy-ultra1 memset-ultra1
 endif
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S
new file mode 100644
index 0000000..4a5508d
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S
@@ -0,0 +1,33 @@
+/* Default SPARC64 memset implementation.
+   Copyright (C) 2017 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/>.  */
+
+#if IS_IN (libc)
+
+# include <sysdep.h>
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)
+# undef weak_alias
+# define weak_alias(x, y)
+
+# define memset __memset_ultra1
+# define __bzero __bzero_ultra1
+
+#endif
+
+#include <sysdeps/sparc/sparc32/sparcv9/memset.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S
deleted file mode 100644
index 8f82643..0000000
--- a/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S
+++ /dev/null
@@ -1,4 +0,0 @@
-#define ASI_PNF     0x82
-#define ASI_BLK_P   0xf0
-#define XCC icc
-#include <sparc64/multiarch/memset.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c
new file mode 100644
index 0000000..a6c5734
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c
@@ -0,0 +1 @@
+#include <sysdeps/sparc/sparc64/multiarch/memset.c>
diff --git a/sysdeps/sparc/sparc64/multiarch/Makefile b/sysdeps/sparc/sparc64/multiarch/Makefile
index 4e52526..6e90cba 100644
--- a/sysdeps/sparc/sparc64/multiarch/Makefile
+++ b/sysdeps/sparc/sparc64/multiarch/Makefile
@@ -9,7 +9,7 @@ endif
 ifeq ($(subdir),string)
 sysdep_routines += memcpy-ultra3 memcpy-niagara1 memcpy-niagara2 \
 		   memset-niagara1 memcpy-niagara4 memset-niagara4 \
-		   memcpy-ultra1
+		   memcpy-ultra1 memset-ultra1
 endif
 
 ifeq ($(subdir),stdlib)
diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-memset.h b/sysdeps/sparc/sparc64/multiarch/ifunc-memset.h
new file mode 100644
index 0000000..eaf0fb8
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/ifunc-memset.h
@@ -0,0 +1,34 @@
+/* Common definition for memset/bzero implementation.
+   All versions must be listed in ifunc-impl-list.c.
+   Copyright (C) 2017 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>
+
+extern __typeof (REDIRECT_NAME) OPTIMIZE (niagara4) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (niagara1) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (ultra1) attribute_hidden;
+
+static inline void *
+IFUNC_SELECTOR (int hwcap)
+{
+  if (hwcap & HWCAP_SPARC_CRYPTO)
+    return OPTIMIZE (niagara4);
+  if (hwcap & HWCAP_SPARC_BLKINIT)
+    return OPTIMIZE (niagara1);
+  return OPTIMIZE (ultra1);
+}
diff --git a/sysdeps/sparc/sparc64/multiarch/memset-ultra1.S b/sysdeps/sparc/sparc64/multiarch/memset-ultra1.S
new file mode 100644
index 0000000..728c179
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/memset-ultra1.S
@@ -0,0 +1,33 @@
+/* Default SPARC64 memset implementation.
+   Copyright (C) 2017 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/>.  */
+
+#if IS_IN (libc)
+
+# include <sysdep.h>
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)
+# undef weak_alias
+# define weak_alias(x, y)
+
+# define memset __memset_ultra1
+# define __bzero __bzero_ultra1
+
+#endif
+
+#include <sysdeps/sparc/sparc64/memset.S>
diff --git a/sysdeps/sparc/sparc64/multiarch/memset.S b/sysdeps/sparc/sparc64/multiarch/memset.S
deleted file mode 100644
index 9469d5e..0000000
--- a/sysdeps/sparc/sparc64/multiarch/memset.S
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Multiple versions of memset and bzero
-   All versions must be listed in ifunc-impl-list.c.
-   Copyright (C) 2010-2017 Free Software Foundation, Inc.
-   Contributed by David S. Miller (davem@davemloft.net)
-   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 <sysdep.h>
-
-#if IS_IN (libc)
-	.text
-ENTRY(memset)
-	.type	memset, @gnu_indirect_function
-# ifdef SHARED
-	SETUP_PIC_REG_LEAF(o3, o5)
-# endif
-	set	HWCAP_SPARC_CRYPTO, %o1
-	andcc	%o0, %o1, %g0
-	be	1f
-	 andcc	%o0, HWCAP_SPARC_BLKINIT, %g0
-# ifdef SHARED
-	sethi	%gdop_hix22(__memset_niagara4), %o1
-	xor	%o1, %gdop_lox10(__memset_niagara4), %o1
-# else
-	set	__memset_niagara4, %o1
-# endif
-	ba	10f
-	 nop
-1:	be	9f
-	 nop
-# ifdef SHARED
-	sethi	%gdop_hix22(__memset_niagara1), %o1
-	xor	%o1, %gdop_lox10(__memset_niagara1), %o1
-# else
-	set	__memset_niagara1, %o1
-# endif
-	ba	10f
-	 nop
-9:
-# ifdef SHARED
-	sethi	%gdop_hix22(__memset_ultra1), %o1
-	xor	%o1, %gdop_lox10(__memset_ultra1), %o1
-# else
-	set	__memset_ultra1, %o1
-# endif
-10:
-# ifdef SHARED
-	add	%o3, %o1, %o1
-# endif
-	retl
-	 mov	%o1, %o0
-END(memset)
-
-ENTRY(__bzero)
-	.type	bzero, @gnu_indirect_function
-# ifdef SHARED
-	SETUP_PIC_REG_LEAF(o3, o5)
-# endif
-	set	HWCAP_SPARC_CRYPTO, %o1
-	andcc	%o0, %o1, %g0
-	be	1f
-	 andcc	%o0, HWCAP_SPARC_BLKINIT, %g0
-# ifdef SHARED
-	sethi	%gdop_hix22(__bzero_niagara4), %o1
-	xor	%o1, %gdop_lox10(__bzero_niagara4), %o1
-# else
-	set	__bzero_niagara4, %o1
-# endif
-	ba	10f
-	 nop
-1:	be	9f
-	 nop
-# ifdef SHARED
-	sethi	%gdop_hix22(__bzero_niagara1), %o1
-	xor	%o1, %gdop_lox10(__bzero_niagara1), %o1
-# else
-	set	__bzero_niagara1, %o1
-# endif
-	ba	10f
-	 nop
-9:
-# ifdef SHARED
-	sethi	%gdop_hix22(__bzero_ultra1), %o1
-	xor	%o1, %gdop_lox10(__bzero_ultra1), %o1
-# else
-	set	__bzero_ultra1, %o1
-# endif
-10:
-# ifdef SHARED
-	add	%o3, %o1, %o1
-# endif
-	retl
-	 mov	%o1, %o0
-END(__bzero)
-
-weak_alias (__bzero, bzero)
-
-# undef weak_alias
-# define weak_alias(a, b)
-
-libc_hidden_builtin_def (memset)
-
-#undef libc_hidden_builtin_def
-#define libc_hidden_builtin_def(name)
-
-#define memset __memset_ultra1
-#define __bzero __bzero_ultra1
-
-#endif
-
-#include "../memset.S"
diff --git a/sysdeps/sparc/sparc64/multiarch/memset.c b/sysdeps/sparc/sparc64/multiarch/memset.c
new file mode 100644
index 0000000..7f1d499
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/memset.c
@@ -0,0 +1,49 @@
+/* Multiple versions of memset.
+   All versions must be listed in ifunc-impl-list.c.
+   Copyright (C) 2017 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/>.  */
+
+#if IS_IN (libc)
+# define memset __redirect_memset
+# define bzero __redirect_bzero
+# include <string.h>
+# undef memset
+# undef bzero
+
+# include <sparc-ifunc.h>
+
+# define SYMBOL_NAME memset
+# include "ifunc-memset.h"
+
+sparc_libc_ifunc_redirected (__redirect_memset, memset, IFUNC_SELECTOR);
+
+/* It essentially does libc_hidden_builtin_def (memset) and redirect
+   the internal symbol to ifunc implementation.  */
+# ifdef SHARED
+__hidden_ver1 (memset, __GI_memset, __redirect_memset)
+  __attribute__ ((visibility ("hidden")));
+# endif
+# undef SYMBOL_NAME
+
+
+# define SYMBOL_NAME bzero
+# include "ifunc-memset.h"
+
+sparc_libc_ifunc_redirected (__redirect_bzero, __bzero, IFUNC_SELECTOR);
+weak_alias (__bzero, bzero)
+
+#endif

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=fc65b1283f15bef84d909fb8aa8d3831e4165968

commit fc65b1283f15bef84d909fb8aa8d3831e4165968
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Oct 3 00:48:27 2017 -0300

    sparc: Implement memcpy/mempcpy ifunc selection in C
    
    This patch refactor the SPARC64 ifunc selector to a C implementation.
    The x86_64 implementation is used as default, which resulted in common
    definitions (ifunc-init.h) used on both architectures.  No functional
    change is expected, including ifunc resolution rules.
    
    Checked on sparc64-linux-gnu, sparcv9-linux-gnu and x86_64-linux-gnu.
    
    	* sysdeps/generic/ifunc-init.h: New file.
    	* sysdeps/sparc/init-arch.h: Likewise.
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-ultra1.S: New
    	file.
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.c: Likewise.
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/mempcpy.c: Likewise.
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-mempcpy.S: Likewise.
    	* sysdeps/sparc/sparc64/multiarch/ifunc-memcpy.h: Likewise.
    	* sysdeps/sparc/sparc64/multiarch/memcpy-ultra1.S: Likewise.
    	* sysdeps/sparc/sparc64/multiarch/memcpy.c: Likewise.
    	* sysdeps/sparc/sparc64/multiarch/mempcpy.c: Likewise.
    	* sysdeps/sparc/sparc64/multiarch/rtld-mempcpy.S: Likewise.
    	* sysdeps/sparc/sparc-ifunc.h (sparc_libc_ifunc_redirected): New
    	macro.
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
    	[$(subdir) = string] (sysdep_routines): Add memcpy-ultra1.
    	* sysdeps/sparc/sparc64/multiarch/Makefile [$(subdir) = string]
    	(sysdep_routines): Add memcpy-ultra1.
    	* sysdeps/sparc/sparc64/multiarch/memcpy.S: Remove file.
    	* sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.S: Likewise.
    	* sysdeps/x86/init-arch.h: Use generic ifunc-init.h.

diff --git a/ChangeLog b/ChangeLog
index 9cbff97..fb954fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2017-10-03  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+	* sysdeps/generic/ifunc-init.h: New file.
+	* sysdeps/sparc/init-arch.h: Likewise.
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-ultra1.S: New
+	file.
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.c: Likewise.
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/mempcpy.c: Likewise.
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-mempcpy.S: Likewise.
+	* sysdeps/sparc/sparc64/multiarch/ifunc-memcpy.h: Likewise.
+	* sysdeps/sparc/sparc64/multiarch/memcpy-ultra1.S: Likewise.
+	* sysdeps/sparc/sparc64/multiarch/memcpy.c: Likewise.
+	* sysdeps/sparc/sparc64/multiarch/mempcpy.c: Likewise.
+	* sysdeps/sparc/sparc64/multiarch/rtld-mempcpy.S: Likewise.
+	* sysdeps/sparc/sparc-ifunc.h (sparc_libc_ifunc_redirected): New
+	macro.
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
+	[$(subdir) = string] (sysdep_routines): Add memcpy-ultra1.
+	* sysdeps/sparc/sparc64/multiarch/Makefile [$(subdir) = string]
+	(sysdep_routines): Add memcpy-ultra1.
+	* sysdeps/sparc/sparc64/multiarch/memcpy.S: Remove file.
+	* sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.S: Likewise.
+	* sysdeps/x86/init-arch.h: Use generic ifunc-init.h.
+
 2017-10-03  Samuel Thibault  <samuel.thibault@ens-lyon.org>
 
 	* include/libc-symbols.h [NO_RTLD_HIDDEN] (rtld_hidden_proto,
diff --git a/sysdeps/x86/init-arch.h b/sysdeps/generic/ifunc-init.h
similarity index 57%
copy from sysdeps/x86/init-arch.h
copy to sysdeps/generic/ifunc-init.h
index 15d3f09..59d5ac6 100644
--- a/sysdeps/x86/init-arch.h
+++ b/sysdeps/generic/ifunc-init.h
@@ -1,5 +1,6 @@
-/* This file is part of the GNU C Library.
-   Copyright (C) 2008-2017 Free Software Foundation, Inc.
+/* IFUNC generic definitions.
+   This file is part of the GNU C Library.
+   Copyright (C) 2017 Free Software Foundation, Inc.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -15,38 +16,29 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef  __ASSEMBLER__
-# include <cpu-features.h>
-#else
-# include <ldsodefs.h>
-#endif
-
 /* These macros are used to implement ifunc selection in C.  To implement
-   an ifunc function, foo, which returns the address of __foo_sse2 or
-   __foo_avx2:
+   an ifunc function, foo, which returns the address of __foo_impl1 or
+   __foo_impl2:
 
    #define foo __redirect_foo
-   #define __foo __redirect___foo
    #include <foo.h>
    #undef foo
-   #undef __foo
    #define SYMBOL_NAME foo
-   #include <init-arch.h>
+   #include <ifunc-init.h>
 
-   extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2) attribute_hidden;
-   extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden;
+   extern __typeof (REDIRECT_NAME) OPTIMIZE (impl1) attribute_hidden;
+   extern __typeof (REDIRECT_NAME) OPTIMIZE (impl2) attribute_hidden;
 
    static inline void *
    foo_selector (void)
    {
-     if (use AVX2)
-      return OPTIMIZE (avx2);
+     if (condition)
+      return OPTIMIZE (impl2);
 
-     return OPTIMIZE (sse2);
+     return OPTIMIZE (impl1);
    }
 
-   libc_ifunc_redirected (__redirect_foo, foo, foo_selector ());
-
+   libc_ifunc_redirected (__redirect_foo, foo, IFUNC_SELECTOR ());
 */
 
 #define PASTER1(x,y)	x##_##y
@@ -60,16 +52,3 @@
 #define REDIRECT_NAME	EVALUATOR1 (__redirect, SYMBOL_NAME)
 #define OPTIMIZE(name)	EVALUATOR2 (SYMBOL_NAME, name)
 #define IFUNC_SELECTOR	EVALUATOR1 (SYMBOL_NAME, ifunc_selector)
-
-#ifndef __x86_64__
-/* Due to the reordering and the other nifty extensions in i686, it is
-   not really good to use heavily i586 optimized code on an i686.  It's
-   better to use i486 code if it isn't an i586.  */
-# if MINIMUM_ISA == 686
-#  define USE_I586 0
-#  define USE_I686 1
-# else
-#  define USE_I586 (HAS_ARCH_FEATURE (I586) && !HAS_ARCH_FEATURE (I686))
-#  define USE_I686 HAS_ARCH_FEATURE (I686)
-# endif
-#endif
diff --git a/sysdeps/sparc/init-arch.h b/sysdeps/sparc/init-arch.h
new file mode 100644
index 0000000..30972cd
--- /dev/null
+++ b/sysdeps/sparc/init-arch.h
@@ -0,0 +1,23 @@
+/* IFUNC common definition for SPARC64.
+   This file is part of the GNU C Library.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   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 <sys/auxv.h>
+#include <ldsodefs.h>
+
+#define INIT_ARCH()
+#include <ifunc-init.h>
diff --git a/sysdeps/sparc/sparc-ifunc.h b/sysdeps/sparc/sparc-ifunc.h
index 4b1ea00..3d81b52 100644
--- a/sysdeps/sparc/sparc-ifunc.h
+++ b/sysdeps/sparc/sparc-ifunc.h
@@ -162,6 +162,9 @@ END (__##name)
 
 #else	/* __ASSEMBLER__ */
 
+# define sparc_libc_ifunc_redirected(redirected_name, name, expr)	\
+  __ifunc (redirected_name, name, expr(hwcap), int hwcap, INIT_ARCH)
+
 # define sparc_libm_ifunc(name, expr)				\
   __ifunc (name, name, expr, int hwcap, libm_ifunc_init)
 
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile b/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
index 4ad7aff..ca44798 100644
--- a/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
@@ -8,5 +8,6 @@ endif
 
 ifeq ($(subdir),string)
 sysdep_routines += memcpy-ultra3 memcpy-niagara1 memcpy-niagara2 \
-		   memset-niagara1 memcpy-niagara4 memset-niagara4
+		   memset-niagara1 memcpy-niagara4 memset-niagara4 \
+		   memcpy-ultra1
 endif
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-ultra1.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-ultra1.S
new file mode 100644
index 0000000..b56438d
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-ultra1.S
@@ -0,0 +1,35 @@
+/* Default SPARC32 memcpy implementation.
+   Copyright (C) 2017 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/>.  */
+
+#if IS_IN (libc)
+
+# include <sysdep.h>
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)
+# undef weak_alias
+# define weak_alias(x, y)
+# undef libc_hidden_def
+# define libc_hidden_def(name)
+
+# define memcpy __memcpy_ultra1
+# define __mempcpy __mempcpy_ultra1
+
+#endif
+
+#include <sysdeps/sparc/sparc32/sparcv9/memcpy.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.S
deleted file mode 100644
index 14df91e..0000000
--- a/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.S
+++ /dev/null
@@ -1,4 +0,0 @@
-#define ASI_PNF     0x82
-#define ASI_BLK_P   0xf0
-#define XCC icc
-#include <sparc64/multiarch/memcpy.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.c b/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.c
new file mode 100644
index 0000000..369acac
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy.c
@@ -0,0 +1 @@
+#include <sysdeps/sparc/sparc64/multiarch/memcpy.c>
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/mempcpy.c b/sysdeps/sparc/sparc32/sparcv9/multiarch/mempcpy.c
new file mode 100644
index 0000000..616a538
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/mempcpy.c
@@ -0,0 +1 @@
+#include <sysdeps/sparc/sparc64/multiarch/mempcpy.c>
diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-mempcpy.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-mempcpy.S
new file mode 100644
index 0000000..f18c9f9
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-mempcpy.S
@@ -0,0 +1 @@
+/* rtld-mempcpy is implemented by rtld-memcpy.S.  */
diff --git a/sysdeps/sparc/sparc64/multiarch/Makefile b/sysdeps/sparc/sparc64/multiarch/Makefile
index 55b757f..4e52526 100644
--- a/sysdeps/sparc/sparc64/multiarch/Makefile
+++ b/sysdeps/sparc/sparc64/multiarch/Makefile
@@ -8,7 +8,8 @@ endif
 
 ifeq ($(subdir),string)
 sysdep_routines += memcpy-ultra3 memcpy-niagara1 memcpy-niagara2 \
-		   memset-niagara1 memcpy-niagara4 memset-niagara4
+		   memset-niagara1 memcpy-niagara4 memset-niagara4 \
+		   memcpy-ultra1
 endif
 
 ifeq ($(subdir),stdlib)
diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-memcpy.h b/sysdeps/sparc/sparc64/multiarch/ifunc-memcpy.h
new file mode 100644
index 0000000..f497108
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/ifunc-memcpy.h
@@ -0,0 +1,40 @@
+/* Common definition for memcpy and mempcpy implementation.
+   All versions must be listed in ifunc-impl-list.c.
+   Copyright (C) 2017 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>
+
+extern __typeof (REDIRECT_NAME) OPTIMIZE (niagara4) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (niagara2) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (niagara1) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (ultra3) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (ultra1) attribute_hidden;
+
+static inline void *
+IFUNC_SELECTOR (int hwcap)
+{
+  if (hwcap & HWCAP_SPARC_CRYPTO)
+    return OPTIMIZE (niagara4);
+  if (hwcap & HWCAP_SPARC_N2)
+    return OPTIMIZE (niagara2);
+  if (hwcap & HWCAP_SPARC_BLKINIT)
+    return OPTIMIZE (niagara1);
+  if (hwcap & HWCAP_SPARC_ULTRA3)
+    return OPTIMIZE (ultra3);
+  return OPTIMIZE (ultra1);
+}
diff --git a/sysdeps/sparc/sparc64/multiarch/memcpy-ultra1.S b/sysdeps/sparc/sparc64/multiarch/memcpy-ultra1.S
new file mode 100644
index 0000000..1a0aaf3
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/memcpy-ultra1.S
@@ -0,0 +1,35 @@
+/* Default SPARC64 memcpy implementation.
+   Copyright (C) 2017 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/>.  */
+
+#if IS_IN (libc)
+
+# include <sysdep.h>
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)
+# undef weak_alias
+# define weak_alias(x, y)
+# undef libc_hidden_def
+# define libc_hidden_def(name)
+
+# define memcpy __memcpy_ultra1
+# define __mempcpy __mempcpy_ultra1
+
+#endif
+
+#include <sysdeps/sparc/sparc64/memcpy.S>
diff --git a/sysdeps/sparc/sparc64/multiarch/memcpy.S b/sysdeps/sparc/sparc64/multiarch/memcpy.S
deleted file mode 100644
index b6396ee..0000000
--- a/sysdeps/sparc/sparc64/multiarch/memcpy.S
+++ /dev/null
@@ -1,167 +0,0 @@
-/* Multiple versions of memcpy
-   All versions must be listed in ifunc-impl-list.c.
-   Copyright (C) 2010-2017 Free Software Foundation, Inc.
-   Contributed by David S. Miller (davem@davemloft.net)
-   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 <sysdep.h>
-
-#if IS_IN (libc)
-	.text
-ENTRY(memcpy)
-	.type	memcpy, @gnu_indirect_function
-# ifdef SHARED
-	SETUP_PIC_REG_LEAF(o3, o5)
-# endif
-	set	HWCAP_SPARC_CRYPTO, %o1
-	andcc	%o0, %o1, %g0
-	be	1f
-	 andcc	%o0, HWCAP_SPARC_N2, %g0
-# ifdef SHARED
-	sethi	%gdop_hix22(__memcpy_niagara4), %o1
-	xor	%o1, %gdop_lox10(__memcpy_niagara4), %o1
-# else
-	set	__memcpy_niagara4, %o1
-# endif
-	ba	10f
-	 nop
-1:	be	1f
-	 andcc	%o0, HWCAP_SPARC_BLKINIT, %g0
-# ifdef SHARED
-	sethi	%gdop_hix22(__memcpy_niagara2), %o1
-	xor	%o1, %gdop_lox10(__memcpy_niagara2), %o1
-# else
-	set	__memcpy_niagara2, %o1
-# endif
-	ba	10f
-	 nop
-1:	be	1f
-	 andcc	%o0, HWCAP_SPARC_ULTRA3, %g0
-# ifdef SHARED
-	sethi	%gdop_hix22(__memcpy_niagara1), %o1
-	xor	%o1, %gdop_lox10(__memcpy_niagara1), %o1
-# else
-	set	__memcpy_niagara1, %o1
-# endif
-	ba	10f
-	 nop
-1:	be	9f
-	 nop
-# ifdef SHARED
-	sethi	%gdop_hix22(__memcpy_ultra3), %o1
-	xor	%o1, %gdop_lox10(__memcpy_ultra3), %o1
-# else
-	set	__memcpy_ultra3, %o1
-# endif
-	ba	10f
-	 nop
-9:
-# ifdef SHARED
-	sethi	%gdop_hix22(__memcpy_ultra1), %o1
-	xor	%o1, %gdop_lox10(__memcpy_ultra1), %o1
-# else
-	set	__memcpy_ultra1, %o1
-# endif
-10:
-# ifdef SHARED
-	add	%o3, %o1, %o1
-# endif
-	retl
-	 mov	%o1, %o0
-END(memcpy)
-
-ENTRY(__mempcpy)
-	.type	__mempcpy, @gnu_indirect_function
-# ifdef SHARED
-	SETUP_PIC_REG_LEAF(o3, o5)
-# endif
-	set	HWCAP_SPARC_CRYPTO, %o1
-	andcc	%o0, %o1, %g0
-	be	1f
-	 andcc	%o0, HWCAP_SPARC_N2, %g0
-# ifdef SHARED
-	sethi	%gdop_hix22(__mempcpy_niagara4), %o1
-	xor	%o1, %gdop_lox10(__mempcpy_niagara4), %o1
-# else
-	set	__mempcpy_niagara4, %o1
-# endif
-	ba	10f
-	 nop
-1:	be	1f
-	 andcc	%o0, HWCAP_SPARC_BLKINIT, %g0
-# ifdef SHARED
-	sethi	%gdop_hix22(__mempcpy_niagara2), %o1
-	xor	%o1, %gdop_lox10(__mempcpy_niagara2), %o1
-# else
-	set	__mempcpy_niagara2, %o1
-# endif
-	ba	10f
-	 nop
-1:	be	1f
-	 andcc	%o0, HWCAP_SPARC_ULTRA3, %g0
-# ifdef SHARED
-	sethi	%gdop_hix22(__mempcpy_niagara1), %o1
-	xor	%o1, %gdop_lox10(__mempcpy_niagara1), %o1
-# else
-	set	__mempcpy_niagara1, %o1
-# endif
-	ba	10f
-	 nop
-1:	be	9f
-	 nop
-# ifdef SHARED
-	sethi	%gdop_hix22(__mempcpy_ultra3), %o1
-	xor	%o1, %gdop_lox10(__mempcpy_ultra3), %o1
-# else
-	set	__mempcpy_ultra3, %o1
-# endif
-	ba	10f
-	 nop
-9:
-# ifdef SHARED
-	sethi	%gdop_hix22(__mempcpy_ultra1), %o1
-	xor	%o1, %gdop_lox10(__mempcpy_ultra1), %o1
-# else
-	set	__mempcpy_ultra1, %o1
-# endif
-10:
-# ifdef SHARED
-	add	%o3, %o1, %o1
-# endif
-	retl
-	 mov	%o1, %o0
-END(__mempcpy)
-
-libc_hidden_builtin_def (memcpy)
-
-libc_hidden_def (__mempcpy)
-weak_alias (__mempcpy, mempcpy)
-libc_hidden_builtin_def (mempcpy)
-
-#undef libc_hidden_builtin_def
-#define libc_hidden_builtin_def(name)
-#undef weak_alias
-#define weak_alias(x, y)
-#undef libc_hidden_def
-#define libc_hidden_def(name)
-
-#define memcpy __memcpy_ultra1
-#define __mempcpy __mempcpy_ultra1
-
-#endif
-
-#include "../memcpy.S"
diff --git a/sysdeps/sparc/sparc64/multiarch/memcpy.c b/sysdeps/sparc/sparc64/multiarch/memcpy.c
new file mode 100644
index 0000000..2c3d3f3
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/memcpy.c
@@ -0,0 +1,38 @@
+/* Multiple versions of memcpy.
+   All versions must be listed in ifunc-impl-list.c.
+   Copyright (C) 2017 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/>.  */
+
+#if IS_IN (libc)
+# define memcpy __redirect_memcpy
+# include <string.h>
+# undef memcpy
+
+# include <sparc-ifunc.h>
+
+# define SYMBOL_NAME memcpy
+# include "ifunc-memcpy.h"
+
+sparc_libc_ifunc_redirected (__redirect_memcpy, memcpy, IFUNC_SELECTOR);
+
+/* It essentially does libc_hidden_builtin_def (memcpy) and redirect
+   the internal symbol to ifunc implementation.  */
+# ifdef SHARED
+__hidden_ver1 (memcpy, __GI_memcpy, __redirect_memcpy)
+  __attribute__ ((visibility ("hidden")));
+# endif
+#endif
diff --git a/sysdeps/sparc/sparc64/multiarch/mempcpy.c b/sysdeps/sparc/sparc64/multiarch/mempcpy.c
new file mode 100644
index 0000000..f52dca6
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/mempcpy.c
@@ -0,0 +1,47 @@
+/* Multiple versions of memcpy
+   All versions must be listed in ifunc-impl-list.c.
+   Copyright (C) 2017 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/>.  */
+
+#if IS_IN (libc)
+# define mempcpy __redirect_mempcpy
+# define __mempcpy __redirect___mempcpy
+# define NO_MEMPCPY_STPCPY_REDIRECT
+# define __NO_STRING_INLINES
+# include <string.h>
+# undef mempcpy
+# undef __mempcpy
+
+# include <sparc-ifunc.h>
+
+# define SYMBOL_NAME mempcpy
+# include "ifunc-memcpy.h"
+
+sparc_libc_ifunc_redirected (__redirect_mempcpy, __mempcpy, IFUNC_SELECTOR);
+
+weak_alias (__mempcpy, mempcpy)
+
+/* It essentially does libc_hidden_builtin_def (mempcpy) and
+   and libc_hidden_def (__mempcpy) and redirects the internal symbol to
+   ifunc implementation.  */
+# ifdef SHARED
+__hidden_ver1 (__mempcpy, __GI___mempcpy, __redirect___mempcpy)
+  __attribute__ ((visibility ("hidden")));
+__hidden_ver1 (mempcpy, __GI_mempcpy, __redirect_mempcpy)
+  __attribute__ ((visibility ("hidden")));
+# endif
+#endif
diff --git a/sysdeps/sparc/sparc64/multiarch/rtld-mempcpy.S b/sysdeps/sparc/sparc64/multiarch/rtld-mempcpy.S
new file mode 100644
index 0000000..f18c9f9
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/rtld-mempcpy.S
@@ -0,0 +1 @@
+/* rtld-mempcpy is implemented by rtld-memcpy.S.  */
diff --git a/sysdeps/x86/init-arch.h b/sysdeps/x86/init-arch.h
index 15d3f09..9228fe5 100644
--- a/sysdeps/x86/init-arch.h
+++ b/sysdeps/x86/init-arch.h
@@ -21,45 +21,7 @@
 # include <ldsodefs.h>
 #endif
 
-/* These macros are used to implement ifunc selection in C.  To implement
-   an ifunc function, foo, which returns the address of __foo_sse2 or
-   __foo_avx2:
-
-   #define foo __redirect_foo
-   #define __foo __redirect___foo
-   #include <foo.h>
-   #undef foo
-   #undef __foo
-   #define SYMBOL_NAME foo
-   #include <init-arch.h>
-
-   extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2) attribute_hidden;
-   extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden;
-
-   static inline void *
-   foo_selector (void)
-   {
-     if (use AVX2)
-      return OPTIMIZE (avx2);
-
-     return OPTIMIZE (sse2);
-   }
-
-   libc_ifunc_redirected (__redirect_foo, foo, foo_selector ());
-
-*/
-
-#define PASTER1(x,y)	x##_##y
-#define EVALUATOR1(x,y)	PASTER1 (x,y)
-#define PASTER2(x,y)	__##x##_##y
-#define EVALUATOR2(x,y)	PASTER2 (x,y)
-
-/* Basically set '__redirect_<symbol>' to use as type definition,
-   '__<symbol>_<variant>' as the optimized implementation and
-   '<symbol>_ifunc_selector' as the IFUNC selector.  */
-#define REDIRECT_NAME	EVALUATOR1 (__redirect, SYMBOL_NAME)
-#define OPTIMIZE(name)	EVALUATOR2 (SYMBOL_NAME, name)
-#define IFUNC_SELECTOR	EVALUATOR1 (SYMBOL_NAME, ifunc_selector)
+#include <ifunc-init.h>
 
 #ifndef __x86_64__
 /* Due to the reordering and the other nifty extensions in i686, it is

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=5f0dc676fae4a60d1d83a3c7c4e7ae08b9631748

commit 5f0dc676fae4a60d1d83a3c7c4e7ae08b9631748
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Oct 4 17:44:08 2017 -0300

    ARM ifunc implementation

diff --git a/sysdeps/arm/arm-ifunc.h b/sysdeps/arm/arm-ifunc.h
new file mode 100644
index 0000000..f33df50
--- /dev/null
+++ b/sysdeps/arm/arm-ifunc.h
@@ -0,0 +1,22 @@
+/* Common definition for ifunc resolvers.  Linux/ARM version.
+   This file is part of the GNU C Library.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   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 <sysdep.h>
+
+#define arm_libc_ifunc_redirected(redirected_name, name, expr)	\
+  __ifunc (redirected_name, name, expr(hwcap), int hwcap, INIT_ARCH)
diff --git a/sysdeps/arm/armv7/multiarch/Makefile b/sysdeps/arm/armv7/multiarch/Makefile
index 9e1e61c..0c94cd9 100644
--- a/sysdeps/arm/armv7/multiarch/Makefile
+++ b/sysdeps/arm/armv7/multiarch/Makefile
@@ -1,3 +1,7 @@
 ifeq ($(subdir),string)
-sysdep_routines += memcpy_neon memcpy_vfp memchr_neon
+sysdep_routines += memcpy_neon memcpy_vfp memchr_neon memcpy_arm
+
+# For ifunc resolvers compiler might place the alias from generic
+# symbol-hacks.h before the resolver implementation itself.
+CFLAGS-.os += #-DNO_MEM_INTERAL_SYM_HACKS
 endif
diff --git a/sysdeps/arm/armv7/multiarch/ifunc-memcpy.h b/sysdeps/arm/armv7/multiarch/ifunc-memcpy.h
new file mode 100644
index 0000000..9b8f2d6
--- /dev/null
+++ b/sysdeps/arm/armv7/multiarch/ifunc-memcpy.h
@@ -0,0 +1,40 @@
+/* Common definition for memcpy and mempcpy implementation.
+   All versions must be listed in ifunc-impl-list.c.
+   Copyright (C) 2017 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>
+ 
+#ifdef __SOFTFP__
+extern __typeof (REDIRECT_NAME) OPTIMIZE (arm) attribute_hidden;
+#endif
+extern __typeof (REDIRECT_NAME) OPTIMIZE (vfp) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (neon) attribute_hidden;
+
+static inline void *
+IFUNC_SELECTOR (int hwcap)
+{
+  if (hwcap & HWCAP_ARM_NEON)
+    return OPTIMIZE (neon);
+#ifdef __SOFTFP__
+  if (hwcap & HWCAP_ARM_VFP)
+    return OPTIMIZE (vfp);
+  return OPTIMIZE (arm);
+#else
+  return OPTIMIZE (vfp);
+#endif
+}
diff --git a/sysdeps/arm/armv7/multiarch/init-arch.h b/sysdeps/arm/armv7/multiarch/init-arch.h
new file mode 100644
index 0000000..f092e92
--- /dev/null
+++ b/sysdeps/arm/armv7/multiarch/init-arch.h
@@ -0,0 +1,21 @@
+/* Define INIT_ARCH for Linux/ARM.
+   This file is part of the GNU C Library.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   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 <ifunc-init.h>
+
+#define INIT_ARCH()
diff --git a/sysdeps/arm/armv7/multiarch/memcpy.S b/sysdeps/arm/armv7/multiarch/memcpy.S
deleted file mode 100644
index 8a53bda..0000000
--- a/sysdeps/arm/armv7/multiarch/memcpy.S
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Multiple versions of memcpy
-   All versions must be listed in ifunc-impl-list.c.
-   Copyright (C) 2013-2017 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/>.  */
-
-/* Thumb requires excess IT instructions here.  */
-#define NO_THUMB
-#include <sysdep.h>
-#include <rtld-global-offsets.h>
-
-#if IS_IN (libc)
-/* Under __ARM_NEON__, memcpy_neon.S defines the name memcpy.  */
-# ifndef __ARM_NEON__
-	.text
-ENTRY(memcpy)
-	.type	memcpy, %gnu_indirect_function
-# ifdef __SOFTFP__
-	ldr	r1, .Lmemcpy_arm
-	tst	r0, #HWCAP_ARM_VFP
-	ldrne	r1, .Lmemcpy_vfp
-# else
-	ldr	r1, .Lmemcpy_vfp
-# endif
-	tst	r0, #HWCAP_ARM_NEON
-	ldrne	r1, .Lmemcpy_neon
-1:
-	add	r0, r1, pc
-	DO_RET(lr)
-
-# ifdef __SOFTFP__
-.Lmemcpy_arm:
-	.long	C_SYMBOL_NAME(__memcpy_arm) - 1b - PC_OFS
-# endif
-.Lmemcpy_neon:
-	.long	C_SYMBOL_NAME(__memcpy_neon) - 1b - PC_OFS
-.Lmemcpy_vfp:
-	.long	C_SYMBOL_NAME(__memcpy_vfp) - 1b - PC_OFS
-
-END(memcpy)
-
-libc_hidden_builtin_def (memcpy)
-#endif  /* Not __ARM_NEON__.  */
-
-/* These versions of memcpy are defined not to clobber any VFP or NEON
-   registers so they must always call the ARM variant of the memcpy code.  */
-strong_alias (__memcpy_arm, __aeabi_memcpy)
-strong_alias (__memcpy_arm, __aeabi_memcpy4)
-strong_alias (__memcpy_arm, __aeabi_memcpy8)
-libc_hidden_def (__memcpy_arm)
-
-#undef libc_hidden_builtin_def
-#define libc_hidden_builtin_def(name)
-#undef weak_alias
-#define weak_alias(x, y)
-#undef libc_hidden_def
-#define libc_hidden_def(name)
-
-#define memcpy __memcpy_arm
-
-#endif
-
-#include "memcpy_impl.S"
diff --git a/sysdeps/arm/armv7/multiarch/memcpy.c b/sysdeps/arm/armv7/multiarch/memcpy.c
new file mode 100644
index 0000000..3ffa212
--- /dev/null
+++ b/sysdeps/arm/armv7/multiarch/memcpy.c
@@ -0,0 +1,41 @@
+/* Multiple versions of memcpy.
+   All versions must be listed in ifunc-impl-list.c.
+   Copyright (C) 2017 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/>.  */
+
+#if IS_IN (libc)
+# define memcpy __redirect_memcpy
+# include <string.h>
+# undef memcpy
+
+# include <arm-ifunc.h>
+
+# define SYMBOL_NAME memcpy
+# include "ifunc-memcpy.h"
+
+arm_libc_ifunc_redirected (__redirect_memcpy, memcpy, IFUNC_SELECTOR);
+
+/* It essentially does libc_hidden_builtin_def (memcpy) and redirect
+   the internal symbol to ifunc implementation.  It is using direct
+   assembly directives because ifunc attribute is not enabled by default
+   on ARM.  */
+# ifdef SHARED
+asm (".globl __GI_memcpy;"
+     ".hidden __GI_memcpy;"
+     "__GI_memcpy = memcpy");
+# endif
+#endif
diff --git a/sysdeps/arm/armv7/multiarch/memcpy_arm.S b/sysdeps/arm/armv7/multiarch/memcpy_arm.S
new file mode 100644
index 0000000..37565cd
--- /dev/null
+++ b/sysdeps/arm/armv7/multiarch/memcpy_arm.S
@@ -0,0 +1,6 @@
+#define memcpy __memcpy_arm
+#include "memcpy_impl.S"
+
+strong_alias (__memcpy_arm, __aeabi_memcpy)
+strong_alias (__memcpy_arm, __aeabi_memcpy4)
+strong_alias (__memcpy_arm, __aeabi_memcpy8)
diff --git a/sysdeps/arm/armv7/multiarch/rtld-memcpy.S b/sysdeps/arm/armv7/multiarch/rtld-memcpy.S
new file mode 100644
index 0000000..0190edc
--- /dev/null
+++ b/sysdeps/arm/armv7/multiarch/rtld-memcpy.S
@@ -0,0 +1 @@
+#include <./sysdeps/arm/armv7/multiarch/memcpy_impl.S>
diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h
index d614c09..589585a 100644
--- a/sysdeps/generic/symbol-hacks.h
+++ b/sysdeps/generic/symbol-hacks.h
@@ -1,6 +1,7 @@
 /* Some compiler optimizations may transform loops into memset/memmove
    calls and without proper declaration it may generate PLT calls.  */
-#if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED
+#if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED \
+    && !defined(NO_MEM_INTERAL_SYM_HACKS)
 asm ("memmove = __GI_memmove");
 asm ("memset = __GI_memset");
 asm ("memcpy = __GI_memcpy");

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]