Path: csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod From: Sebastian Frias Newsgroups: linux.kernel Subject: Re: [PATCH v2] add equivalent of BIT(x) for bitfields Date: Tue, 06 Dec 2016 11:40:02 +0100 Message-ID: References: X-Original-To: Linus Torvalds Dkim-Signature: v=1; a=rsa-sha256; c=simple/simple; d=laposte.net; s=mail0; t=1481019002; bh=+c9h9gwJS4HmXWcBNh/+zZtyQWmFo7/jlhwHNvFiaBk=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=BKOVpGQVpDcdKcdN9JQD3Atsm3Qz9cMLrtNF+LevIIOwkmCEQM83W+yC138aJ/PgW RKhlirlJhWmJ364AUgFD2ok2SBp8FD9kqkWy0pC8lpl1jxpkvM6TDxUdn6pDeagbnW /lp4KMdef8aEfThr7Q5q5zTGGEHrjaZZFf/45dYvIg3ESNsUXFz8SgbJOfFhu41qqC JUtLM/M2PvyHHQE8BdvJgIhZmmmi7QvgslgiGpKxxfvHvo4pblxk9n4WFT7w2FNso7 XFK7wE5IMCLfIp8/a9dA5W6OCZ9Qv7LGm4Tbim/PAe16F/sNtZrepSr3cuoEuPcoyo lJ/fJKzq/oUjA== User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Vr-Srcip: 92.154.11.170 X-Vr-Score: -100 X-Vr-Cause-1: gggruggvucftvghtrhhoucdtuddrfeelfedrhedtgddtvdcutefuodetggdotefrodftvfcurfhrohhf X-Vr-Cause-2: ihhlvgemucfntefrqffuvffgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhs X-Vr-Cause-3: ucdlqddutddtmdenucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefu X-Vr-Cause-4: vggsrghsthhirghnucfhrhhirghsuceoshhfkeegsehlrghpohhsthgvrdhnvghtqeenucfkphepledv X-Vr-Cause-5: rdduheegrdduuddrudejtdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopegludej X-Vr-Cause-6: vddrvdejrddtrddvudegngdpihhnvghtpeelvddrudehgedruddurddujedtpdhmrghilhhfrhhomhep X-Vr-Cause-7: shhfkeegsehlrghpohhsthgvrdhnvghtpdhrtghpthhtohepthhorhhvrghlughssehlihhnuhigqdhf X-Vr-Cause-8: ohhunhgurghtihhonhdrohhrgh X-Vr-Avstate: No Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 27 Organization: linux.* mail to news gateway X-Original-Cc: zijun_hu , Andrew Morton , Linux Kernel Mailing List , Mason , Harvey Harrison , Borislav Petkov X-Original-Date: Tue, 6 Dec 2016 11:10:02 +0100 X-Original-Message-ID: <9d74aaf8-a328-a3a6-dcaa-9ade95538241@laposte.net> X-Original-References: <93523b80-6033-bafa-c1ec-4bc2c3f9c53b@laposte.net> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1536841 On 05/12/16 19:23, Linus Torvalds wrote: > On Mon, Dec 5, 2016 at 9:49 AM, Sebastian Frias wrote: >> Introduce GENVALUE(msb, lsb, value) macro to ease dealing with >> continuous bitfields, just as BIT(x) does for single bits. > > Oh, and looking at the implementation, this is wrong. You use "lsb" > twice, so it mustn't have side effects. > > That's fine for all expected users (since you'd expect that the only > real use of this is with constant values for msb/lsb), Yes, that's what I thought. >but please add > actual checking. Sure! Thanks for the advice. > > You can use BUILD_BUG_ON_ZERO(!__builtin_constant_p(x)) or something. > That returns zero, so it's easy to use in expressions. Done. v3 of the patch is submitted. > > Linus >