]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86-64: Implement wcscpy IFUNC selector in C
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 15 Jun 2017 15:57:39 +0000 (08:57 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 15 Jun 2017 15:57:52 +0000 (08:57 -0700)
* sysdeps/x86_64/multiarch/wcscpy.S: Removed.
* sysdeps/x86_64/multiarch/wcscpy.c: New file.

ChangeLog
sysdeps/x86_64/multiarch/wcscpy.c [moved from sysdeps/x86_64/multiarch/wcscpy.S with 58% similarity]

index 241ef2ba5eab14e53b5f4d0439320e612ac3b164..bf791fcc438fe0837017048a6cc8103999c7b0a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-15  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * sysdeps/x86_64/multiarch/wcscpy.S: Removed.
+       * sysdeps/x86_64/multiarch/wcscpy.c: New file.
+
 2017-06-15  H.J. Lu  <hongjiu.lu@intel.com>
 
        * sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
similarity index 58%
rename from sysdeps/x86_64/multiarch/wcscpy.S
rename to sysdeps/x86_64/multiarch/wcscpy.c
index 9150ab6d18c69aefab0d35c2a43751d285574ace..01dee8054ae6802e46ec856865e11705e9cd1c7d 100644 (file)
@@ -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
    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