lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 7 Dec 2016 11:00:57 +0100
From:   Sebastian Frias <sf84@...oste.net>
To:     Kalle Valo <kvalo@...eaurora.org>
Cc:     zijun_hu <zijun_hu@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        linux-kernel@...r.kernel.org,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Mason <slash.tmp@...e.fr>,
        Harvey Harrison <harvey.harrison@...il.com>,
        Borislav Petkov <bp@...en8.de>,
        Jakub Kicinski <jakub.kicinski@...ronome.com>
Subject: Re: [PATCH v3] add equivalent of BIT(x) for bitfields

On 07/12/16 09:42, Kalle Valo wrote:
> Sebastian Frias <sf84@...oste.net> writes:
> 
>> Introduce GENVALUE(msb, lsb, value) macro to ease dealing with
>> continuous bitfields, just as BIT(x) does for single bits.
>>
>> GENVALUE_ULL(msb, lsb, value) macro is also added.
>>
>> This is useful mostly for creating values to be packed together
>> via OR operations, ex:
>>
>>    u32 val = 0x11110000;
>>    val |= GENVALUE(19, 12, 0x5a);
>>
>> now 'val = 0x1115a000'
>>
>>
>> Signed-off-by: Sebastian Frias <sf84@...oste.net>
>> Link: https://marc.info/?l=linux-kernel&m=148094498711000&w=2
>> ---
>>
>> Change in v2:
>> - rename the macro to GENVALUE as proposed by Linus
>> - longer comment attempts to show use case for the macro as
>> proposed by Borislav
>>
>> Change in v3:
>> - use BUILD_BUG_ON_ZERO() to break if some input parameters
>> (essentially 'lsb' but also 'msb') are not constants as
>> proposed by Linus.
>> Indeed, 'lsb' is used twice so it cannot have side-effects;
>> 'msb' is subjected to same constraints for consistency.
> 
> (I missed there was v3 already, but I'll repeat what I said in v1.)
> 
> Please check FIELD_PREP() from include/linux/bitfield.h, doesn't it
> already do the same?

Indeed, it appears to do the same :-)
Any reason why "include/linux/bitfield.h" is not included by default in
bitops.h?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ