lkml.org 
[lkml]   [2000]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] resizeable printk ring buffer


On Mon, 21 Aug 2000, Paul Gortmaker wrote:

> + i = 128;
> + while (i != len && i != 4) i>>=1;
> + if (i != len)
> + goto out;

just as an aside, there's a cute operation which tells you if there's
exactly 1 bit on in a word, which in this case would look like:

if (len & (len - 1))
goto out; /* not a power of 2 */

it's easiest to prove it with pencil and paper, and represent len in
binary form.

(there's a natural extension of this to counting 1-bits in a word...
which is a fun interview question i hear.)

-dean

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:37    [W:0.027 / U:2.660 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site