From: William Lee Irwin III <wli@holomorphy.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-arch@vger.kernel.org
Subject: Re: find_next_bit return type
Date: Sun, 1 Aug 2004 04:53:34 -0700 [thread overview]
Message-ID: <20040801115334.GP2334@holomorphy.com> (raw)
In-Reply-To: <20040731232434.7263b50c.akpm@osdl.org>
On Sat, Jul 31, 2004 at 11:24:34PM -0700, Andrew Morton wrote:
> Seems that several 64-bit architectures are returning longs from
> find_next_bit(), find_next_zero_bit(), etc. x86 returns an int. wli sent
> me a patch which does
> return min(NR_CPUS, find_first_bit(srcp->bits, nbits));
> so these architectures now get a zillion warnings.
> We should be consistent here. Is there any reason why these functions
> cannot return integers?
Not in particular, no. I'd sort of like 64-bit arches to keep their
natural wordsize as the return value as davem pointed out sign
extensions, conversions, etc. are overheads there.
To address this without a negative impact on 64-bit architectures and
to have the least code impact possible, I'd recommend the following.
(sparc32 obviously doesn't care about this issue either way)
-- wli
Index: hotplug-2.6.8-rc2/include/linux/cpumask.h
===================================================================
--- hotplug-2.6.8-rc2.orig/include/linux/cpumask.h 2004-07-29 04:44:59.000000000 -0700
+++ hotplug-2.6.8-rc2/include/linux/cpumask.h 2004-08-01 04:32:56.572244384 -0700
@@ -207,13 +207,13 @@
#define first_cpu(src) __first_cpu(&(src), NR_CPUS)
static inline int __first_cpu(const cpumask_t *srcp, int nbits)
{
- return find_first_bit(srcp->bits, nbits);
+ return min_t(int, NR_CPUS, find_first_bit(srcp->bits, nbits));
}
#define next_cpu(n, src) __next_cpu((n), &(src), NR_CPUS)
static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits)
{
- return find_next_bit(srcp->bits, nbits, n+1);
+ return min_t(int, NR_CPUS, find_next_bit(srcp->bits, nbits, n+1));
}
#define cpumask_of_cpu(cpu) \
next prev parent reply other threads:[~2004-08-01 11:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-01 6:24 find_next_bit return type Andrew Morton
2004-08-01 6:25 ` Andrew Morton
2004-08-01 6:58 ` David S. Miller
2004-08-01 7:02 ` Andrew Morton
2004-08-01 7:10 ` David S. Miller
2004-08-02 10:40 ` Andi Kleen
2004-08-01 6:25 ` Andrew Morton
2004-08-01 6:26 ` Andrew Morton
2004-08-01 11:53 ` William Lee Irwin III [this message]
2004-08-01 13:51 ` William Lee Irwin III
2004-08-01 15:05 ` James Bottomley
2004-08-01 15:07 ` William Lee Irwin III
2004-08-01 22:09 ` Paul Mackerras
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=20040801115334.GP2334@holomorphy.com \
--to=wli@holomorphy.com \
--cc=akpm@osdl.org \
--cc=linux-arch@vger.kernel.org \
/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