Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1536843

Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields

From Geert Uytterhoeven <geert@linux-m68k.org>
Newsgroups linux.kernel
Subject Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields
Date 2016-12-06 11:50 +0100
Message-ID <sLltU-UD-3@gated-at.bofh.it> (permalink)
References <sL1ER-58Y-23@gated-at.bofh.it> <sL5yO-7xB-41@gated-at.bofh.it> <sLlke-Rj-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Dec 6, 2016 at 11:31 AM, Sebastian Frias <sf84@laposte.net> wrote:
> On 05/12/16 18:48, Geert Uytterhoeven wrote:
>> On Mon, Dec 5, 2016 at 2:36 PM, Sebastian Frias <sf84@laposte.net> wrote:
>>> Introduce SETBITFIELD(msb, lsb, value) macro to ease dealing with
>>> continuous bitfields, just as BIT(x) does for single bits.
>>
>> If it's a bitfield, why not calling it that way?
>
> I don't know if you saw v2 (or v3 for that matter), but the name was changed
> to GENVALUE.

... which means "generate a value"??

> Also a small use case was added to the commit message:
>
> "Introduce GENVALUE(msb, lsb, value) macro..."
> "...This is useful mostly for creating values to be packed together
> via OR operations, ex:
>
>    u32 val = 0x11110000;
>    val |= GENVALUE(19, 12, 0x5a);

"val |= 0x5a << 12;" looks much more readable to me...

> now 'val = 0x1115a000'"
>
>> So what about BITFIELD(start ,size), like arch/tile/kernel/tile-desc_32.c has?
>>
>>> SETBITFIELD_ULL(msb, lsb, value) macro is also added.
>>
>> Confused by the need for a "value" parameter...
>
> "value" is the value to be massaged (shifted, masked) into a [msb:lsb] bitfield.

OK. So it inserts a value into a bitfield.

Yes, that can be useful. Now let's find a sensible name for this.
Perhaps inspired by a PowerPC mnemonic? At least that would be more
obvious than "GENVALUE", IMHO...

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] bitops: add equivalent of BIT(x) for bitfields Sebastian Frias <sf84@laposte.net> - 2016-12-05 14:40 +0100
  Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Borislav Petkov <bp@alien8.de> - 2016-12-05 16:40 +0100
    Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Sebastian Frias <sf84@laposte.net> - 2016-12-05 18:30 +0100
  Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-05 18:20 +0100
    Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Sebastian Frias <sf84@laposte.net> - 2016-12-05 18:50 +0100
  Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Geert Uytterhoeven <geert@linux-m68k.org> - 2016-12-05 18:50 +0100
    Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Sebastian Frias <sf84@laposte.net> - 2016-12-06 11:40 +0100
      Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Geert Uytterhoeven <geert@linux-m68k.org> - 2016-12-06 11:50 +0100
        Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Sebastian Frias <sf84@laposte.net> - 2016-12-06 12:10 +0100
          Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Geert Uytterhoeven <geert@linux-m68k.org> - 2016-12-06 12:40 +0100
            Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Sebastian Frias <sf84@laposte.net> - 2016-12-06 16:00 +0100
  Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields Kalle Valo <kvalo@codeaurora.org> - 2016-12-07 09:40 +0100

csiph-web