From patchwork Thu Oct 12 21:09:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 115679 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2376161qgn; Thu, 12 Oct 2017 14:10:30 -0700 (PDT) X-Received: by 10.101.83.140 with SMTP id x12mr617066pgq.425.1507842630262; Thu, 12 Oct 2017 14:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507842630; cv=none; d=google.com; s=arc-20160816; b=fN0qVM/dP3wZ0ipqCBzIeSLNOeM5Z3G2EJlNOdmE+AIzLexAUlgC5KtvD3W3JgODuS PRrw0RY0cxqgSVo4cOhqSOWCxggBxIgGK6bkDk3dNSy9UBVglFAiDw6ibCE2yY27Ccb0 hrgJrGV606xiJxc/R0fOqG8tx83h3nXCc/H/mSAtxP9lXCcRCsDDJ3h0PU+1CLN69HB3 nuefKC6reOd0/Kw5yLTaoZBTtrTYlvHkOpm6EoR92Si5UK2ynAUIylVw6MqmXKf/cvNw lJq0Hwu5eo+Ua9gFXBNkFE76YQb3xowfXGTJoxEDDISSiHu1MC/qLoGtA2r+/NjjOZb+ JyiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=othSC5QcrvKtS2BX1hBUJaqN5Bc0g4zVbgg9KfxTK8A=; b=Jw9mPb1krM8M9z4Gr2K2idLMOCzURo8fx5jGvYMUi12TjIjtlpk6i6jjE0wHZH7u/C qcledgu8USxYdAaIQkTNDU1m267X+lsRycckz1u8SNBsFsrfWLxp2lfybebmIgDnissF ZIKemSBrktPmiSXxzbVzVvdrZmc/uGBcUUPpJ5idO5m1ZIMCgQdVXALg3LZSV5NAPl2q D8aC2DHq1BdgPUIREHgTjTH7sIs8yQR43dO1S/HvIRsofw1zP9xwRNuL0gM/wjjAo1cr Mg1LhemTily2SQBkB/8pPA2v7vuOP/a+0HklymDHyotRAGyEmOlMqm054MTtlopcYRyx tg1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ro5H8SLh; spf=pass (google.com: domain of libc-alpha-return-85764-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85764-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 9si2029545pfw.188.2017.10.12.14.10.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 14:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-85764-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ro5H8SLh; spf=pass (google.com: domain of libc-alpha-return-85764-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85764-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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; q=dns; s= default; b=rijNccNRbBJzp15FzrGls6es9hSrg1gG9AaRL5d1nE4yqrKxEY0eh aV5ey4ETfKZ2seSImtoYQFUT6TI7EgCXAwIRxOU8HkcLyvP+WpPJUIfNY0i2ltAF rTBAjFvCWBFmDtHHZ6BURvI8vYLoKN7vOPgkND8w9Ga2oi2BcINeZE= 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; s=default; bh=0KZRP9tBPcsLprkuwNFjoO0iFZ8=; b=ro5H8SLhtVV4DibVboEDgNF+d6Ns BL9Fggkcf4NZ1SiW059AQsStyYmmaF4UO5DrmDV8B6L6dxydecezYg5gVlbUoLdy GqxvHeSGYkOKb4tyN13w9xDh4TVQWRROfzjphC8/pE73Bypp9c3JdSGro8ZI2AYK Sx2blJ+Un+Z8TxM= Received: (qmail 102578 invoked by alias); 12 Oct 2017 21:10:03 -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 101943 invoked by uid 89); 12 Oct 2017 21:10:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3838, 6346 X-HELO: mail-qk0-f170.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=othSC5QcrvKtS2BX1hBUJaqN5Bc0g4zVbgg9KfxTK8A=; b=q50N0JzBlyUceE6H5NDt0bkbLEbp2PYFPQ6nYvyn+Ue3NOvAbIpsKx55MgEUXe2DC4 oKpEsF9BWo8b5XOBECJnFTGbjDzKgBgYKDOkaRgQ/hgyUzp7VpGqXViBCPrlicJpW0PQ Xbv3nq9vThOqW1TsJ/HP1DIW9RFJoWh+rEziPi3p8+zPGaC8DcN3V1vxXzh+/AEVsszT ePvnTFlUb3QFPOAalUSeEkxKiYGlQijK+qkvtcMFN/BEpFdg54GCZbKX8X63Kw3AIHSZ lrtB5evv+wws1brnzih5ylGJn8uhjrR9JTxqhosVCT0MMMmm92tpKaOXPCxmlWYOq0ab jfSw== X-Gm-Message-State: AMCzsaUzO4pig2TJJyKOM3meBUQUXYlVoDNPgM7LH/P4QofCxs/5K8Oc k5sag2ova+GI9m1drXowhcx/CFS+C3k= X-Google-Smtp-Source: AOwi7QCQdkgbpv7gSJArpoljF8RnmKj6UBNBeZLTNwd/DhkBuE+eSeCK+f2acJFCf5tQ5nxP7mC40A== X-Received: by 10.55.98.205 with SMTP id w196mr2529951qkb.322.1507842594437; Thu, 12 Oct 2017 14:09:54 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/5] Avoid build multiarch if compiler warns about mismatched alias Date: Thu, 12 Oct 2017 18:09:40 -0300 Message-Id: <1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org> GCC 8 emits a warning for alias for functions with incompatible types and it is used extensivelly for ifunc resolvers implementations in C (for instance on weak_alias with the internal symbol name to the external one or with the libc_hidden_def to set ifunc for internal usage). This breaks the build when the ifunc resolver is not defined using gcc attribute extensions (HAVE_GCC_IFUNC being 0). Although for all currently architectures that have multiarch support this compiler options is enabled for default, there is still the option where the user might try build glibc with a compiler without support for such extension. In this case this patch just disable the multiarch folder in sysdeps selections. GCC 7 and before still builds IFUNCs regardless of compiler support (although for the lack of attribute support debug information would be optimal). The patch also fixes the default value of the multiarch support in configure.ac (the correct value which is tested later in the script assumes 'yes' instead of 'default'). Checked with a build on multiarch support architectures (aarch64,a arm, sparc, s390, powerpc, x86_64, i386) with multiarch enable and disable and with GCC 7 and GCC 8. * configure.ac (multi_arch): Use 'yes' as default value. (libc_cv_gcc_incompatbile_alias): New define: indicates whether compiler emits an warning for alias for functions with incompatible types. --- ChangeLog | 7 +++++++ configure | 39 ++++++++++++++++++++++++++++++++++++++- configure.ac | 31 ++++++++++++++++++++++++++++++- 3 files changed, 75 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/configure.ac b/configure.ac index 195e81a..647aaa6 100644 --- a/configure.ac +++ b/configure.ac @@ -304,7 +304,7 @@ AC_ARG_ENABLE([multi-arch], AC_HELP_STRING([--enable-multi-arch], [enable single DSO with optimizations for multiple architectures]), [multi_arch=$enableval], - [multi_arch=default]) + [multi_arch=yes]) AC_ARG_ENABLE([experimental-malloc], AC_HELP_STRING([--disable-experimental-malloc], @@ -634,6 +634,26 @@ if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \ fi rm -f conftest*]) +# Check if gcc warns about alias for function with incompatible types. +AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types], + libc_cv_gcc_incompatible_alias, [dnl +cat > conftest.c <&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then + libc_cv_gcc_incompatible_alias=no +fi +rm -f conftest*]) + if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then if test x"$multi_arch" = xyes; then AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support]) @@ -645,6 +665,15 @@ if test x"$libc_cv_gcc_indirect_function" != xyes && test x"$multi_arch" = xyes; then AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support. Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function]) + # GCC 8+ emits and warning for alias with incompatible types and thus fail + # to build ifunc resolvers aliases to either weak or internal symbols. + # Disables multiarch build in this case. + if test x"$libc_cv_gcc_incompatible_alias" == xyes && + test x"$enable_werror" == xyes; then + AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types +and -Werror is enabled. Multi-arch is disabled. ]) + multi_arch=no + fi fi multi_arch_d= if test x"$multi_arch" != xno; then From patchwork Thu Oct 12 21:09:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 115677 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2375914qgn; Thu, 12 Oct 2017 14:10:12 -0700 (PDT) X-Received: by 10.101.74.206 with SMTP id c14mr1223153pgu.190.1507842612004; Thu, 12 Oct 2017 14:10:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507842611; cv=none; d=google.com; s=arc-20160816; b=QPixEIwY3N2UXhiEAEE5DMjBTSbW3QRRumQqo3fpfUK+Pp/7vdTKHG90I8fEVGSTsk RVr2Ha0eF7sb4sF6qdLxIx6BJZXkwkx1VHEREb9U2gROBzGKqCRa3PJjxb74f8aGAuzB 266dp10NU/Ab0/htObof7/6uTgIMMN39QtX48gHeWl4f7N/tFa0KOZV3fAuevY/LBlPM ZfzW2RCYgnRlZNEuDz7XwWm1Mt9e6Hb4zKhZv7cOn3fn2+qeSda3SqR8s4E1EW6trsNN eWSlq52zwUHZ9mAD2q6S8GOUeCR9kTV5iVc26XmSPTQ5bfBtUPS6Z1wNdqdgKUd0BDz2 as0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=5kEURYOBurK4Mr6IshlbtMncrbM4NhieFCwzyhi6dQo=; b=sv2K1De0l6dRLrD+pnIx/N+w9pjfI/0GCIRennPw9D2z4SBuBCAA2tAh/+3nzTahdD G84G5YJthqEWA0pNOVGChsXkwTYZ10SB480OqMu8swu44fVuJL6QG+hTyMTuIB8+6UjD LfWsyqmNb4Vv+BHMihT5YcKeqWHyFIC2PrEt+2wNOzOQ4uxRlk5844EQLpArmZTzJs+d g3wIy9pu5QjDQAAbD++28K7yQT7j5toOKEvHx8r1ym/lsUMxRNXopAPoxmMjd1947XvH ATwq8obDxT3htce3G+vxBx+z9ReVmQQOLwqDrhMa5H4lIoXSQmEvN6ewGMAPZ25Fux6s SliQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=IQcMiQXb; spf=pass (google.com: domain of libc-alpha-return-85762-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85762-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id i1si11155506pfi.590.2017.10.12.14.10.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 14:10:11 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-85762-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=IQcMiQXb; spf=pass (google.com: domain of libc-alpha-return-85762-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85762-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=PU2nKhi1EcymQ//dmwz5Dho72vCOQfC KgPVmswL2oc5HOPf8gCBVAQ3F9EVuz72XyLFJ6RLewe8juXPhbVViy3lWdH8Y3vW 9RcYH/IDyCZkJot2+/LZFsuDtdIElA/g0bjLPewKgPvF/TwSrnibylc7c49luUX9 qiSxOVNu4W0Y= 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=foUOTTPcZBjsXXMKBB9VHuc27jE=; b=IQcMi QXbuZT0q5NMR6F7V/5bu/6IFFB3DZp6uhGqdFrSES7ZmgLOCIoul+AkNkOwB0E7l SjNEL6cciDQ+nlvuW+TagoHSPZQRZ8p0RZqZ5q2fX6PBjWf1yQlGWU53O3xDqYwl QA/opK+QFkDdgFepOmCgJZNt1Fo23M8Rv8Zn2g= Received: (qmail 101088 invoked by alias); 12 Oct 2017 21:09:59 -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 100430 invoked by uid 89); 12 Oct 2017 21:09:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=2046, nifty X-HELO: mail-qk0-f177.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=5kEURYOBurK4Mr6IshlbtMncrbM4NhieFCwzyhi6dQo=; b=bJX4uhpecI7OoDS6do9bZ9G+/fL4+CUbOYoobn9sAuNz4buHn6vo1zm+siSxyMj+HQ JXh4G4w6ir4k5/T0n90yGVGf0dCJ9aj2vOnTr7e9/KvPYlXLn1C11mEUxo6y4s+p5q2b 4GSbcS+adhIx3p8aoNnrHGzszRorirLg1fGXBibp/lMdMuOqEulqQBVC9tDKhw6/Z7uz xRE4WmIfmd0wL96e+3eiDtJgOB26Nd3my2M2M2c7adq31vEZ4LtD2kpoViRiSma17RXv jWbsGgxUVjEnQCsc2lpMWlXVlWbGy2E0GQScqOGQiwy2ALu4YKuEFm6/YcIWl3dr0oOx XJ/g== X-Gm-Message-State: AMCzsaXIfZoX5YwxAFDe+xIS5toQb5qqGHFl9UnF2h/Ypwikeki5hk8P Z2LJI2d6HTQ/KnaLt00mPjumkSYiRps= X-Google-Smtp-Source: ABhQp+Si6losbiWPDSxwnVbHzb/IX8H6mO/vWxl+RG/Ok9VSjNaSHRc71qoWjo/e65pAfndrOypFrw== X-Received: by 10.55.22.146 with SMTP id 18mr2449044qkw.281.1507842595826; Thu, 12 Oct 2017 14:09:55 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/5] Add common ifunc-init.h header Date: Thu, 12 Oct 2017 18:09:41 -0300 Message-Id: <1507842584-28674-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org> References: <1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org> This patch moves the generic definition from x86_64 init-arch to a common header ifunc-init.h. No functional changes is expected. Checked on a x86_64-linux-gnu build. * sysdeps/generic/ifunc-init.h: New file. * sysdeps/x86/init-arch.h: Use generic ifunc-init.h. --- ChangeLog | 3 +++ sysdeps/generic/ifunc-init.h | 54 ++++++++++++++++++++++++++++++++++++++++++++ sysdeps/x86/init-arch.h | 41 +-------------------------------- 3 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 sysdeps/generic/ifunc-init.h -- 2.7.4 diff --git a/sysdeps/generic/ifunc-init.h b/sysdeps/generic/ifunc-init.h new file mode 100644 index 0000000..59d5ac6 --- /dev/null +++ b/sysdeps/generic/ifunc-init.h @@ -0,0 +1,54 @@ +/* IFUNC generic definitions. + This file is part of the GNU C Library. + Copyright (C) 2017 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* These macros are used to implement ifunc selection in C. To implement + an ifunc function, foo, which returns the address of __foo_impl1 or + __foo_impl2: + + #define foo __redirect_foo + #include + #undef foo + #define SYMBOL_NAME foo + #include + + extern __typeof (REDIRECT_NAME) OPTIMIZE (impl1) attribute_hidden; + extern __typeof (REDIRECT_NAME) OPTIMIZE (impl2) attribute_hidden; + + static inline void * + foo_selector (void) + { + if (condition) + return OPTIMIZE (impl2); + + return OPTIMIZE (impl1); + } + + libc_ifunc_redirected (__redirect_foo, foo, IFUNC_SELECTOR ()); +*/ + +#define PASTER1(x,y) x##_##y +#define EVALUATOR1(x,y) PASTER1 (x,y) +#define PASTER2(x,y) __##x##_##y +#define EVALUATOR2(x,y) PASTER2 (x,y) + +/* Basically set '__redirect_' to use as type definition, + '___' as the optimized implementation and + '_ifunc_selector' as the IFUNC selector. */ +#define REDIRECT_NAME EVALUATOR1 (__redirect, SYMBOL_NAME) +#define OPTIMIZE(name) EVALUATOR2 (SYMBOL_NAME, name) +#define IFUNC_SELECTOR EVALUATOR1 (SYMBOL_NAME, ifunc_selector) diff --git a/sysdeps/x86/init-arch.h b/sysdeps/x86/init-arch.h index 15d3f09..06a21cc 100644 --- a/sysdeps/x86/init-arch.h +++ b/sysdeps/x86/init-arch.h @@ -20,46 +20,7 @@ #else # include #endif - -/* These macros are used to implement ifunc selection in C. To implement - an ifunc function, foo, which returns the address of __foo_sse2 or - __foo_avx2: - - #define foo __redirect_foo - #define __foo __redirect___foo - #include - #undef foo - #undef __foo - #define SYMBOL_NAME foo - #include - - extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2) attribute_hidden; - extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden; - - static inline void * - foo_selector (void) - { - if (use AVX2) - return OPTIMIZE (avx2); - - return OPTIMIZE (sse2); - } - - libc_ifunc_redirected (__redirect_foo, foo, foo_selector ()); - -*/ - -#define PASTER1(x,y) x##_##y -#define EVALUATOR1(x,y) PASTER1 (x,y) -#define PASTER2(x,y) __##x##_##y -#define EVALUATOR2(x,y) PASTER2 (x,y) - -/* Basically set '__redirect_' to use as type definition, - '___' as the optimized implementation and - '_ifunc_selector' as the IFUNC selector. */ -#define REDIRECT_NAME EVALUATOR1 (__redirect, SYMBOL_NAME) -#define OPTIMIZE(name) EVALUATOR2 (SYMBOL_NAME, name) -#define IFUNC_SELECTOR EVALUATOR1 (SYMBOL_NAME, ifunc_selector) +#include #ifndef __x86_64__ /* Due to the reordering and the other nifty extensions in i686, it is From patchwork Thu Oct 12 21:09:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 115678 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2376051qgn; Thu, 12 Oct 2017 14:10:21 -0700 (PDT) X-Received: by 10.98.35.75 with SMTP id j72mr3173338pfj.82.1507842621533; Thu, 12 Oct 2017 14:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507842621; cv=none; d=google.com; s=arc-20160816; b=Klt/rRuRuX8FQdjn3XYuvh9dZAE1ro1uybl+37TVA7nHEP0MSJ2KbH38WcuFIz3vYY znzolXJqQghTi3krVk/zU+WHcNkuNvaw6WrX2g2H5lf4KI3Bm0mgKyYSD97HnosMHnfW qDp1CJ7sNF+o5Uvlveu3N6C1gjeQa7zGgfz8Y44PD21lRDpInT6DryL79PEF8Fmk7rzO x1V87jWE6aA3+pE5a7yTEFjySX9NDtOvJBQBXfxm6nrzxalNP790YZvazHF7VnrDX5sD DdUPpwDfVIOjPH/jE/LD778g1F6WPgf3KpZzJXAj1XmLJyLigMNKck/0CYPSPHTrwNdl rhOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=9VrDMqQfowUabzJQ7P1VOaRRT5H4CBrsNgGsDkFEc64=; b=BXf3KCIdsodRIFZ8g8sAnvZ8nO/FxABF/Yskx0h9OY2UlpdWKAK/qKTv9ORC61nqub h/3/fZXVa5ep6vuOkZGBDa9LRmnjBtpN4GZuFsZ6exao07O+ow50yf0YCkUSl5o7ir0I N08vVHzM1pwNzsq3Q6Db249huLOeEJLfHd9qVUoSaf3WbOZR331q5eByc5VWjM3c2FpT SbmWvLfO12sFejAyXE4+sMQyk9eCgTVR08jqI1IIpWFK/4N0LdhmXpMyyqUzjtiFD6aA /4LRvVq+SLp5HdfufColFGZPes4etN7YeLugU3ZeiEEHcT/geYVkm/v9Q89p/W8+z8Fj 6MxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ccRCJn29; spf=pass (google.com: domain of libc-alpha-return-85763-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85763-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t24si11688788pfj.580.2017.10.12.14.10.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 14:10:21 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-85763-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ccRCJn29; spf=pass (google.com: domain of libc-alpha-return-85763-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85763-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=hr+fsYcutXsscinmGgK6swZX/+B+JdE CAztCpZw8Gi9FAyJ9csVxa7CtwinMXcP/RNSc4s0qWx3mm0yiHXClrLicJaumz9Y NITfZYQzAfO9DKsIDijNqUFupOQ0x8Ct7r1ezz0jVXqWqrBKh8G7WzIP81bkuJY0 9i3069lP/NKE= 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=3wQbUz9JZ6TNQ3vtVq5l1vbgSyA=; b=ccRCJ n29Vwaf5dxTJ4n2eA+n+OfE64m2MVI4fA4uRVedx8FgUqRDk+nPqngCRUaZGTXll sBZXlFlxLokK3NFIapyf6u5lYHJFlSVB4aL4NNHQzYWcVW5m0IITgZ0ivqQrHcrj +J11axvGsm3uClKv7giMFWpw1D2rR4j7cktIhE= Received: (qmail 101677 invoked by alias); 12 Oct 2017 21:10:00 -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 101488 invoked by uid 89); 12 Oct 2017 21:10:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1192 X-HELO: mail-qk0-f176.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=9VrDMqQfowUabzJQ7P1VOaRRT5H4CBrsNgGsDkFEc64=; b=nWaGrMIlFQ5TH67bTERw78UkRCkjw1vhM6BU9Yqo5G7go5NJ27wDAmg4V0DHHsNDlE NcpHdr6W/GI04ZVOdU/WnbQUhTvWppAMYflVH5ctd21Szfj9qdOGfc5j3zw0mg7EKZxi dJbyay6rTSuKsd+MPxfmLtItT3oOVpSaJCyuQ83eT77AB7KSVNNFUO1pvgqAOw69he2G 5L1qOeBUyRXXLwOXfh1UpE/H0WppqWEYuqL4oYOc3Dse7qP6TUb4Oqr1g5k+teSQ0ugV RV96qrmv00rTnUdSGwjt6u5IQ0f1UBC4IR2mEqi98H6mzCEXiDgOjJSmg3fFvX/EjNcV myrw== X-Gm-Message-State: AMCzsaUWKU/J2pun8MnnUvXJOCYvJRW2RgoTL2BgEUj2IVmRHEN+dKL0 2k0L08bhqSJlIbrYwgN4bk6v8xIe7Kw= X-Google-Smtp-Source: ABhQp+Rj4mcOPYMWSHOT2PudD37tDWNTjKnnL6bR0V8NO0zDN8Wyl+2QbFgpTijAKIAdKx0/Gi//WA== X-Received: by 10.233.221.66 with SMTP id r63mr2480574qkf.79.1507842597291; Thu, 12 Oct 2017 14:09:57 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/5] Add build-many-glibcs.py arm-linux-gnueabihf-v7{-disable-multiarch} Date: Thu, 12 Oct 2017 18:09:42 -0300 Message-Id: <1507842584-28674-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org> References: <1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds two extra configuration for arm-linux-gnueabihf to cover for multiarch support: 1. arm-linux-gnueabihf-v7a: enables multiarch support by using -march=armv7a. 2. Same as 1. but with --disable-multiarch. Check with build-many-glibcs.py for both options. * scripts/build-many-glibcs.py (Context.add_all_configs): Add arm-linux-gnueabihf multiarch extra_glibcs. --- ChangeLog | 3 +++ scripts/build-many-glibcs.py | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py index a6c01f9..4cd0a81 100755 --- a/scripts/build-many-glibcs.py +++ b/scripts/build-many-glibcs.py @@ -174,7 +174,12 @@ class Context(object): variant='be8', gcc_cfg=['--with-arch=armv7-a']) self.add_config(arch='arm', - os_name='linux-gnueabihf') + os_name='linux-gnueabihf', + extra_glibcs=[{'variant': 'v7a', + 'ccopts': '-march=armv7a'}, + {'variant': 'v7a-disable-multi-arch', + 'ccopts': '-march=armv7a', + 'cfg': ['--disable-multi-arch']}]) self.add_config(arch='armeb', os_name='linux-gnueabihf') self.add_config(arch='armeb', From patchwork Thu Oct 12 21:09:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 115680 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2376325qgn; Thu, 12 Oct 2017 14:10:42 -0700 (PDT) X-Received: by 10.99.100.134 with SMTP id y128mr1207522pgb.45.1507842642369; Thu, 12 Oct 2017 14:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507842642; cv=none; d=google.com; s=arc-20160816; b=pgI2Li+fp66NUrqQUoJRzOQAEhFXz5j7BqYiK/zx+jB4SW2IdlaBcqrrl1dznoUQkj wP5lSxmvfFh0yfJCYs1iEa0G1MC3iSsGyjDpuxMxLDYtTMYm2RspT8elIfkEZxOmKMhO M4NLH96Z0+PEI9mXVDPpvkHCeLEyXKyIx7SCaHl8H5rH0qBDkFxj/+cJYefJQpYkxYSa SaNor2i7Hr8HzvWCyhomKb64O0W7ImnX03iIcrSMVSJu5zuQu6jXmpSUr+kMC4c6TRja IyGurYcUb1Z/BjbVyNyPGPqV1DF7Slkq0nU0SpGEjoMGFdt5gPrk/K0/SzfwoonaCczl ddLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=1ZcjlBYXu6s4ftvLe1zI3kSgtGwRXogQFShvxv+mrDE=; b=WOG/UW3Z/kM3KzihJ+OozOxu2uzbVB2qjlic8AjrNJUfpbwMoGOrOcYXyr59E708gQ czSOAhvpMoguJeYQOd4lrW05sQxxGXyMbHX+0hMTlS6FqTCp4cXvhLc0CAUlQWt165KI 0LSOmB244k04iuo3IyyuV6ZrehZ5jwLQJt/rXzwHOQlqpIQKlFqbhHzwiiQccyZMVlXR 5FO/dRHOpC+ndG0REHCZ38rCclIttDhZcbcFWpC044MbTojMaai0PKJrid2B6TMF2bmw 9AfiYgU76RDNxwr/aIYQbResoTbbQGstWdYXs0vpjlVV8Bvj5ZsP3e4HqMXMsBwffuRC L+TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=I3Z4d18L; spf=pass (google.com: domain of libc-alpha-return-85765-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85765-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id x71si1407343pgd.517.2017.10.12.14.10.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 14:10:42 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-85765-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=I3Z4d18L; spf=pass (google.com: domain of libc-alpha-return-85765-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85765-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=Yc8lEgP/l42L4W1Th3BvTlNpqDmDUC/ X8+Eg6Pv/+FnKkacyIf6LwbwaK7sMtTkm28BKt2HvkqkOnJlcq1zt6H69GzUSX+U DEZNF2i6MaEc8/qZ9+qcaW5+V9zPvJBdfFUo+WaAHauPnRqpGdHXOvOe8dOyNCay 9dmKS84uq0bI= 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=9F3+GZt/iE/UDGiVVTG3P/0ttrk=; b=I3Z4d 18LgC/RtbeBmbGebgJO9KIx0u9/veCXzxzkGA7sHiDFT195vbkg6L4CK3dDfh5f/ 4R1bF0NTIAvkaxzN54jH6uoEHCWBKQW71X+iEHhg5em0YzotyOyVa3qM4xlTMBWo WKORW3+Q0Rts3tB1IlVWFf24aEw7s7x69W+l+E= Received: (qmail 102930 invoked by alias); 12 Oct 2017 21:10:03 -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 102765 invoked by uid 89); 12 Oct 2017 21:10:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f182.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=1ZcjlBYXu6s4ftvLe1zI3kSgtGwRXogQFShvxv+mrDE=; b=QDmi689gRbZ5Wd63VOclMArdX/KMiAMjk7UftHtslZnegbFERazX2AWqbZRSYuL3Gb w9rZemIGQ0y2+Wd0b3CMa6F5cCkJSCG/xq409CcJC4RJ9fs39w6FWKvdqpgr8op3qGzG piQiUsz1551L/NHCNBabm/juKyleRYJMwpJimg4SetqTYvAXEpC8YF4V0l0FW05ZBQN4 9u6jC0vEgjrVl7H9BW1+82Rc1iMFu3U44eBB8oNNXnUg6j7+PoSSHeYjxV9p9khxPmeo 4pNqTu6TfEv4MrGub6MSNFTw9FayRZ1a0eTNsjgXkngowBV9VpdXUQb87dhjQnQ1u4ZO v2vQ== X-Gm-Message-State: AMCzsaWhxl2n1QnnqRx6YThJD3BbkPdhPMMklDJATD/uoN2L4Ih6xSi5 LruiLB3WwT3H6P9c2kvUHwECBgzQhPo= X-Google-Smtp-Source: AOwi7QCWUrHdhBGoKsX5AVLni5n0CJWM+2UXx/09s/XdcNfOLuXtj4SqbiqbVsbOTiqOF01E/Uzk5g== X-Received: by 10.200.38.50 with SMTP id u47mr5516461qtu.112.1507842598884; Thu, 12 Oct 2017 14:09:58 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 4/5] arm: Implement memcpy ifunc selection in C Date: Thu, 12 Oct 2017 18:09:43 -0300 Message-Id: <1507842584-28674-4-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org> References: <1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org> This patch refactor ARM memcpy ifunc selector to a C implementation. No functional change is expected, including ifunc resolution rules. Checked on armv7-linux-gnueabihf and with a build for arm-linux-gnueabi, arm-linux-gnueabihf with and without multiarch support and with both GCC 7.1 and GCC mainline. * sysdeps/arm/arm-ifunc.h: New file. * sysdeps/arm/armv7/multiarch/ifunc-memcpy.h: Likewise. * sysdeps/arm/armv7/multiarch/memcpy.c: Likewise. * sysdeps/arm/armv7/multiarch/memcpy_arm.S: Likewise. * sysdeps/arm/armv7/multiarch/rtld-memcpy.S: Likewise. * sysdeps/arm/armv7/multiarch/Makefile [$(subdir) = string] (sysdep_routines): Add memcpy_arm. * sysdeps/arm/armv7/multiarch/memcpy.S: Remove file. --- ChangeLog | 9 ++++ sysdeps/arm/arm-ifunc.h | 33 +++++++++++++ sysdeps/arm/armv7/multiarch/Makefile | 2 +- sysdeps/arm/armv7/multiarch/ifunc-memcpy.h | 37 +++++++++++++++ sysdeps/arm/armv7/multiarch/memcpy.S | 76 ------------------------------ sysdeps/arm/armv7/multiarch/memcpy.c | 33 +++++++++++++ sysdeps/arm/armv7/multiarch/memcpy_arm.S | 6 +++ sysdeps/arm/armv7/multiarch/rtld-memcpy.S | 1 + 8 files changed, 120 insertions(+), 77 deletions(-) create mode 100644 sysdeps/arm/arm-ifunc.h create mode 100644 sysdeps/arm/armv7/multiarch/ifunc-memcpy.h delete mode 100644 sysdeps/arm/armv7/multiarch/memcpy.S create mode 100644 sysdeps/arm/armv7/multiarch/memcpy.c create mode 100644 sysdeps/arm/armv7/multiarch/memcpy_arm.S create mode 100644 sysdeps/arm/armv7/multiarch/rtld-memcpy.S -- 2.7.4 diff --git a/sysdeps/arm/arm-ifunc.h b/sysdeps/arm/arm-ifunc.h new file mode 100644 index 0000000..52cb533 --- /dev/null +++ b/sysdeps/arm/arm-ifunc.h @@ -0,0 +1,33 @@ +/* Common definition for ifunc resolvers. Linux/ARM version. + This file is part of the GNU C Library. + Copyright (C) 2017 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +#define INIT_ARCH() + +#define arm_libc_ifunc_redirected(redirected_name, name, expr) \ + __ifunc (redirected_name, name, expr(hwcap), int hwcap, INIT_ARCH) + +#if defined SHARED +# define arm_libc_ifunc_hidden_def(redirect_name, name) \ + __hidden_ver1 (name, __GI_##name, redirect_name) \ + __attribute__ ((visibility ("hidden"))) +#else +# define arm_libc_ifunc_hidden_def(redirect_name, name) +#endif diff --git a/sysdeps/arm/armv7/multiarch/Makefile b/sysdeps/arm/armv7/multiarch/Makefile index 9e1e61c..1e62ef9 100644 --- a/sysdeps/arm/armv7/multiarch/Makefile +++ b/sysdeps/arm/armv7/multiarch/Makefile @@ -1,3 +1,3 @@ ifeq ($(subdir),string) -sysdep_routines += memcpy_neon memcpy_vfp memchr_neon +sysdep_routines += memcpy_neon memcpy_vfp memchr_neon memcpy_arm endif diff --git a/sysdeps/arm/armv7/multiarch/ifunc-memcpy.h b/sysdeps/arm/armv7/multiarch/ifunc-memcpy.h new file mode 100644 index 0000000..78cef2a --- /dev/null +++ b/sysdeps/arm/armv7/multiarch/ifunc-memcpy.h @@ -0,0 +1,37 @@ +/* Common definition for memcpy resolver. + 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifdef __SOFTFP__ +__typeof (REDIRECT_NAME) OPTIMIZE (arm) attribute_hidden; +#endif +__typeof (REDIRECT_NAME) OPTIMIZE (vfp) attribute_hidden; +__typeof (REDIRECT_NAME) OPTIMIZE (neon) attribute_hidden; + +static inline void * +IFUNC_SELECTOR (int hwcap) +{ + if (hwcap & HWCAP_ARM_NEON) + return OPTIMIZE (neon); +#ifdef __SOFTFP__ + if (hwcap & HWCAP_ARM_VFP) + return OPTIMIZE (vfp); + return OPTIMIZE (arm); +#else + return OPTIMIZE (vfp); +#endif +} diff --git a/sysdeps/arm/armv7/multiarch/memcpy.S b/sysdeps/arm/armv7/multiarch/memcpy.S deleted file mode 100644 index 8a53bda..0000000 --- a/sysdeps/arm/armv7/multiarch/memcpy.S +++ /dev/null @@ -1,76 +0,0 @@ -/* Multiple versions of memcpy - All versions must be listed in ifunc-impl-list.c. - Copyright (C) 2013-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 - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* Thumb requires excess IT instructions here. */ -#define NO_THUMB -#include -#include - -#if IS_IN (libc) -/* Under __ARM_NEON__, memcpy_neon.S defines the name memcpy. */ -# ifndef __ARM_NEON__ - .text -ENTRY(memcpy) - .type memcpy, %gnu_indirect_function -# ifdef __SOFTFP__ - ldr r1, .Lmemcpy_arm - tst r0, #HWCAP_ARM_VFP - ldrne r1, .Lmemcpy_vfp -# else - ldr r1, .Lmemcpy_vfp -# endif - tst r0, #HWCAP_ARM_NEON - ldrne r1, .Lmemcpy_neon -1: - add r0, r1, pc - DO_RET(lr) - -# ifdef __SOFTFP__ -.Lmemcpy_arm: - .long C_SYMBOL_NAME(__memcpy_arm) - 1b - PC_OFS -# endif -.Lmemcpy_neon: - .long C_SYMBOL_NAME(__memcpy_neon) - 1b - PC_OFS -.Lmemcpy_vfp: - .long C_SYMBOL_NAME(__memcpy_vfp) - 1b - PC_OFS - -END(memcpy) - -libc_hidden_builtin_def (memcpy) -#endif /* Not __ARM_NEON__. */ - -/* These versions of memcpy are defined not to clobber any VFP or NEON - registers so they must always call the ARM variant of the memcpy code. */ -strong_alias (__memcpy_arm, __aeabi_memcpy) -strong_alias (__memcpy_arm, __aeabi_memcpy4) -strong_alias (__memcpy_arm, __aeabi_memcpy8) -libc_hidden_def (__memcpy_arm) - -#undef libc_hidden_builtin_def -#define libc_hidden_builtin_def(name) -#undef weak_alias -#define weak_alias(x, y) -#undef libc_hidden_def -#define libc_hidden_def(name) - -#define memcpy __memcpy_arm - -#endif - -#include "memcpy_impl.S" diff --git a/sysdeps/arm/armv7/multiarch/memcpy.c b/sysdeps/arm/armv7/multiarch/memcpy.c new file mode 100644 index 0000000..7ef6714 --- /dev/null +++ b/sysdeps/arm/armv7/multiarch/memcpy.c @@ -0,0 +1,33 @@ +/* Multiple versions of memcpy. + All versions must be listed in ifunc-impl-list.c. + 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# define memcpy __redirect_memcpy +# include +# undef memcpy + +# include + +# define SYMBOL_NAME memcpy +# include "ifunc-memcpy.h" + +arm_libc_ifunc_redirected (__redirect_memcpy, memcpy, IFUNC_SELECTOR); + +arm_libc_ifunc_hidden_def (__redirect_memcpy, memcpy); +#endif diff --git a/sysdeps/arm/armv7/multiarch/memcpy_arm.S b/sysdeps/arm/armv7/multiarch/memcpy_arm.S new file mode 100644 index 0000000..37565cd --- /dev/null +++ b/sysdeps/arm/armv7/multiarch/memcpy_arm.S @@ -0,0 +1,6 @@ +#define memcpy __memcpy_arm +#include "memcpy_impl.S" + +strong_alias (__memcpy_arm, __aeabi_memcpy) +strong_alias (__memcpy_arm, __aeabi_memcpy4) +strong_alias (__memcpy_arm, __aeabi_memcpy8) diff --git a/sysdeps/arm/armv7/multiarch/rtld-memcpy.S b/sysdeps/arm/armv7/multiarch/rtld-memcpy.S new file mode 100644 index 0000000..0190edc --- /dev/null +++ b/sysdeps/arm/armv7/multiarch/rtld-memcpy.S @@ -0,0 +1 @@ +#include <./sysdeps/arm/armv7/multiarch/memcpy_impl.S> From patchwork Thu Oct 12 21:09:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 115681 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2376480qgn; Thu, 12 Oct 2017 14:10:53 -0700 (PDT) X-Received: by 10.84.131.197 with SMTP id d63mr1219247pld.320.1507842652936; Thu, 12 Oct 2017 14:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507842652; cv=none; d=google.com; s=arc-20160816; b=s3+Uo/7mejl+oAVmnaIGJsFGzk7BHqP/nXj6cAdoYcC33jT2NRFKSvdN9HD6zGHZVq /QwVRorkOm4fTZqv7/PP2i5icW2MAlOi8mkN4WBgRxdosRn9kVy3cXzR+zulzIb/2IT9 9vkYFFt9xid0z7SKWEjerXE6afj/jeQFRYvVag7xiLa76woyTALRueAiO8nBrwsHmrxr gpPW92mBQG8h/APAwrWJg9MLhuGYCQ0mXJKRgIoy2vP+OaUKwRdm4t9SB60bwtfHmMT9 e+DzT+BDB9nAFwwOwV6lnIBsCJbnH9QaN5w7S2tphamJY1NAPKqg+oNHgKo3uoY2Tits xkoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=3sH0CWcExyoa7JrI3jjw+EvNJLAWRHX+G0Lt0FYbfW0=; b=PJAW1FsJRrAtigsKcOfxCegqQMBIDNWa4GuIfmsTW4zQMCvOd2Q5LjvBgK+pfPRxXk t4yAsc1OurTkVaSlvlrP1+y+b+BEteRjRkUff5/oNj/W/5/Rj8wiE3ixUZOoc34qbvRX HGQvyL+0KgxDCwOOCx3e9lRi3pYzTIzY1JRndd8c+LmCffULnYYzYfklA1sRahNIwqkh GTH1u349OMravlIIakUVXCMPs+Tm3iaVheq2TOynT2VcDxMXnqIGJYDzgQ3qnSLIbdWI /80hcqeE6m1hcfCgtSggeBzAETjxRTxLGdRSN2KBFGq5onQmgy7dpTVUCwSfAI7W4Lhn r9bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=egOnzcuM; spf=pass (google.com: domain of libc-alpha-return-85766-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85766-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id f7si8673446pgc.746.2017.10.12.14.10.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 14:10:52 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-85766-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=egOnzcuM; spf=pass (google.com: domain of libc-alpha-return-85766-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85766-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=wQWLYadQxJq2SdFKad1FmE2owC6MAzv pGHzv/9EbCpEXqrV0LO5Yf+UzthYmFTrG3Wklw/ndT6fShPNzVQoOFw4Wu8XMJr6 s5mS36ZSg7Uiq6cMTIx7EaF9vpowV/acgGa0uxM8JFNBbcR32cM/WHGWLDbq1f8w Yg87uInZ7IsQ= 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=QYaWpdUhjsK2n3GhGKE8wLgNKTU=; b=egOnz cuMjHEJOVUnv303+pyYVKjhelhyR1dTzaNz6tG5esXzRgNffLMtirM5HOXZ/rRiY Hyt5tBpVokq8LLLw3cOZwnfxyGM4I5GJo3ZfCTB2rk7n7Ep713Vc1JyJOhG7MDoh cVTP2njWLxh1O2bmj9Kldes8Om0Q+sEKgw4Gko= Received: (qmail 104283 invoked by alias); 12 Oct 2017 21:10:07 -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 104084 invoked by uid 89); 12 Oct 2017 21:10:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=compensate, Compensate X-HELO: mail-qt0-f180.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=3sH0CWcExyoa7JrI3jjw+EvNJLAWRHX+G0Lt0FYbfW0=; b=hE9mwrjsQq8mVgs5rB1xGQXdiVDWRQWaXAB5dEaD6dRCz5JnHdgfqvqjFKhpfUTQXj OygjXq8enVB6BvExXuGDp3Kpgu8Be/mj2j2sowSWpmycjtYx3rngozilBi5n50uhDAdY aHOV5NYR28HIOPf9F3P68Vv1R+bnXs0WWGCuiXEB0Nhwcv5DPtGA4UKprLmP1/zZRMBo BFXSoR9zdeMYJuCI6M5uPMBF25z1v6cQtM/28VjLNgB/VsppTXJO1kggHVTx2U2jSTev hInyV1w61J4kwY7z6U17FaGrhXfcrp9Y4Ez6qmnvud3g6yctpxgIxZ43zjxmJ0fjEeCW xjCA== X-Gm-Message-State: AMCzsaWJmQ1yPnGPUoLtiaIfx0p9qXiZ++8SV6ykfDAgLvgsI/mVO/pB khgVDFkViTa7c22wSZoQdHP0kgVB4U0= X-Google-Smtp-Source: ABhQp+TH8sBukOya24PQQ8fgC8j5lEZQ+m50oTLkb+HswZ82Aq/nm/8oR7PfEKuI1GVYNyTSfnHIPg== X-Received: by 10.200.16.8 with SMTP id z8mr5712243qti.61.1507842600469; Thu, 12 Oct 2017 14:10:00 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 5/5] arm: Implement memchr ifunc selection in C Date: Thu, 12 Oct 2017 18:09:44 -0300 Message-Id: <1507842584-28674-5-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org> References: <1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org> This patch refactor ARM memchr ifunc selector to a C implementation. No functional change is expected, including ifunc resolution rules. It also reorganize the ifunc options code: 1. The memchr_impl.S is renamed to memchr_neon.S and multiple compilation options (which route to armv6t2/memchr one) is removed. The code to build if __ARM_NEON__ is defined is also simplified. 2. A memchr_noneon is added (which as build along previous ifunc resolution) and includes the armv6t2 direct. 3. Same as 2. for loader object. Checked on armv7-linux-gnueabihf and with a build for arm-linux-gnueabi, arm-linux-gnueabihf with and without multiarch support and with both GCC 7.1 and GCC mainline. * sysdeps/arm/armv7/multiarch/Makefile [$(subdir) = string] (sysdeps_routines): Add memchr_noneon. * sysdeps/arm/armv7/multiarch/ifunc-memchr.h: New file. * sysdeps/arm/armv7/multiarch/memchr_noneon.S: Likewise. * sysdeps/arm/armv7/multiarch/rtld-memchr.S: Likewise. * sysdeps/arm/armv7/multiarch/memchr.S: Remove file. * sysdeps/arm/armv7/multiarch/memchr.c: New file. * sysdeps/arm/armv7/multiarch/memchr_impl.S: Move to ... * sysdeps/arm/armv7/multiarch/memchr_neon.S: ... here. --- ChangeLog | 10 ++ sysdeps/arm/armv7/multiarch/Makefile | 3 +- sysdeps/arm/armv7/multiarch/ifunc-memchr.h | 28 ++++ sysdeps/arm/armv7/multiarch/memchr.S | 59 -------- sysdeps/arm/armv7/multiarch/memchr.c | 35 +++++ sysdeps/arm/armv7/multiarch/memchr_impl.S | 219 --------------------------- sysdeps/arm/armv7/multiarch/memchr_neon.S | 221 +++++++++++++++++++++++++++- sysdeps/arm/armv7/multiarch/memchr_noneon.S | 8 + sysdeps/arm/armv7/multiarch/rtld-memchr.S | 1 + 9 files changed, 299 insertions(+), 285 deletions(-) create mode 100644 sysdeps/arm/armv7/multiarch/ifunc-memchr.h delete mode 100644 sysdeps/arm/armv7/multiarch/memchr.S create mode 100644 sysdeps/arm/armv7/multiarch/memchr.c delete mode 100644 sysdeps/arm/armv7/multiarch/memchr_impl.S create mode 100644 sysdeps/arm/armv7/multiarch/memchr_noneon.S create mode 100644 sysdeps/arm/armv7/multiarch/rtld-memchr.S -- 2.7.4 diff --git a/sysdeps/arm/armv7/multiarch/Makefile b/sysdeps/arm/armv7/multiarch/Makefile index 1e62ef9..6e5851f 100644 --- a/sysdeps/arm/armv7/multiarch/Makefile +++ b/sysdeps/arm/armv7/multiarch/Makefile @@ -1,3 +1,4 @@ ifeq ($(subdir),string) -sysdep_routines += memcpy_neon memcpy_vfp memchr_neon memcpy_arm +sysdep_routines += memcpy_neon memcpy_vfp memchr_neon memcpy_arm \ + memchr_noneon endif diff --git a/sysdeps/arm/armv7/multiarch/ifunc-memchr.h b/sysdeps/arm/armv7/multiarch/ifunc-memchr.h new file mode 100644 index 0000000..42f89fa --- /dev/null +++ b/sysdeps/arm/armv7/multiarch/ifunc-memchr.h @@ -0,0 +1,28 @@ +/* Common definition for memchr resolver. + 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +__typeof (REDIRECT_NAME) OPTIMIZE (neon) attribute_hidden; +__typeof (REDIRECT_NAME) OPTIMIZE (noneon) attribute_hidden; + +static inline void * +IFUNC_SELECTOR (int hwcap) +{ + if (hwcap & HWCAP_ARM_NEON) + return OPTIMIZE (neon); + return OPTIMIZE (noneon); +} diff --git a/sysdeps/arm/armv7/multiarch/memchr.S b/sysdeps/arm/armv7/multiarch/memchr.S deleted file mode 100644 index 8e8097a..0000000 --- a/sysdeps/arm/armv7/multiarch/memchr.S +++ /dev/null @@ -1,59 +0,0 @@ -/* Multiple versions of memchr - All versions must be listed in ifunc-impl-list.c. - Copyright (C) 2013-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 - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -#if IS_IN (libc) -/* Under __ARM_NEON__, memchr_neon.S defines the name memchr. */ -# ifndef __ARM_NEON__ - .text - .arm -ENTRY(memchr) - .type memchr, %gnu_indirect_function - ldr r1, .Lmemchr_noneon - tst r0, #HWCAP_ARM_NEON - ldrne r1, .Lmemchr_neon -1: - add r0, r1, pc - DO_RET(lr) - -.Lmemchr_noneon: - .long C_SYMBOL_NAME(__memchr_noneon) - 1b - 8 -.Lmemchr_neon: - .long C_SYMBOL_NAME(__memchr_neon) - 1b - 8 - -END(memchr) - -libc_hidden_builtin_def (memchr) -# endif /* Not __ARM_NEON__. */ -libc_hidden_def (__memchr_noneon) - -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) -# undef weak_alias -# define weak_alias(x, y) -# undef libc_hidden_def -# define libc_hidden_def(name) - -# define memchr __memchr_noneon - -#endif - -#include "memchr_impl.S" diff --git a/sysdeps/arm/armv7/multiarch/memchr.c b/sysdeps/arm/armv7/multiarch/memchr.c new file mode 100644 index 0000000..906bcd5 --- /dev/null +++ b/sysdeps/arm/armv7/multiarch/memchr.c @@ -0,0 +1,35 @@ +/* Multiple versions of memchr. + All versions must be listed in ifunc-impl-list.c. + 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* For __ARM_NEON__ memchr_neon.S defines memchr directly and ifunc + is not used. */ +#if IS_IN (libc) && !defined (__ARM_NEON__) +# define memchr __redirect_memchr +# include +# undef memchr + +# include + +# define SYMBOL_NAME memchr +# include "ifunc-memchr.h" + +arm_libc_ifunc_redirected (__redirect_memchr, memchr, IFUNC_SELECTOR); + +arm_libc_ifunc_hidden_def (__redirect_memchr, memchr); +#endif diff --git a/sysdeps/arm/armv7/multiarch/memchr_impl.S b/sysdeps/arm/armv7/multiarch/memchr_impl.S deleted file mode 100644 index e8cbb97..0000000 --- a/sysdeps/arm/armv7/multiarch/memchr_impl.S +++ /dev/null @@ -1,219 +0,0 @@ -/* memchr implemented using NEON. - Copyright (C) 2011-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 - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#ifdef MEMCHR_NEON - -#include - - .arch armv7-a - .fpu neon - - -/* Arguments */ -#define srcin r0 -#define chrin r1 -#define cntin r2 - -/* Retval */ -#define result r0 /* Live range does not overlap with srcin */ - -/* Working registers */ -#define src r1 /* Live range does not overlap with chrin */ -#define tmp r3 -#define synd r0 /* No overlap with srcin or result */ -#define soff r12 - -/* Working NEON registers */ -#define vrepchr q0 -#define vdata0 q1 -#define vdata0_0 d2 /* Lower half of vdata0 */ -#define vdata0_1 d3 /* Upper half of vdata0 */ -#define vdata1 q2 -#define vdata1_0 d4 /* Lower half of vhas_chr0 */ -#define vdata1_1 d5 /* Upper half of vhas_chr0 */ -#define vrepmask q3 -#define vrepmask0 d6 -#define vrepmask1 d7 -#define vend q4 -#define vend0 d8 -#define vend1 d9 - -/* - * Core algorithm: - * - * For each 32-byte chunk we calculate a 32-bit syndrome value, with one bit per - * byte. Each bit is set if the relevant byte matched the requested character - * and cleared otherwise. Since the bits in the syndrome reflect exactly the - * order in which things occur in the original string, counting trailing zeros - * allows to identify exactly which byte has matched. - */ - -#ifndef NO_THUMB - .thumb_func -#else - .arm -#endif - .p2align 4,,15 - -ENTRY(memchr) - /* Use a simple loop if there are less than 8 bytes to search. */ - cmp cntin, #7 - bhi .Llargestr - and chrin, chrin, #0xff - -.Lsmallstr: - subs cntin, cntin, #1 - blo .Lnotfound /* Return not found if reached end. */ - ldrb tmp, [srcin], #1 - cmp tmp, chrin - bne .Lsmallstr /* Loop again if not found. */ - /* Otherwise fixup address and return. */ - sub result, srcin, #1 - bx lr - - -.Llargestr: - vdup.8 vrepchr, chrin /* Duplicate char across all lanes. */ - /* - * Magic constant 0x8040201008040201 allows us to identify which lane - * matches the requested byte. - */ - movw tmp, #0x0201 - movt tmp, #0x0804 - lsl soff, tmp, #4 - vmov vrepmask0, tmp, soff - vmov vrepmask1, tmp, soff - /* Work with aligned 32-byte chunks */ - bic src, srcin, #31 - ands soff, srcin, #31 - beq .Lloopintro /* Go straight to main loop if it's aligned. */ - - /* - * Input string is not 32-byte aligned. We calculate the syndrome - * value for the aligned 32 bytes block containing the first bytes - * and mask the irrelevant part. - */ - vld1.8 {vdata0, vdata1}, [src:256]! - sub tmp, soff, #32 - adds cntin, cntin, tmp - vceq.i8 vdata0, vdata0, vrepchr - vceq.i8 vdata1, vdata1, vrepchr - vand vdata0, vdata0, vrepmask - vand vdata1, vdata1, vrepmask - vpadd.i8 vdata0_0, vdata0_0, vdata0_1 - vpadd.i8 vdata1_0, vdata1_0, vdata1_1 - vpadd.i8 vdata0_0, vdata0_0, vdata1_0 - vpadd.i8 vdata0_0, vdata0_0, vdata0_0 - vmov synd, vdata0_0[0] - - /* Clear the soff lower bits */ - lsr synd, synd, soff - lsl synd, synd, soff - /* The first block can also be the last */ - bls .Lmasklast - /* Have we found something already? */ -#ifndef NO_THUMB - cbnz synd, .Ltail -#else - cmp synd, #0 - bne .Ltail -#endif - - -.Lloopintro: - vpush {vend} - /* 264/265 correspond to d8/d9 for q4 */ - cfi_adjust_cfa_offset (16) - cfi_rel_offset (264, 0) - cfi_rel_offset (265, 8) - .p2align 3,,7 -.Lloop: - vld1.8 {vdata0, vdata1}, [src:256]! - subs cntin, cntin, #32 - vceq.i8 vdata0, vdata0, vrepchr - vceq.i8 vdata1, vdata1, vrepchr - /* If we're out of data we finish regardless of the result. */ - bls .Lend - /* Use a fast check for the termination condition. */ - vorr vend, vdata0, vdata1 - vorr vend0, vend0, vend1 - vmov synd, tmp, vend0 - orrs synd, synd, tmp - /* We're not out of data, loop if we haven't found the character. */ - beq .Lloop - -.Lend: - vpop {vend} - cfi_adjust_cfa_offset (-16) - cfi_restore (264) - cfi_restore (265) - - /* Termination condition found, let's calculate the syndrome value. */ - vand vdata0, vdata0, vrepmask - vand vdata1, vdata1, vrepmask - vpadd.i8 vdata0_0, vdata0_0, vdata0_1 - vpadd.i8 vdata1_0, vdata1_0, vdata1_1 - vpadd.i8 vdata0_0, vdata0_0, vdata1_0 - vpadd.i8 vdata0_0, vdata0_0, vdata0_0 - vmov synd, vdata0_0[0] -#ifndef NO_THUMB - cbz synd, .Lnotfound - bhi .Ltail /* Uses the condition code from - subs cntin, cntin, #32 above. */ -#else - cmp synd, #0 - beq .Lnotfound - cmp cntin, #0 - bhi .Ltail -#endif - - -.Lmasklast: - /* Clear the (-cntin) upper bits to avoid out-of-bounds matches. */ - neg cntin, cntin - lsl synd, synd, cntin - lsrs synd, synd, cntin - it eq - moveq src, #0 /* If no match, set src to 0 so the retval is 0. */ - - -.Ltail: - /* Count the trailing zeros using bit reversing */ - rbit synd, synd - /* Compensate the last post-increment */ - sub src, src, #32 - /* Count the leading zeros */ - clz synd, synd - /* Compute the potential result and return */ - add result, src, synd - bx lr - - -.Lnotfound: - /* Set result to NULL if not found and return */ - mov result, #0 - bx lr - -END(memchr) -libc_hidden_builtin_def (memchr) - -#else - -#include "../../armv6t2/memchr.S" - -#endif diff --git a/sysdeps/arm/armv7/multiarch/memchr_neon.S b/sysdeps/arm/armv7/multiarch/memchr_neon.S index ee21818..a400033 100644 --- a/sysdeps/arm/armv7/multiarch/memchr_neon.S +++ b/sysdeps/arm/armv7/multiarch/memchr_neon.S @@ -1,9 +1,218 @@ -#ifdef __ARM_NEON__ -/* Under __ARM_NEON__, this file defines memchr directly. */ -libc_hidden_builtin_def (memchr) -#else +/* memchr implemented using NEON. + Copyright (C) 2011-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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include + +/* For __ARM_NEON__ this file defines memchr. */ +#ifndef __ARM_NEON__ # define memchr __memchr_neon +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(a) +#endif + + .arch armv7-a + .fpu neon + + +/* Arguments */ +#define srcin r0 +#define chrin r1 +#define cntin r2 + +/* Retval */ +#define result r0 /* Live range does not overlap with srcin */ + +/* Working registers */ +#define src r1 /* Live range does not overlap with chrin */ +#define tmp r3 +#define synd r0 /* No overlap with srcin or result */ +#define soff r12 + +/* Working NEON registers */ +#define vrepchr q0 +#define vdata0 q1 +#define vdata0_0 d2 /* Lower half of vdata0 */ +#define vdata0_1 d3 /* Upper half of vdata0 */ +#define vdata1 q2 +#define vdata1_0 d4 /* Lower half of vhas_chr0 */ +#define vdata1_1 d5 /* Upper half of vhas_chr0 */ +#define vrepmask q3 +#define vrepmask0 d6 +#define vrepmask1 d7 +#define vend q4 +#define vend0 d8 +#define vend1 d9 + +/* + * Core algorithm: + * + * For each 32-byte chunk we calculate a 32-bit syndrome value, with one bit per + * byte. Each bit is set if the relevant byte matched the requested character + * and cleared otherwise. Since the bits in the syndrome reflect exactly the + * order in which things occur in the original string, counting trailing zeros + * allows to identify exactly which byte has matched. + */ + +#ifndef NO_THUMB + .thumb_func +#else + .arm +#endif + .p2align 4,,15 + +ENTRY(memchr) + /* Use a simple loop if there are less than 8 bytes to search. */ + cmp cntin, #7 + bhi .Llargestr + and chrin, chrin, #0xff + +.Lsmallstr: + subs cntin, cntin, #1 + blo .Lnotfound /* Return not found if reached end. */ + ldrb tmp, [srcin], #1 + cmp tmp, chrin + bne .Lsmallstr /* Loop again if not found. */ + /* Otherwise fixup address and return. */ + sub result, srcin, #1 + bx lr + + +.Llargestr: + vdup.8 vrepchr, chrin /* Duplicate char across all lanes. */ + /* + * Magic constant 0x8040201008040201 allows us to identify which lane + * matches the requested byte. + */ + movw tmp, #0x0201 + movt tmp, #0x0804 + lsl soff, tmp, #4 + vmov vrepmask0, tmp, soff + vmov vrepmask1, tmp, soff + /* Work with aligned 32-byte chunks */ + bic src, srcin, #31 + ands soff, srcin, #31 + beq .Lloopintro /* Go straight to main loop if it's aligned. */ + + /* + * Input string is not 32-byte aligned. We calculate the syndrome + * value for the aligned 32 bytes block containing the first bytes + * and mask the irrelevant part. + */ + vld1.8 {vdata0, vdata1}, [src:256]! + sub tmp, soff, #32 + adds cntin, cntin, tmp + vceq.i8 vdata0, vdata0, vrepchr + vceq.i8 vdata1, vdata1, vrepchr + vand vdata0, vdata0, vrepmask + vand vdata1, vdata1, vrepmask + vpadd.i8 vdata0_0, vdata0_0, vdata0_1 + vpadd.i8 vdata1_0, vdata1_0, vdata1_1 + vpadd.i8 vdata0_0, vdata0_0, vdata1_0 + vpadd.i8 vdata0_0, vdata0_0, vdata0_0 + vmov synd, vdata0_0[0] + + /* Clear the soff lower bits */ + lsr synd, synd, soff + lsl synd, synd, soff + /* The first block can also be the last */ + bls .Lmasklast + /* Have we found something already? */ +#ifndef NO_THUMB + cbnz synd, .Ltail +#else + cmp synd, #0 + bne .Ltail #endif -#define MEMCHR_NEON -#include "memchr_impl.S" + +.Lloopintro: + vpush {vend} + /* 264/265 correspond to d8/d9 for q4 */ + cfi_adjust_cfa_offset (16) + cfi_rel_offset (264, 0) + cfi_rel_offset (265, 8) + .p2align 3,,7 +.Lloop: + vld1.8 {vdata0, vdata1}, [src:256]! + subs cntin, cntin, #32 + vceq.i8 vdata0, vdata0, vrepchr + vceq.i8 vdata1, vdata1, vrepchr + /* If we're out of data we finish regardless of the result. */ + bls .Lend + /* Use a fast check for the termination condition. */ + vorr vend, vdata0, vdata1 + vorr vend0, vend0, vend1 + vmov synd, tmp, vend0 + orrs synd, synd, tmp + /* We're not out of data, loop if we haven't found the character. */ + beq .Lloop + +.Lend: + vpop {vend} + cfi_adjust_cfa_offset (-16) + cfi_restore (264) + cfi_restore (265) + + /* Termination condition found, let's calculate the syndrome value. */ + vand vdata0, vdata0, vrepmask + vand vdata1, vdata1, vrepmask + vpadd.i8 vdata0_0, vdata0_0, vdata0_1 + vpadd.i8 vdata1_0, vdata1_0, vdata1_1 + vpadd.i8 vdata0_0, vdata0_0, vdata1_0 + vpadd.i8 vdata0_0, vdata0_0, vdata0_0 + vmov synd, vdata0_0[0] +#ifndef NO_THUMB + cbz synd, .Lnotfound + bhi .Ltail /* Uses the condition code from + subs cntin, cntin, #32 above. */ +#else + cmp synd, #0 + beq .Lnotfound + cmp cntin, #0 + bhi .Ltail +#endif + + +.Lmasklast: + /* Clear the (-cntin) upper bits to avoid out-of-bounds matches. */ + neg cntin, cntin + lsl synd, synd, cntin + lsrs synd, synd, cntin + it eq + moveq src, #0 /* If no match, set src to 0 so the retval is 0. */ + + +.Ltail: + /* Count the trailing zeros using bit reversing */ + rbit synd, synd + /* Compensate the last post-increment */ + sub src, src, #32 + /* Count the leading zeros */ + clz synd, synd + /* Compute the potential result and return */ + add result, src, synd + bx lr + + +.Lnotfound: + /* Set result to NULL if not found and return */ + mov result, #0 + bx lr + +END(memchr) +libc_hidden_builtin_def (memchr) diff --git a/sysdeps/arm/armv7/multiarch/memchr_noneon.S b/sysdeps/arm/armv7/multiarch/memchr_noneon.S new file mode 100644 index 0000000..e13be13 --- /dev/null +++ b/sysdeps/arm/armv7/multiarch/memchr_noneon.S @@ -0,0 +1,8 @@ +/* For __ARM_NEON__ memchr_neon defines memchr. */ +#ifndef __ARM_NEON__ +# define memchr __memchr_noneon +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) + +# include +#endif diff --git a/sysdeps/arm/armv7/multiarch/rtld-memchr.S b/sysdeps/arm/armv7/multiarch/rtld-memchr.S new file mode 100644 index 0000000..ae8e5f0 --- /dev/null +++ b/sysdeps/arm/armv7/multiarch/rtld-memchr.S @@ -0,0 +1 @@ +#include