lkml.org 
[lkml]   [2016]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] add equivalent of BIT(x) for bitfields
On Mon, Dec 5, 2016 at 9:49 AM, Sebastian Frias <sf84@laposte.net> 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), but please add
actual checking.

You can use BUILD_BUG_ON_ZERO(!__builtin_constant_p(x)) or something.
That returns zero, so it's easy to use in expressions.

Linus

\
 
 \ /
  Last update: 2016-12-05 19:23    [W:0.434 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site