From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id D6A693858435 for ; Mon, 7 Feb 2022 20:35:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D6A693858435 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: LvdSmhh5iTQEWzKuoHFixlj+tEm0cM9TX7pbz7GhDFh63lKU4RhRhy9Yk18XqpRhXsIHKjS3i1 TIIqZA1TR+A7zIl6xQdt00DC0Xqqwf9rPxB6SOYrWi0jIkeji6Abgxv0KndfIn1ihFE8okJnHZ LusvObLR62N8rd5ngVy5uILJXyB/VNn66ohzSY51RIp9Z2bIhclEh0TYrRCnvQwpVqJDGx89rq XZ0o+HXGkxHbTgVIY8gFf8oNsxsaOT63SLRGYsO62ObHkQupSRiC3lljbkXWnuO7PANR8nI44b 8/X7GGNdMT/mhli0jNR2rJr/ X-IronPort-AV: E=Sophos;i="5.88,350,1635235200"; d="scan'208";a="71708128" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 07 Feb 2022 12:35:57 -0800 IronPort-SDR: hDSkZHKwZ7B4LyFG/LhGT5YEVWNw37xzAiThqwnZLw0Y8OYQZw6h4Lbo6hZFiGhs/g/LlX9KID frTTnQa/8n+kgNk14JodzCOdIa2d77j82uDvR8UdiUt5Ao6hjv52OQsEmArk0weTstGA4NnNHz MjZJB60DGG2Shxj2qfPPGjVxH17lfUpWXtDrTDSWiUouB3EWcpV/uxnZc7IBHMcaeP6qS85aTb RG9UYtolyDW0CNBPRfRqEE2uqlGlh8hUUjua9C1hH+s8riHTCLgeeygcF0s2YDLvxxPjFvaFA9 sPI= Date: Mon, 7 Feb 2022 20:35:43 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: "H.J. Lu" CC: Subject: Re: [PATCH] elf: Replace memcmp with __memcmpeq for variable size In-Reply-To: <20220206210914.1593336-1-hjl.tools@gmail.com> Message-ID: References: <20220206210914.1593336-1-hjl.tools@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-3114.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Feb 2022 20:36:00 -0000 On Sun, 6 Feb 2022, H.J. Lu via Libc-alpha wrote: > Replace memcmp with __memcmpeq when a boolean return is all that is > needed. __memcmpeq is an alias of memcmp by default and it can be > optimized by architectures. I don't think we should make this sort of change to glibc source code at all. We should write the code to be clear for readers - meaning using the standard C function name, which is memcmp - and leave the compiler to optimize or not. In general we should move away from writing such internal function calls directly in the source code, where it can reasonably call the standard function names instead. Cf. how we handle things for various internal calls in libm: call standard names the compiler might inline (don't provide e.g. inline versions of those functions in glibc's internal headers), with asm redirection to reserved names to cover the case when those function calls don't get inlined. -- Joseph S. Myers joseph@codesourcery.com