Search Linux Wireless

Re: [PATCH] bitfield: add FIELD_PREP_CONST()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2023-01-18 at 17:49 +0100, Alexander Lobakin wrote:
> 
> Aaaah right. Seems like we can't avoid introducing a separate macro for
> that. I like the idea of your patch anyways!

:)

> One note re __BF_CHECK_POW2(): can't we reuse is_power_of_2() anyhow?
> Foe example, by deriving the code of the latter into a macro and then
> using it in both?
> 

Well, not directly - for example is_power_of_2() doesn't accept 0, while
we want to accept 0 (mask being e.g. "0xfull<<60", we already check for
mask != 0).

I thought about __BUILD_BUG_ON_NOT_POWER_OF_2 but it uses BUILD_BUG_ON,
not BUILD_BUG_ON_ZERO, and BUILD_BUG_ON is nicer in most contexts ...

So you could pull out the expression "((n) & ((n) - 1)) != 0" from all
four of these, but it doesn't feel worth it.

johannes




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux