Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752956AbdLMAhJ (ORCPT ); Tue, 12 Dec 2017 19:37:09 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:39924 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752877AbdLMAhC (ORCPT ); Tue, 12 Dec 2017 19:37:02 -0500 Date: Wed, 13 Dec 2017 00:36:59 +0000 From: Al Viro To: Jakub Kicinski Cc: Linus Torvalds , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH] new byteorder primitives - ..._{replace,get}_bits() Message-ID: <20171213003659.GA21978@ZenIV.linux.org.uk> References: <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> <20171212194532.GA7062@ZenIV.linux.org.uk> <20171212120409.64b6362e@cakuba.netronome.com> <20171212234856.GZ21978@ZenIV.linux.org.uk> <20171212155933.03c88eab@cakuba.netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171212155933.03c88eab@cakuba.netronome.com> User-Agent: Mutt/1.9.0 (2017-09-02) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 663 Lines: 14 On Tue, Dec 12, 2017 at 03:59:33PM -0800, Jakub Kicinski wrote: > > +static __always_inline __##type type##_replace_bits(__##type old, \ > > + base val, base mask) \ > > +{ \ > > + __##type m = to(mask); \ > > + if (__builtin_constant_p(val) && \ > > Is the lack of a __builtin_constant_p(mask) test intentional? Sometimes > the bitfield is a packed array and people may have a helper to which > only the mask is passed as non-constant and the value is implied by the > helper, thus constant. If the mask in non-constant, we probably shouldn't be using that at all; could you show a real-world example where that would be the case?