From patchwork Mon Jun 12 16:11:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lu, Hongjiu" X-Patchwork-Id: 20953 Received: (qmail 48796 invoked by alias); 12 Jun 2017 16:11:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 48136 invoked by uid 89); 12 Jun 2017 16:11:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, NO_DNS_FOR_FROM, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=corporation X-HELO: mga05.intel.com X-ExtLoop1: 1 Date: Mon, 12 Jun 2017 09:11:34 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] x86-64: Implement wcscpy IFUNC selector in C Message-ID: <20170612161134.GE25262@gmail.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.0 (2017-02-23) 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 . */ -#include -#include - /* Define multiple versions only for the definition in libc. */ #if IS_IN (libc) +# define wcscpy __redirect_wcscpy +# include +# undef wcscpy + +# define SYMBOL_NAME wcscpy +# include + +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