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 185493858D33 for ; Tue, 21 Nov 2023 23:35:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 185493858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 185493858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.141.98 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700609708; cv=none; b=X7Zn807k4hgZ9pqg+B4YloiUE+X7QgXEtWU4dkFZbCQyn8unDMg/s5B5UoRdRv+hPNcnBQD9BsyyxbhYgM6oKj/fmeS7hRG6F4t08lxCWVhBc3ntPFbOuGu7311b21jkDgEVKpARVR9aZWgr4IHYdXi9iTA3DcvDrJ4qUtXXhRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700609708; c=relaxed/simple; bh=z94R4YWHm3VyUmZbQ65POAuJE0szk1XXY+wK02X+/IU=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=TZxaz9wegYi5WOVWM03OanE6DeBQp4LNl1a0lUqYkweDqSBWuG7CGOnBgTSwUybqgm+lFy4ZQgxTWMtYuvGsaa3z0gE486GJkhZmXVlQQTZzlfETjDKcyTcptwB2NyuX74m7wz9RQXa9wSgnTWLvy2CeC2OymWZVKc/zwqewcoI= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: oVrwQjE3QUmYmoQ6yVvlkw== X-CSE-MsgGUID: 7uC76IxoToqO6LIXET5GlQ== X-IronPort-AV: E=Sophos;i="6.04,217,1695715200"; d="scan'208";a="26184245" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 21 Nov 2023 15:35:04 -0800 IronPort-SDR: PjVA+KopDJWxNhZihcgrN+YQ2myDgoV7HX283gTIE0D0O0j6abbS5w6uEKBhEujtnR1Zt/XQhz z5OdmjhSQCaHHz4EnFPyGsffQ8Uq9DzzMFNDf9lF9ats+w7bWChpTk2sqWMt6DgBMmE297fK1c wyMANuQpiZd6MejLPAqB112XSNMHJ+JGqi7O47JheuvpsErSESH9zCdWi82uPh1tX9esXcnDid CBoojiqxpJXmuIxCFumCRfRut4/6/ODYngskWi2s4kT8E3mlPWIi79mkqY52Ux+LmLKmUfRIM/ fgE= Date: Tue, 21 Nov 2023 23:35:00 +0000 From: Joseph Myers To: Jakub Jelinek CC: , Florian Weimer Subject: Re: [PATCH] c: Add __builtin_stdc_bit_{width,floor,ceil} builtins In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3103.1 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 20 Nov 2023, Jakub Jelinek wrote: > > Note that stdc_bit_ceil now has defined behavior (return 0) on overflow: > > CD2 comment FR-135 was accepted for the DIS at the June WG14 meeting. > > This affects both the documentation and the implementation, as they need > > to avoid an undefined shift by the width of the type. That's why my > > stdbit.h implementations have two shifts (not claiming that's necessarily > > the optimal way of ensuring the correct result in the overflow case). > > > > return __x <= 1 ? 1 : ((uint64_t) 1) << (__bw64_inline (__x - 1) - 1) << 1; > > So > return __x <= 1 ? 1 : ((uint64_t) 2) << (__bw64_inline (__x - 1) - 1); > then? Yes, that looks better than my version, thanks. -- Joseph S. Myers joseph@codesourcery.com