summaryrefslogtreecommitdiff
path: root/include/linux/cpumask.h
diff options
context:
space:
mode:
authorWilliam Lee Irwin III <wli@holomorphy.com>2004-08-23 21:20:21 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-08-23 21:20:21 -0700
commitf9bbb9e847eeea390f08643443578ced950996ed (patch)
treeead3e1cc57de1282fbb0efb0d320e0f5eda322ef /include/linux/cpumask.h
parent1a87fc37ad3d21cd3e6c4e574aa34edbea534dad (diff)
[PATCH] first/next_cpu returns values > NR_CPUS
Zwane Mwaikambo <zwane@fsmlabs.com> wrote: The following caused some fireworks whilst merging i386 cpu hotplug. any_online_cpu(0x2) returns 32 on i386 if we're forced to continue past the only set bit due to the additional find_first_bit in the find_next_bit i386 implementation. Not wanting to change current behaviour in the bitops primitives and since the NR_CPUS thing is a cpumask issue, i've opted to fix next_cpu() and first_cpu() instead. This might save a couple of lines of code. From: <akpm@osdl.org> Fix cross-arch ulong/int disaster with find_next_bit(). Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/cpumask.h')
-rw-r--r--include/linux/cpumask.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 7109aa6e501e..1ff1e85f6e59 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -73,6 +73,7 @@
* inside a macro, the way we do the other calls.
*/
+#include <linux/kernel.h>
#include <linux/threads.h>
#include <linux/bitmap.h>
#include <asm/bug.h>
@@ -207,13 +208,13 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
#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, nbits, 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, nbits, find_next_bit(srcp->bits, nbits, n+1));
}
#define cpumask_of_cpu(cpu) \