On Wed, 05 Apr 2023, Steven Price wrote:
> On 31/03/2023 09:31, Jani Nikula wrote:
>> On Thu, 30 Mar 2023, Andrew Morton wrote:
>>> On Thu, 30 Mar 2023 21:53:03 + David Laight
>>> wrote:
>>>
> But wouldn't all these issues be addressed by simply doing
>
> #define
On 31/03/2023 09:31, Jani Nikula wrote:
> On Thu, 30 Mar 2023, Andrew Morton wrote:
>> On Thu, 30 Mar 2023 21:53:03 + David Laight
>> wrote:
>>
But wouldn't all these issues be addressed by simply doing
#define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0))
?
On Thu, 30 Mar 2023, Andrew Morton wrote:
> On Thu, 30 Mar 2023 21:53:03 + David Laight
> wrote:
>
>> > But wouldn't all these issues be addressed by simply doing
>> >
>> > #define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0))
>> >
>> > ?
>> >
>> > (With suitable tweaks to avoid
From: Andrew Morton
> Sent: 30 March 2023 23:19
>
> On Thu, 30 Mar 2023 21:53:03 + David Laight
> wrote:
>
> > > But wouldn't all these issues be addressed by simply doing
> > >
> > > #define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0))
> > >
> > > ?
> > >
> > > (With suitable tweaks
On Thu, 30 Mar 2023 21:53:03 + David Laight wrote:
> > But wouldn't all these issues be addressed by simply doing
> >
> > #define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0))
> >
> > ?
> >
> > (With suitable tweaks to avoid evaluating `n' more than once)
>
> I think you need to use
From: Andrew Morton
> Sent: 30 March 2023 20:51
>
> On Thu, 30 Mar 2023 13:42:39 +0300 Jani Nikula wrote:
>
> > is_power_of_2() only works for types <= sizeof(unsigned long) and it's
> > also not a constant expression. There are a number of places in kernel
> > where is_power_of_2() is called
On Thu, 30 Mar 2023 13:42:39 +0300 Jani Nikula wrote:
> is_power_of_2() only works for types <= sizeof(unsigned long) and it's
> also not a constant expression. There are a number of places in kernel
> where is_power_of_2() is called on u64, which fails on 32-bit
> builds. Try to remedy that.
Am 30.03.23 um 12:42 schrieb Jani Nikula:
is_power_of_2() only works for types <= sizeof(unsigned long) and it's
also not a constant expression. There are a number of places in kernel
where is_power_of_2() is called on u64, which fails on 32-bit
builds. Try to remedy that. While at it, make it a
is_power_of_2() only works for types <= sizeof(unsigned long) and it's
also not a constant expression. There are a number of places in kernel
where is_power_of_2() is called on u64, which fails on 32-bit
builds. Try to remedy that. While at it, make it a constant expression
when possible.
I admit