On Fri, Sep 28, 2012 at 3:39 PM, Willy Tarreau <[email protected]> wrote:

> On Fri, Sep 28, 2012 at 03:32:37PM +0800, Robin Lee wrote:
> > Hi, I just began reading the code of HAproxy.
> >
> > I am confused a bit with the operations about fd_evts. The comment says:
> >
> > /* Each 32-bit word contains 2-bit descriptors of the latest state for 16
> > FDs :
> >  *   desc = (u32 >> (2*fd)) & 3
> >
> > Should that actually be
> >      desc = (u32 >> FD2BIT(fd)) & 3
> >
> > (2*fd) may be larger than 32.
>
> Yes but as you can see it's just a comment explaining the general principle
> (and BTW you got it right). If you look at the code you can find
> FD2BIT(fd).
>
> And for what it's worth, most archs automatically trim bit counts during
> shifts, so even without the mask it will work, though I would definitely
> not rely on this !
>
> Regards,
> Willy
>
Thank you!

Reply via email to