From patchwork Tue Jun 12 22:19:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 928524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-93121-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="D2rAIl3y"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4154BP1Hsgz9s0W for ; Wed, 13 Jun 2018 08:22:20 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=k2A/yLaXjUr/eqsjOku7IjCeaEBVEBH 6ATKohHJPFBHhOga7rDG0gzvVaoF3f50vmtYaBJVtu9+LW4s08esuYKg2XPWEyRk 0wGanvdMRqo9x8zl3UB4gZUWS9gu5ozSu5W2kzEPuRQWEfP7YetscAG8q6nvSWjG 5JMiGVFeSN8U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=GAxoxezsIm1GuZhFyDBgJnQzBMI=; b=D2rAI l3y3/Aqa56qw5Qsopbrg3FQ1SZvm0l3z5Wm3zO1MQ1jow9XQC+aF3jYbywOYtKB+ kpUAtOzS8H2PTCwRu9NHfADq6uI1cAJAYB8jK8uEb7vgwOERI7zQf3pxpy4AvCgU 96mQGMtnqGrzOuSbaA6LPbjemaj9rGAsPkSFoI= Received: (qmail 94158 invoked by alias); 12 Jun 2018 22:20:05 -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 93049 invoked by uid 89); 12 Jun 2018 22:19:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, KAM_STOCKGEN, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy= X-HELO: mga01.intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH 16/20] libcpu-rt-c/x86-64: Add strnlen Date: Tue, 12 Jun 2018 15:19:35 -0700 Message-Id: <20180612221939.19545-17-hjl.tools@gmail.com> In-Reply-To: <20180612221939.19545-1-hjl.tools@gmail.com> References: <20180612221939.19545-1-hjl.tools@gmail.com> * sysdeps/x86_64/Makefile (cpu-rt-c-routines): Add strnlen. * sysdeps/x86_64/multiarch/Makefile (libcpu-rt-c-sysdep_routines): Add strnlen-sse2 and strnlen-avx2. * sysdeps/x86_64/multiarch/strnlen-sse2.S: Support libcpu-rt-c. * sysdeps/x86_64/multiarch/strnlen.c: Likewise. --- sysdeps/x86_64/Makefile | 2 +- sysdeps/x86_64/multiarch/Makefile | 3 ++- sysdeps/x86_64/multiarch/strnlen-sse2.S | 2 +- sysdeps/x86_64/multiarch/strnlen.c | 20 ++++++++++++++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index ea0d7a31dc..1a5720bbac 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -148,7 +148,7 @@ endif ifeq ($(subdir),cpu-rt-c) cpu-rt-c-routines += memchr memcmp memcpy memmove mempcpy memrchr \ - memset strcat strchr strcmp strcpy strlen \ + memset strcat strchr strcmp strcpy strlen strnlen \ wmemset # For the CPU run-time tests. diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile index 10de1f3af3..1c902eec4e 100644 --- a/sysdeps/x86_64/multiarch/Makefile +++ b/sysdeps/x86_64/multiarch/Makefile @@ -88,5 +88,6 @@ libcpu-rt-c-sysdep_routines += memchr-sse2 memchr-avx2 \ strcmp-sse2-unaligned strcmp-ssse3 \ strcmp-sse4_2 strcmp-avx2 strcpy-sse2 \ strcpy-sse2-unaligned strcpy-ssse3 \ - strlen-sse2 strlen-avx2 + strlen-sse2 strlen-avx2 \ + strnlen-sse2 strnlen-avx2 endif diff --git a/sysdeps/x86_64/multiarch/strnlen-sse2.S b/sysdeps/x86_64/multiarch/strnlen-sse2.S index 41f33f6f6f..a5cba9a698 100644 --- a/sysdeps/x86_64/multiarch/strnlen-sse2.S +++ b/sysdeps/x86_64/multiarch/strnlen-sse2.S @@ -16,7 +16,7 @@ License along with the GNU C Library; if not, see . */ -#if IS_IN (libc) +#if IS_IN (libc) || IS_IN (libcpu_rt_c) # define __strnlen __strnlen_sse2 # undef weak_alias diff --git a/sysdeps/x86_64/multiarch/strnlen.c b/sysdeps/x86_64/multiarch/strnlen.c index 3ab94ce230..5752764d2b 100644 --- a/sysdeps/x86_64/multiarch/strnlen.c +++ b/sysdeps/x86_64/multiarch/strnlen.c @@ -18,7 +18,7 @@ . */ /* Define multiple versions only for the definition in libc. */ -#if IS_IN (libc) +#if IS_IN (libc) || IS_IN (libcpu_rt_c) # define strnlen __redirect_strnlen # define __strnlen __redirect___strnlen # include @@ -28,12 +28,28 @@ # define SYMBOL_NAME strnlen # include "ifunc-avx2.h" +#if IS_IN (libcpu_rt_c) +# define __strnlen strnlen +#endif + libc_ifunc_redirected (__redirect_strnlen, __strnlen, IFUNC_SELECTOR ()); + +# if IS_IN (libcpu_rt_c) +# ifdef SHARED +__hidden_ver1 (strnlen, __strnlen, __redirect___strnlen) + __attribute__((visibility ("hidden"))); +# else +# undef __strnlen +/* Needed by strncpy-c.o. */ +strong_alias (strnlen, __strnlen); +# endif +# else +# ifdef SHARED weak_alias (__strnlen, strnlen); -# ifdef SHARED __hidden_ver1 (__strnlen, __GI___strnlen, __redirect___strnlen) __attribute__((visibility ("hidden"))); __hidden_ver1 (strnlen, __GI_strnlen, __redirect_strnlen) __attribute__((weak, visibility ("hidden"))); +# endif # endif #endif