Messages in this thread | | | Date | Mon, 21 Aug 2000 08:49:44 -0700 (PDT) | From | dean gaudet <> | Subject | Re: [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/
| |