about summary refs log tree commit diff
path: root/sysdeps/x86_64
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-06-15 08:57:39 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-06-15 08:57:52 -0700
commit9f4254b8bd1b948c3a90e48a126236bf3e5e70a0 (patch)
tree2ae35f450d620168037021810d2ec57230ae609b /sysdeps/x86_64
parent9ed0aa15d316fb30e056d3a2e8f3361460c67e78 (diff)
downloadglibc-9f4254b8bd1b948c3a90e48a126236bf3e5e70a0.tar.gz
glibc-9f4254b8bd1b948c3a90e48a126236bf3e5e70a0.tar.xz
glibc-9f4254b8bd1b948c3a90e48a126236bf3e5e70a0.zip
x86-64: Implement wcscpy IFUNC selector in C
	* sysdeps/x86_64/multiarch/wcscpy.S: Removed.
	* sysdeps/x86_64/multiarch/wcscpy.c: New file.
Diffstat (limited to 'sysdeps/x86_64')
-rw-r--r--sysdeps/x86_64/multiarch/wcscpy.c (renamed from sysdeps/x86_64/multiarch/wcscpy.S)38
1 files changed, 21 insertions, 17 deletions
diff --git a/sysdeps/x86_64/multiarch/wcscpy.S b/sysdeps/x86_64/multiarch/wcscpy.c
index 9150ab6d18..01dee8054a 100644
--- a/sysdeps/x86_64/multiarch/wcscpy.S
+++ b/sysdeps/x86_64/multiarch/wcscpy.c
@@ -1,7 +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.
-   Contributed by Intel Corporation.
+   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
@@ -18,23 +17,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