vserver 1.9.5.x5
[linux-2.6.git] / include / linux / cpumask.h
index 7109aa6..8ccf548 100644 (file)
@@ -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)                                            \
@@ -233,29 +234,29 @@ static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits)
 #if NR_CPUS <= BITS_PER_LONG
 
 #define CPU_MASK_ALL                                                   \
-((cpumask_t) { {                                                       \
+(cpumask_t) { {                                                                \
        [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD                 \
-} })
+} }
 
 #else
 
 #define CPU_MASK_ALL                                                   \
-((cpumask_t) { {                                                       \
+(cpumask_t) { {                                                                \
        [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL,                        \
        [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD                 \
-} })
+} }
 
 #endif
 
 #define CPU_MASK_NONE                                                  \
-((cpumask_t) { {                                                       \
+(cpumask_t) { {                                                                \
        [0 ... BITS_TO_LONGS(NR_CPUS)-1] =  0UL                         \
-} })
+} }
 
 #define CPU_MASK_CPU0                                                  \
-((cpumask_t) { {                                                       \
+(cpumask_t) { {                                                                \
        [0] =  1UL                                                      \
-} })
+} }
 
 #define cpus_addr(src) ((src).bits)