From patchwork Wed Nov 23 17:19:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 17735 Received: (qmail 100393 invoked by alias); 23 Nov 2016 17:19:43 -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 99971 invoked by uid 89); 23 Nov 2016 17:19:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=rawmemchr, Hx-exchange-antispam-report-cfa-test:6042181, HX-HELO:sk:EUR02-V, Hx-spam-relays-external:sk:EUR02-V X-HELO: EUR02-VE1-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH v2] Do not transform strchr into rawmemchr Date: Wed, 23 Nov 2016 17:19:29 +0000 Message-ID: References: , In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-microsoft-exchange-diagnostics: 1; AM5PR0802MB2609; 7:fDyuZmaI0Z3HUp1nM+6F6MBt+ICjaetOka+qRJ3VJZEJeuw/lla0JxH8YkCP6YwFT9S8+q7qBYdIebhyABO8cV7u0gRnW7eH6H5NCgvlnxKPbr+/LxJ2CIZjVXycvZb3+zp+sfjiGU+hkEr8n2SG574DYiQowAiWwX8arjsNBPwpDfgYyTpy8hcErxO30S2VQWC3mBAT62qaGXKh1MqeXZE53ueOaWXvpkmjOIvVJalEe43/NaBgt5WLoSgJaqJUyThcfEf3IaUVN4fnYxNjjiLVDcZM9F/cYfd/rkz/SN+80SRnGEvwdEATlA2oxpkNV7L7TBXQX/f9zJG11UCwgRrjWwae9k5CfURk4kgEGlU= x-ms-office365-filtering-correlation-id: 3552f742-5793-425e-6490-08d413c4e256 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM5PR0802MB2609; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6060326)(6040307)(6045199)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(6061324)(6072148)(6042181); SRVR:AM5PR0802MB2609; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0802MB2609; x-forefront-prvs: 013568035E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(189002)(54534003)(377424004)(199003)(7846002)(33656002)(5660300001)(76176999)(50986999)(8676002)(7736002)(2906002)(305945005)(66066001)(6116002)(450100001)(102836003)(77096005)(3846002)(3280700002)(4001150100001)(97736004)(92566002)(4326007)(189998001)(5640700001)(122556002)(54356999)(2501003)(8936002)(74316002)(106116001)(3660700001)(106356001)(86362001)(105586002)(6916009)(9686002)(81166006)(6506003)(7696004)(110136003)(101416001)(2950100002)(81156014)(68736007)(2900100001)(76576001)(2351001)(38730400001)(40753002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2609; H:AM5PR0802MB2610.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Nov 2016 17:19:29.6141 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2609 Version 2 of the patch removes the strchr define completely as suggested: GLIBC uses strchr (s, '\0') as an idiom to find the end of a string. This is transformed into rawmemchr by the bits/string2.h header. However this is generally slower than strlen on most targets, even when an optimized rawmemchr implementation exists. Since GCC7 optimizes strchr (s, '\0') to strlen (s) + s, the GLIBC headers should not transform this to rawmemchr. As GCC recognizes strchr as a builtin, defining strchr as the builtin is not useful. Regress passes, OK for commit? ChangeLog: 2015-11-23 Wilco Dijkstra * string/bits/string2.h (strchr): Remove define. diff --git a/string/bits/string2.h b/string/bits/string2.h index e39d4f1a85c25a4f47418e6a5613b27177ca6cbb..de426b47cae09933b2dc53e0956d63b4c93aebc0 100644 --- a/string/bits/string2.h +++ b/string/bits/string2.h @@ -58,16 +58,6 @@ #endif -#ifndef _HAVE_STRING_ARCH_strchr -extern void *__rawmemchr (const void *__s, int __c); -# define strchr(s, c) \ - (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s) \ - && (c) == '\0' \ - ? (char *) __rawmemchr (s, c) \ - : __builtin_strchr (s, c))) -#endif - - /* Copy SRC to DEST, returning pointer to final NUL byte. */ #ifdef __USE_GNU # ifndef _HAVE_STRING_ARCH_stpcpy