From: Matthew Dobson <colpatch@us.ibm.com>
To: Paul Jackson <pj@sgi.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Martin J. Bligh" <mbligh@aracnet.com>,
Andrew Morton <akpm@osdl.org>,
William Lee Irwin III <wli@holomorphy.com>,
Dave Hansen <haveblue@us.ibm.com>
Subject: Re: [PATCH] mask ADT: bitmap and bitop tweaks [1/22]
Date: Mon, 29 Mar 2004 15:06:16 -0800 [thread overview]
Message-ID: <1080601576.6742.43.camel@arrakis> (raw)
In-Reply-To: <20040329041249.65d365a1.pj@sgi.com>
On Mon, 2004-03-29 at 04:12, Paul Jackson wrote:
> Patch_1_of_22 - Underlying bitmap/bitop details, added ops
> Add a couple of 'const' qualifiers
> Add intersects, subset, xor and andnot operators.
> Fix some unused bits in bitmap_complement
> Change bitmap_complement to take two operands.
<snip>
> diff -Nru a/lib/bitmap.c b/lib/bitmap.c
> --- a/lib/bitmap.c Mon Mar 29 01:03:26 2004
> +++ b/lib/bitmap.c Mon Mar 29 01:03:26 2004
> @@ -45,7 +45,7 @@
> EXPORT_SYMBOL(bitmap_full);
>
> int bitmap_equal(const unsigned long *bitmap1,
> - unsigned long *bitmap2, int bits)
> + const unsigned long *bitmap2, int bits)
> {
> int k, lim = bits/BITS_PER_LONG;;
> for (k = 0; k < lim; ++k)
Double `;`? You didn't put it there, but it seems that...
> @@ -61,13 +61,14 @@
> }
> EXPORT_SYMBOL(bitmap_equal);
>
> -void bitmap_complement(unsigned long *bitmap, int bits)
> +void bitmap_complement(unsigned long *dst, const unsigned long *src, int bits)
> {
> - int k;
> - int nr = BITS_TO_LONGS(bits);
> + int k, lim = bits/BITS_PER_LONG;;
> + for (k = 0; k < lim; ++k)
> + dst[k] = ~src[k];
...you propagated the error...
> +int bitmap_intersects(const unsigned long *bitmap1,
> + const unsigned long *bitmap2, int bits)
> +{
> + int k, lim = bits/BITS_PER_LONG;;
...a couple times...
> + for (k = 0; k < lim; ++k)
> + if (bitmap1[k] & bitmap2[k])
> + return 1;
> +
> + if (bits % BITS_PER_LONG)
> + if ((bitmap1[k] & bitmap2[k]) &
> + ((1UL << (bits % BITS_PER_LONG)) - 1))
> + return 1;
> + return 0;
> +}
> +EXPORT_SYMBOL(bitmap_intersects);
Do we need to check the last word specially? If we're assuming that the
unused bits are 0's, then they can't affect the check, right? If we're
not assuming the unused bits are 0's, then we need to do this last word
special casing in bitmap_xor & bitmap_andnot, because they could set the
unused bits. Or am I confused?
> +int bitmap_subset(const unsigned long *bitmap1,
> + const unsigned long *bitmap2, int bits)
> +{
> + int k, lim = bits/BITS_PER_LONG;;
> + for (k = 0; k < lim; ++k)
> + if (bitmap1[k] & ~bitmap2[k])
> + return 0;
> +
> + if (bits % BITS_PER_LONG)
> + if ((bitmap1[k] & ~bitmap2[k]) &
> + ((1UL << (bits % BITS_PER_LONG)) - 1))
> + return 0;
> + return 1;
> +}
> +EXPORT_SYMBOL(bitmap_subset);
Same comments here, both the double ';' and the last word special
casing...
Looking ahead, patch 2/22 specifically states that we assume all our
input masks have the high/unused bits cleared and we promise not to set
them. So we shouldn't need the last word special casing in
bitmap_intersect & bitmap_subset... I think. ;)
-Matt
next prev parent reply other threads:[~2004-03-29 23:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-29 12:12 [PATCH] mask ADT: bitmap and bitop tweaks [1/22] Paul Jackson
2004-03-29 23:06 ` Matthew Dobson [this message]
2004-03-29 23:52 ` William Lee Irwin III
2004-03-29 23:43 ` Paul Jackson
2004-03-30 1:27 ` Matthew Dobson
2004-03-30 2:06 ` William Lee Irwin III
2004-03-30 1:46 ` Paul Jackson
2004-03-30 2:55 ` William Lee Irwin III
2004-03-30 5:09 ` Paul Jackson
2004-03-30 6:36 ` William Lee Irwin III
2004-03-30 8:00 ` Paul Jackson
2004-03-30 9:22 ` William Lee Irwin III
2004-03-29 23:50 ` Paul Jackson
2004-03-30 15:53 ` Chris Friesen
2004-03-30 18:30 ` Paul Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1080601576.6742.43.camel@arrakis \
--to=colpatch@us.ibm.com \
--cc=akpm@osdl.org \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mbligh@aracnet.com \
--cc=pj@sgi.com \
--cc=wli@holomorphy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox