* [PATCH] Add the macro to test if "exactly_one_bit_set" to log2.h.
@ 2007-11-06 16:38 Robert P. J. Day
2007-11-06 18:11 ` Boaz Harrosh
2007-11-09 4:36 ` Andrew Morton
0 siblings, 2 replies; 6+ messages in thread
From: Robert P. J. Day @ 2007-11-06 16:38 UTC (permalink / raw)
To: Linux Kernel Mailing List; +Cc: Andrew Morton, matthew
While this macro is defined in terms of "is_power_of_2" and is
therefore functionally equivalent, the visual semantics are sometimes
more appropriate for what is actually being tested.
Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
---
diff --git a/include/linux/log2.h b/include/linux/log2.h
index c8cf5e8..d0d324e 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -55,6 +55,12 @@ bool is_power_of_2(unsigned long n)
}
/*
+ * And for folks who want slightly different semantics ...
+ */
+
+#define exactly_one_bit_set is_power_of_2
+
+/*
* round up to nearest power of two
*/
static inline __attribute__((const))
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://crashcourse.ca
========================================================================
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Add the macro to test if "exactly_one_bit_set" to log2.h.
2007-11-06 16:38 [PATCH] Add the macro to test if "exactly_one_bit_set" to log2.h Robert P. J. Day
@ 2007-11-06 18:11 ` Boaz Harrosh
2007-11-06 18:53 ` Robert P. J. Day
2007-11-09 4:36 ` Andrew Morton
1 sibling, 1 reply; 6+ messages in thread
From: Boaz Harrosh @ 2007-11-06 18:11 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: Linux Kernel Mailing List, Andrew Morton, matthew
On Tue, Nov 06 2007 at 18:38 +0200, "Robert P. J. Day" <rpjday@crashcourse.ca> wrote:
> While this macro is defined in terms of "is_power_of_2" and is
> therefore functionally equivalent, the visual semantics are sometimes
> more appropriate for what is actually being tested.
>
> Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
>
> ---
>
> diff --git a/include/linux/log2.h b/include/linux/log2.h
> index c8cf5e8..d0d324e 100644
> --- a/include/linux/log2.h
> +++ b/include/linux/log2.h
> @@ -55,6 +55,12 @@ bool is_power_of_2(unsigned long n)
> }
>
> /*
> + * And for folks who want slightly different semantics ...
> + */
> +
> +#define exactly_one_bit_set is_power_of_2
at_most_one_bit_set No?
> +
> +/*
> * round up to nearest power of two
> */
> static inline __attribute__((const))
Boaz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add the macro to test if "exactly_one_bit_set" to log2.h.
2007-11-06 18:11 ` Boaz Harrosh
@ 2007-11-06 18:53 ` Robert P. J. Day
2007-11-07 9:17 ` Boaz Harrosh
0 siblings, 1 reply; 6+ messages in thread
From: Robert P. J. Day @ 2007-11-06 18:53 UTC (permalink / raw)
To: Boaz Harrosh; +Cc: Linux Kernel Mailing List, Andrew Morton, matthew
On Tue, 6 Nov 2007, Boaz Harrosh wrote:
> On Tue, Nov 06 2007 at 18:38 +0200, "Robert P. J. Day" <rpjday@crashcourse.ca> wrote:
> > While this macro is defined in terms of "is_power_of_2" and is
> > therefore functionally equivalent, the visual semantics are sometimes
> > more appropriate for what is actually being tested.
> >
> > Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
> >
> > ---
> >
> > diff --git a/include/linux/log2.h b/include/linux/log2.h
> > index c8cf5e8..d0d324e 100644
> > --- a/include/linux/log2.h
> > +++ b/include/linux/log2.h
> > @@ -55,6 +55,12 @@ bool is_power_of_2(unsigned long n)
> > }
> >
> > /*
> > + * And for folks who want slightly different semantics ...
> > + */
> > +
> > +#define exactly_one_bit_set is_power_of_2
>
> at_most_one_bit_set No?
no, it really is *exactly* one bit set. zero is not considered a
power of two.
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://crashcourse.ca
========================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add the macro to test if "exactly_one_bit_set" to log2.h.
2007-11-06 18:53 ` Robert P. J. Day
@ 2007-11-07 9:17 ` Boaz Harrosh
0 siblings, 0 replies; 6+ messages in thread
From: Boaz Harrosh @ 2007-11-07 9:17 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: Linux Kernel Mailing List
On Tue, Nov 06 2007 at 20:53 +0200, "Robert P. J. Day" <rpjday@crashcourse.ca> wrote:
> On Tue, 6 Nov 2007, Boaz Harrosh wrote:
>
>> On Tue, Nov 06 2007 at 18:38 +0200, "Robert P. J. Day" <rpjday@crashcourse.ca> wrote:
>>> While this macro is defined in terms of "is_power_of_2" and is
>>> therefore functionally equivalent, the visual semantics are sometimes
>>> more appropriate for what is actually being tested.
>>>
>>> Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
>>>
>>> ---
>>>
>>> diff --git a/include/linux/log2.h b/include/linux/log2.h
>>> index c8cf5e8..d0d324e 100644
>>> --- a/include/linux/log2.h
>>> +++ b/include/linux/log2.h
>>> @@ -55,6 +55,12 @@ bool is_power_of_2(unsigned long n)
>>> }
>>>
>>> /*
>>> + * And for folks who want slightly different semantics ...
>>> + */
>>> +
>>> +#define exactly_one_bit_set is_power_of_2
>> at_most_one_bit_set No?
>
> no, it really is *exactly* one bit set. zero is not considered a
> power of two.
>
> rday
Yes, Sorry for the noise it was late and I should have returned to
the kids instead of reading lkml.
Boaz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add the macro to test if "exactly_one_bit_set" to log2.h.
2007-11-06 16:38 [PATCH] Add the macro to test if "exactly_one_bit_set" to log2.h Robert P. J. Day
2007-11-06 18:11 ` Boaz Harrosh
@ 2007-11-09 4:36 ` Andrew Morton
2007-11-09 5:09 ` Robert P. J. Day
1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2007-11-09 4:36 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: linux-kernel, matthew
> On Tue, 6 Nov 2007 11:38:52 -0500 (EST) "Robert P. J. Day" <rpjday@crashcourse.ca> wrote:
>
> While this macro is defined in terms of "is_power_of_2" and is
> therefore functionally equivalent, the visual semantics are sometimes
> more appropriate for what is actually being tested.
>
This is gettig a bit anal, but I guess you're the is_power_of_2 maintainer.
> ---
>
> diff --git a/include/linux/log2.h b/include/linux/log2.h
> index c8cf5e8..d0d324e 100644
> --- a/include/linux/log2.h
> +++ b/include/linux/log2.h
> @@ -55,6 +55,12 @@ bool is_power_of_2(unsigned long n)
> }
>
> /*
> + * And for folks who want slightly different semantics ...
> + */
> +
> +#define exactly_one_bit_set is_power_of_2
And I'm the dont-code-in-cpp-when-you-could-code-in-C maintainer.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add the macro to test if "exactly_one_bit_set" to log2.h.
2007-11-09 4:36 ` Andrew Morton
@ 2007-11-09 5:09 ` Robert P. J. Day
0 siblings, 0 replies; 6+ messages in thread
From: Robert P. J. Day @ 2007-11-09 5:09 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, matthew
On Thu, 8 Nov 2007, Andrew Morton wrote:
> > On Tue, 6 Nov 2007 11:38:52 -0500 (EST) "Robert P. J. Day" <rpjday@crashcourse.ca> wrote:
> >
> > While this macro is defined in terms of "is_power_of_2" and is
> > therefore functionally equivalent, the visual semantics are
> > sometimes more appropriate for what is actually being tested.
>
> This is gettig a bit anal, but I guess you're the is_power_of_2
> maintainer.
>
> > ---
> >
> > diff --git a/include/linux/log2.h b/include/linux/log2.h
> > index c8cf5e8..d0d324e 100644
> > --- a/include/linux/log2.h
> > +++ b/include/linux/log2.h
> > @@ -55,6 +55,12 @@ bool is_power_of_2(unsigned long n)
> > }
> >
> > /*
> > + * And for folks who want slightly different semantics ...
> > + */
> > +
> > +#define exactly_one_bit_set is_power_of_2
actually, i could go either way on this one. it wasn't originally my
idea, but i tossed it out there because i have, in fact, seen comments
that explicitly said something along the lines of "make sure that
exactly one bit is set". so i'll leave it up to someone else to
decide whether it should go in. it's not something i'm going to go to
the mats over one way or the other.
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://crashcourse.ca
========================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-11-09 5:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-06 16:38 [PATCH] Add the macro to test if "exactly_one_bit_set" to log2.h Robert P. J. Day
2007-11-06 18:11 ` Boaz Harrosh
2007-11-06 18:53 ` Robert P. J. Day
2007-11-07 9:17 ` Boaz Harrosh
2007-11-09 4:36 ` Andrew Morton
2007-11-09 5:09 ` Robert P. J. Day
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox