Re: svn commit: r273274 - head/sys/netpfil/ipfw

2014-10-21 Thread Dag-Erling Smørgrav
Luigi Rizzo writes: > This code is not performance critical. I wouldn't bother optimizing it. So just use fls() or flsl(). DES -- Dag-Erling Smørgrav - d...@des.no ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn

Re: svn commit: r273274 - head/sys/netpfil/ipfw

2014-10-21 Thread Luigi Rizzo
On Sun, Oct 19, 2014 at 03:02:07PM +0300, Andriy Gapon wrote: > On 19/10/2014 14:15, Alexander V. Chernikov wrote: > > +static uint32_t > > +roundup2p(uint32_t v) > > +{ > > + > > + v--; > > + v |= v >> 1; > > + v |= v >> 2; > > + v |= v >> 4; > > + v |= v >> 8; > > + v |= v >> 16; > >

Re: svn commit: r273274 - head/sys/netpfil/ipfw

2014-10-21 Thread Bruce Evans
On Tue, 21 Oct 2014, David Chisnall wrote: On 19 Oct 2014, at 13:02, Andriy Gapon wrote: I think that on platforms where an optimized version of fls() is available that would work faster than this cool piece of bit magic. Even a lightly optimized naive linear search might work faster. The

Re: svn commit: r273274 - head/sys/netpfil/ipfw

2014-10-21 Thread David Chisnall
On 19 Oct 2014, at 13:02, Andriy Gapon wrote: > I think that on platforms where an optimized version of fls() is available > that > would work faster than this cool piece of bit magic. If you're lucky, the compiler's idiom recogniser will spot this. You're generally better off using the built

Re: svn commit: r273274 - head/sys/netpfil/ipfw

2014-10-20 Thread Bruce Simpson
On Sun, 19 Oct 2014, at 13:02, Andriy Gapon wrote: > I think that on platforms where an optimized version of fls() is > available that > would work faster than this cool piece of bit magic. This is a common enough idiom that perhaps a macro should be added: sys/param.h: #define roundup(x, y)

Re: svn commit: r273274 - head/sys/netpfil/ipfw

2014-10-19 Thread Andriy Gapon
On 19/10/2014 14:15, Alexander V. Chernikov wrote: > +static uint32_t > +roundup2p(uint32_t v) > +{ > + > + v--; > + v |= v >> 1; > + v |= v >> 2; > + v |= v >> 4; > + v |= v >> 8; > + v |= v >> 16; > + v++; > + > + return (v); > +} I think that on platforms where a

svn commit: r273274 - head/sys/netpfil/ipfw

2014-10-19 Thread Alexander V. Chernikov
Author: melifaro Date: Sun Oct 19 11:15:19 2014 New Revision: 273274 URL: https://svnweb.freebsd.org/changeset/base/273274 Log: Perform more checks on the number of tables supplied by user. Modified: head/sys/netpfil/ipfw/ip_fw_table.c Modified: head/sys/netpfil/ipfw/ip_fw_table.c ==