From: Al Viro Subject: Re: [RFC][PATCH] new byteorder primitives - ..._{replace,get}_bits() Date: Tue, 12 Dec 2017 19:45:32 +0000 Message-ID: <20171212194532.GA7062@ZenIV.linux.org.uk> References: <20171210045326.GO21978@ZenIV.linux.org.uk> <420a198d-61f8-81cf-646d-10446cb41def@synopsys.com> <20171211050520.GV21978@ZenIV.linux.org.uk> <20171211053803.GW21978@ZenIV.linux.org.uk> <20171211155422.GA12326@ZenIV.linux.org.uk> <20171211200224.23bc5df4@cakuba.netronome.com> <20171212062002.GY21978@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Linus Torvalds , netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: Jakub Kicinski Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:33292 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbdLLTpe (ORCPT ); Tue, 12 Dec 2017 14:45:34 -0500 Content-Disposition: inline In-Reply-To: <20171212062002.GY21978@ZenIV.linux.org.uk> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, Dec 12, 2017 at 06:20:02AM +0000, Al Viro wrote: > Umm... What's wrong with > > #define FIELD_FOO 0,4 > #define FIELD_BAR 6,12 > #define FIELD_BAZ 18,14 > > A macro can bloody well expand to any sequence of tokens - le32_get_bits(v, FIELD_BAZ) > will become le32_get_bits(v, 18, 14) just fine. What's the problem with that? FWIW, if you want to use the mask, __builtin_ffsll() is not the only way to do it - you don't need the shift. Multiplier would do just as well, and that can be had easier. If mask = (2*a + 1)<