[lkml]   [2000]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
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.)


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

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