All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vignesh Babu BM <vignesh.babu@wipro.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] anyone interested in the "power of 2" stuff?
Date: Tue, 13 Feb 2007 10:38:48 +0000	[thread overview]
Message-ID: <1171362408.20656.6.camel@wriver-t81fb058.linuxcoe> (raw)
In-Reply-To: <Pine.LNX.4.64.0702081713530.5222@localhost.localdomain>

On Tue, 2007-02-13 at 04:46 -0500, Robert P. J. Day wrote:
> On Tue, 13 Feb 2007, Vignesh Babu BM wrote:
> 
> >
> > I have a doubt:
> > There are instances as follows:
> >
> > if(!iobase_reg && !is_power_of_2(iobase_reg))
> > ---where we are checking for 0 at 2 places-both inside and outside of
> > is_power_of_2
> >
> > But the n & (n-1) is just one step.
> > Is this not more optimised?
> >
> > What would you suggest here?
> 

> and while that might seem *superficially* almost the same thing,
> semantically it's quite different.
Agreed.

> 
> it might be worth defining a macro:
> 
>   #define at_most_one_bit_set(n)      ((n) & ((n) - 1))
> 
> thoughts?
> 
> rday
> 

There are around 80 instances of code similar to the above. So instead
of a macro why not do an inline function?
And btw where would it go?

-- 
Regards,  
Vignesh Babu BM  
_____________________________________________________________  
"Why is it that every time I'm with you, makes me believe in magic?"
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

  parent reply	other threads:[~2007-02-13 10:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08 22:17 [KJ] anyone interested in the "power of 2" stuff? Robert P. J. Day
2007-02-09  5:18 ` Vignesh Babu BM
2007-02-09 12:39 ` Robert P. J. Day
2007-02-13  9:04 ` Vignesh Babu BM
2007-02-13  9:46 ` Robert P. J. Day
2007-02-13 10:38 ` Vignesh Babu BM [this message]
2007-02-13 11:56 ` Robert P. J. Day

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1171362408.20656.6.camel@wriver-t81fb058.linuxcoe \
    --to=vignesh.babu@wipro.com \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.