public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86-64: Implement wcscpy IFUNC selector in C
@ 2017-06-12 16:11 H.J. Lu
  2017-06-15 15:33 ` Adhemerval Zanella
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2017-06-12 16:11 UTC (permalink / raw)
  To: GNU C Library

Any comments?

H.J.
	* sysdeps/x86_64/multiarch/wcscpy.S: Removed.
	* sysdeps/x86_64/multiarch/wcscpy.c: New file.
---
 sysdeps/x86_64/multiarch/{wcscpy.S => wcscpy.c} | 37 ++++++++++++++-----------
 1 file changed, 21 insertions(+), 16 deletions(-)
 rename sysdeps/x86_64/multiarch/{wcscpy.S => wcscpy.c} (59%)

diff --git a/sysdeps/x86_64/multiarch/wcscpy.S b/sysdeps/x86_64/multiarch/wcscpy.c
similarity index 59%
rename from sysdeps/x86_64/multiarch/wcscpy.S
rename to sysdeps/x86_64/multiarch/wcscpy.c
index 9150ab6..104ee00 100644
--- a/sysdeps/x86_64/multiarch/wcscpy.S
+++ b/sysdeps/x86_64/multiarch/wcscpy.c
@@ -1,6 +1,6 @@
-/* Multiple versions of wcscpy
+/* Multiple versions of wcscpy.
    All versions must be listed in ifunc-impl-list.c.
-   Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   Copyright (C) 2017 Free Software Foundation, Inc.
    Contributed by Intel Corporation.
    This file is part of the GNU C Library.
 
@@ -18,23 +18,28 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdep.h>
-#include <init-arch.h>
-
 /* Define multiple versions only for the definition in libc. */
 #if IS_IN (libc)
+# define wcscpy __redirect_wcscpy
+# include <wchar.h>
+# undef wcscpy
+
+# define SYMBOL_NAME wcscpy
+# include <init-arch.h>
+
+extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (ssse3) attribute_hidden;
+
+static inline void *
+IFUNC_SELECTOR (void)
+{
+  const struct cpu_features* cpu_features = __get_cpu_features ();
 
-	.text
-ENTRY(wcscpy)
-	.type	wcscpy, @gnu_indirect_function
-	LOAD_RTLD_GLOBAL_RO_RDX
-	HAS_CPU_FEATURE (SSSE3)
-	jnz	2f
-	leaq	__wcscpy_sse2(%rip), %rax
-	ret
+  if (CPU_FEATURES_CPU_P (cpu_features, SSSE3))
+    return OPTIMIZE (ssse3);
 
-2:	leaq	__wcscpy_ssse3(%rip), %rax
-	ret
+  return OPTIMIZE (sse2);
+}
 
-END(wcscpy)
+libc_ifunc_redirected (__redirect_wcscpy, wcscpy, IFUNC_SELECTOR ());
 #endif
-- 
2.9.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86-64: Implement wcscpy IFUNC selector in C
  2017-06-12 16:11 [PATCH] x86-64: Implement wcscpy IFUNC selector in C H.J. Lu
@ 2017-06-15 15:33 ` Adhemerval Zanella
  0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella @ 2017-06-15 15:33 UTC (permalink / raw)
  To: libc-alpha



On 12/06/2017 13:11, H.J. Lu wrote:
> Any comments?
> 
> H.J.
> 	* sysdeps/x86_64/multiarch/wcscpy.S: Removed.
> 	* sysdeps/x86_64/multiarch/wcscpy.c: New file.

LGTM.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-15 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-12 16:11 [PATCH] x86-64: Implement wcscpy IFUNC selector in C H.J. Lu
2017-06-15 15:33 ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).