From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2075.outbound.protection.outlook.com [40.107.13.75]) by sourceware.org (Postfix) with ESMTPS id 46CD2385841C for ; Fri, 3 Feb 2023 13:18:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46CD2385841C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xSd5CZVq5M3NW8wSbJsg3GzH6ZN7EwZjF4j5zZTzmLk=; b=y01zCw5QBiGcwFb/mfev0FtfrZYN1IBQqmGwL5vMD+V1kek4lK/H90qaDl+kymHjXdtftdDZZrLGgHiQGXx18LSwVz9p5NAfjY97kfr/6uuSo2OZUp63I28+yk588vdmwBUVU3EgyjIzgzBtS3Ujkfk/GUodo+LjVigRwfMR7p8= Received: from AM7PR04CA0004.eurprd04.prod.outlook.com (2603:10a6:20b:110::14) by AM9PR08MB6083.eurprd08.prod.outlook.com (2603:10a6:20b:2d8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Fri, 3 Feb 2023 13:18:24 +0000 Received: from AM7EUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:110:cafe::f7) by AM7PR04CA0004.outlook.office365.com (2603:10a6:20b:110::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29 via Frontend Transport; Fri, 3 Feb 2023 13:18:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT060.mail.protection.outlook.com (100.127.140.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29 via Frontend Transport; Fri, 3 Feb 2023 13:18:24 +0000 Received: ("Tessian outbound 0d7b2ab0f13d:v132"); Fri, 03 Feb 2023 13:18:24 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bf845e45afe8952f X-CR-MTA-TID: 64aa7808 Received: from ccf98b5a27b8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CD39301A-9F02-4A98-9B35-9A7A99701A17.1; Fri, 03 Feb 2023 13:18:18 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ccf98b5a27b8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 03 Feb 2023 13:18:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I6gJ+ENoRLKnb/SY27f2EfBQ55f09zSt066cOTZz0d/by+01jBKparARWMsuFkGqNF8Vl1f7bNBeGFwIcC7yD/3lc5Majzs1h0nCZnbd9MxKOijFKxlXhIbhzNmR9xBR+61ITHEHR5b/9B9/NDwoz5QfU1zExuIaJBhTeZbMt7EQMYtTChmZrkSwziGbGrlejsuqYuMcriSYI7W6Y4TMfXWTvLYJ3QPZmUmP/2yqDSkNUmYF7MPEsBlqzuTGnhnSBJDFWHVK+BMoP8nFkXnFKnHtshbVJ7pFCioR9HqS1syd9XAeY5gMD7AWwyHvLcP1hDDDvHm7NfZOXMArFeOX+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xSd5CZVq5M3NW8wSbJsg3GzH6ZN7EwZjF4j5zZTzmLk=; b=dii31wc5Rq5+YDtNQsegmKTwWoC8nIXq+Wq+U+V0rZN1R9xJkC3XAztA6M35r57GaECdp7H0N5+fJgB8DSjzTh3VBC7j7JW0Oyt60vDFWzPaEgsGlYdA87c8xIHc5qDTw+7ALbS0ILuhdj2aOR0snFFMX5Y7kHIwrda8i5HAHu9vMKH/UiVDrgD7Ms+icyOVOkccdfVQFQfJ2DoB/B+3ysonUcy/Y5KI1U+3dVCw1Ce59rktJHmBFKJAcrwuzaHX5t6t11xCUPlKNaIdbhUhI9OqywgdsrxJoDQZTB7qTUszFn1t+kByMR1hQ6eaDCxLu63mqhSZH6BWFUZ72cuueQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xSd5CZVq5M3NW8wSbJsg3GzH6ZN7EwZjF4j5zZTzmLk=; b=y01zCw5QBiGcwFb/mfev0FtfrZYN1IBQqmGwL5vMD+V1kek4lK/H90qaDl+kymHjXdtftdDZZrLGgHiQGXx18LSwVz9p5NAfjY97kfr/6uuSo2OZUp63I28+yk588vdmwBUVU3EgyjIzgzBtS3Ujkfk/GUodo+LjVigRwfMR7p8= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by AS8PR08MB7912.eurprd08.prod.outlook.com (2603:10a6:20b:52b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.24; Fri, 3 Feb 2023 13:18:14 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::dc17:8fa2:cce5:3573]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::dc17:8fa2:cce5:3573%8]) with mapi id 15.20.6064.024; Fri, 3 Feb 2023 13:18:14 +0000 From: Wilco Dijkstra To: Adhemerval Zanella CC: 'GNU C Library' Subject: [PATCH v12 12/31] string: Improve generic strnlen with memchr Thread-Topic: [PATCH v12 12/31] string: Improve generic strnlen with memchr Thread-Index: AQHZN9DsXu4tsOqy40S8gBvwK1yHIw== Date: Fri, 3 Feb 2023 13:18:14 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAWPR08MB8982:EE_|AS8PR08MB7912:EE_|AM7EUR03FT060:EE_|AM9PR08MB6083:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ca6c527-687f-4f48-19a9-08db05e92147 x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: rmeHoP1BNKPVEnG7uIAqGSwTM5ccxFGGZ6nNEfMVmqkOQPuzxAH5pHf6j27rIbMJ9vHk4v+uLsBKtFS4KAZ463iMgUFas8Aj0z33b8SpEeGgcCEmXRJ/AV98yk/9g0oiDIyITPpWEMdUQbZ3e/zpRiVvxzj4Hxnh/f8NosBD+kmcKdRfVKDO2V1hMDr6j/DRgVnZOFhBAYQeqInXLxJLJJ/nl3ilZSWS4a0hluaV1ACMkKIW2U7uXc+FAnt0e3I08zzd3QX+typdHXAWWHuVz/n5dJWnwz6atF9Vh2sNmZKB1Q34W7wGiNKCenzg5ROGDu34jC/FbnbP6D6ftm5fDmde9ryM+4k40dzs7G1CqVKUbZYAoy/kc2lDziQ7BTg3IDBdkZsNOfEtki7wFRfKGgpfuuKMskttttCr7jEbmKhwH9gQ1p31Jc+F5IRygcTHBq4Q6kfZevEkkVZajqD2sQoraE5WsyDKfKap85KYGJLrKTsZWUIy8i4PRT8C/aApEN/yKCCYkIQfpV2sqFg0fEUM6qz6PHP9YWNoat5w49VRz0w6EUxgXKn2Nn+EIX5FdAjU7F5/jSZ1toPzcUefvN+PKGvM+/Ga9jRlgugF796wT6DloN0IdgitwerL5UYqi/ZoyJNYiC6hEND0ajfuQ7ZUnP3wXVsnYJ3G+vFLb/a58SxM3TIx7C8Cuk8Emdn8AaiM4NjQtT9QWKEWGPSas4oR7WEka37NlUvi9YNIUC52qwl0Z/gdDYeFpr6g9Q3J X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR08MB8982.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(366004)(39860400002)(136003)(376002)(346002)(451199018)(5660300002)(6506007)(9686003)(186003)(122000001)(26005)(38100700002)(38070700005)(52536014)(316002)(33656002)(66476007)(6916009)(478600001)(64756008)(55016003)(66446008)(66556008)(7696005)(71200400001)(2906002)(76116006)(8936002)(91956017)(86362001)(4326008)(66946007)(8676002)(41300700001)(41533002);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7912 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 35acd0d9-0fdd-4205-d896-08db05e91b3e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w5NOiHhBKX+LJOZd22JyWPQBbTos7+BNWzjOv1Bc6TR+FYP+W4g1NbtntuARZWk4JBoYyLBdMer6smAd18tr0LnzXIaB4Sxd3WD+LV0MAsDVLYH2q0BQ2gsyMjrkOFo78J0R/UCVAeKJH4pgbRjx1+iha7bmfBkWAMYyLhKRO6OHfJK3BzxVPvT6z76zxwfwLldzMGKrlkU0jI0rx4DegmKOwkmra/CLq1cIjS8p6FA+ieLjsNCabevITOKL+V6WqaPRF+v5BhjWtyc3dZC2F+PN/aLodRMV/wjEs+ka+g8HAmHNq51QObY0w19bG24c+alIsf5/Y9ysCIE65tlWqoMfuayJYk/oApASsuTLtf5DkBquFlOWdG7pKJVaOngLXqKP9krG9KgVv726T/5eNmmnFXqPQv7LmDjC4nIq7A+zLTBuP8tCf9aCY5IcB0SpmXQDJ2CKbsYlZrQTXMr+eP8EqkELd6HF8gp8BldgLtiKu4v8Sn/a6zTHdUAgw/Q6Yp42dnv+lw3gGxeTKjYoI+U8n/d3qxVQuTtQjskpT0zoQDddLxuFClaD+DmqtiGWh38+sj7rqVgPxnmP4eY/mhZNv6c2BYpgWY8Fe7J37Tljrqj3HG0TnPEgWGDdz4ojTDHr/T7elIbW230x3sIe7ObPqcXQAHU3IkwQXfJ41rIIgzwtGNi1xklbP/cw5z4gg80eB8Abk34MRzf6B7TSwRhItja2yuRYh9p+o2y/hfZh7fbVbZs49fSqQJa6M/Bh X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(396003)(39860400002)(376002)(451199018)(46966006)(40470700004)(36840700001)(33656002)(86362001)(81166007)(82740400003)(356005)(478600001)(6506007)(36860700001)(47076005)(9686003)(26005)(186003)(336012)(2906002)(70206006)(70586007)(8676002)(4326008)(7696005)(5660300002)(52536014)(6862004)(8936002)(41300700001)(40480700001)(55016003)(82310400005)(316002)(40460700003)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:18:24.6415 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ca6c527-687f-4f48-19a9-08db05e92147 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6083 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Adhemerval,=0A= =0A= /* Find the length of S, but scan at most MAXLEN characters. If no=0A= '\0' terminator is found in that many characters, return MAXLEN. */=0A= @@ -32,134 +27,12 @@=0A= size_t=0A= __strnlen (const char *str, size_t maxlen)=0A= {=0A= + const char *found =3D memchr (str, '\0', maxlen);=0A= + return found ? found - str : maxlen;=0A= }=0A= =0A= OK. Indeed, using memchr is better by default since it is optimized on=0A= many targets and it ensures the useful property that strnlen is at least=0A= as fast as memchr.=0A= =0A= =0A= #ifndef STRNLEN=0A= -libc_hidden_def (__strnlen)=0A= weak_alias (__strnlen, strnlen)=0A= -#endif=0A= +libc_hidden_def (__strnlen)=0A= libc_hidden_def (strnlen)=0A= +#endif=0A= diff --git a/sysdeps/i386/i686/multiarch/strnlen-c.c b/sysdeps/i386/i686/mu= ltiarch/strnlen-c.c=0A= index 351e939a93..beb0350d53 100644=0A= --- a/sysdeps/i386/i686/multiarch/strnlen-c.c=0A= +++ b/sysdeps/i386/i686/multiarch/strnlen-c.c=0A= @@ -1,10 +1,10 @@=0A= #define STRNLEN __strnlen_ia32=0A= +#include =0A= +=0A= #ifdef SHARED=0A= -# undef libc_hidden_def=0A= -# define libc_hidden_def(name) \=0A= - __hidden_ver1 (__strnlen_ia32, __GI_strnlen, __strnlen_ia32); \=0A= - strong_alias (__strnlen_ia32, __strnlen_ia32_1); \=0A= - __hidden_ver1 (__strnlen_ia32_1, __GI___strnlen, __strnlen_ia32_1);=0A= +/* Alias for internal symbol to avoid PLT generation, it redirects the=0A= + libc_hidden_def (__strnlen/strlen) to default implementation. */=0A= +__hidden_ver1 (__strnlen_ia32, __GI_strnlen, __strnlen_ia32);=0A= +strong_alias (__strnlen_ia32, __strnlen_ia32_1);=0A= +__hidden_ver1 (__strnlen_ia32_1, __GI___strnlen, __strnlen_ia32_1);=0A= #endif=0A= -=0A= -#include "string/strnlen.c"=0A= diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/strnlen-ppc32.c b/s= ysdeps/powerpc/powerpc32/power4/multiarch/strnlen-ppc32.c=0A= index 957b9b99e8..2ca1cd7181 100644=0A= --- a/sysdeps/powerpc/powerpc32/power4/multiarch/strnlen-ppc32.c=0A= +++ b/sysdeps/powerpc/powerpc32/power4/multiarch/strnlen-ppc32.c=0A= @@ -17,12 +17,12 @@=0A= . */=0A= =0A= #define STRNLEN __strnlen_ppc=0A= +#include =0A= +=0A= #ifdef SHARED=0A= -# undef libc_hidden_def=0A= -# define libc_hidden_def(name) \=0A= - __hidden_ver1 (__strnlen_ppc, __GI_strnlen, __strnlen_ppc); \=0A= - strong_alias (__strnlen_ppc, __strnlen_ppc_1); \=0A= - __hidden_ver1 (__strnlen_ppc_1, __GI___strnlen, __strnlen_ppc_1);=0A= +/* Alias for internal symbol to avoid PLT generation, it redirects the=0A= + libc_hidden_def (__strnlen/strlen) to default implementation. */=0A= +__hidden_ver1 (__strnlen_ppc, __GI_strnlen, __strnlen_ppc); \=0A= +strong_alias (__strnlen_ppc, __strnlen_ppc_1); \=0A= +__hidden_ver1 (__strnlen_ppc_1, __GI___strnlen, __strnlen_ppc_1);=0A= #endif=0A= -=0A= -#include =0A= diff --git a/sysdeps/s390/strnlen-c.c b/sysdeps/s390/strnlen-c.c=0A= index 172fcc7caa..95156a0ff5 100644=0A= --- a/sysdeps/s390/strnlen-c.c=0A= +++ b/sysdeps/s390/strnlen-c.c=0A= @@ -21,14 +21,16 @@=0A= #if HAVE_STRNLEN_C=0A= # if HAVE_STRNLEN_IFUNC=0A= # define STRNLEN STRNLEN_C=0A= +# endif=0A= +=0A= +# include =0A= +=0A= +# if HAVE_STRNLEN_IFUNC=0A= # if defined SHARED && IS_IN (libc)=0A= -# undef libc_hidden_def=0A= -# define libc_hidden_def(name) \=0A= - __hidden_ver1 (__strnlen_c, __GI_strnlen, __strnlen_c); \=0A= - strong_alias (__strnlen_c, __strnlen_c_1); \=0A= - __hidden_ver1 (__strnlen_c_1, __GI___strnlen, __strnlen_c_1);=0A= +__hidden_ver1 (__strnlen_c, __GI_strnlen, __strnlen_c);=0A= +strong_alias (__strnlen_c, __strnlen_c_1);=0A= +__hidden_ver1 (__strnlen_c_1, __GI___strnlen, __strnlen_c_1);=0A= # endif=0A= # endif=0A= =0A= -# include =0A= #endif=0A= -- =0A= 2.34.1=0A= =0A= LGTM=0A= =0A= Cheers,=0A= Wilco=