Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1536841
| From | Sebastian Frias <sf84@laposte.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] add equivalent of BIT(x) for bitfields |
| Date | 2016-12-06 11:40 +0100 |
| Message-ID | <sLlke-Rj-25@gated-at.bofh.it> (permalink) |
| References | <sL5yO-7xB-29@gated-at.bofh.it> <sL6bv-84q-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 05/12/16 19:23, Linus Torvalds wrote: > 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), 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 >
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v2] add equivalent of BIT(x) for bitfields Sebastian Frias <sf84@laposte.net> - 2016-12-05 18:50 +0100
Re: [PATCH v2] add equivalent of BIT(x) for bitfields Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-05 19:30 +0100
Re: [PATCH v2] add equivalent of BIT(x) for bitfields Sebastian Frias <sf84@laposte.net> - 2016-12-06 11:40 +0100
csiph-web