cpumask: reorder header to minimize separate #ifdefs

cpumask.h is pretty chaotic.  Now we've replaced most of it, let's
group things together a bit better.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 include/linux/cpumask.h |   74 ++++++++++++++++++++----------------------------
 1 file changed, 32 insertions(+), 42 deletions(-)

diff -r 59afc71e7a44 include/linux/cpumask.h
--- a/include/linux/cpumask.h	Mon Oct 06 08:41:03 2008 +1100
+++ b/include/linux/cpumask.h	Mon Oct 06 08:42:20 2008 +1100
@@ -178,13 +178,26 @@ extern cpumask_t _unused_cpumask_arg_;
 #define cpu_mask_all		(*(cpumask_t *)cpu_all_mask)
 /* End deprecated region. */
 
-#if NR_CPUS <= BITS_PER_LONG
+#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(CONFIG_NR_CPUS)
+
+#if CONFIG_NR_CPUS <= BITS_PER_LONG
 /* Constant is usually more efficient than a variable for small NR_CPUS */
 #define nr_cpu_ids NR_CPUS
+
+#define CPU_BITS_ALL						\
+{								\
+	[BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD	\
+}
 #else
-/* Starts at NR_CPUS until we know better. */
+/* Starts at CONFIG_NR_CPUS until we know better. */
 extern int nr_cpu_ids;
-#endif /* NR_CPUS > BITS_PER_LONG */
+
+#define CPU_BITS_ALL						\
+{								\
+	[0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-2] = ~0UL,		\
+	[BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD	\
+}
+#endif /* CONFIG_NR_CPUS > BITS_PER_LONG */
 
 #define cpumask_size() (BITS_TO_LONGS(nr_cpu_ids) * sizeof(long))
 
@@ -395,25 +408,6 @@ static inline const struct cpumask *cpum
 	return (const struct cpumask *)p;
 }
 
-#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
-
-#if NR_CPUS <= BITS_PER_LONG
-
-#define CPU_BITS_ALL						\
-{								\
-	[BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD	\
-}
-
-#else
-
-#define CPU_BITS_ALL						\
-{								\
-	[0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-2] = ~0UL,		\
-	[BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD	\
-}
-
-#endif
-
 #define CPU_BITS_NONE						\
 {								\
 	[0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = 0UL		\
@@ -425,7 +419,6 @@ static inline const struct cpumask *cpum
 }
 
 #if NR_CPUS == 1
-
 #define cpumask_first(src)	({ (void)(src); 0; })
 #define cpumask_next(n, src)	({ (void)(src); 1; })
 #define cpumask_first_both(src1, src2)	({ (void)(src1); (void)(src2); 0; })
@@ -436,6 +429,13 @@ static inline const struct cpumask *cpum
 #define for_each_cpu_both(cpu, mask1, mask2) \
 	for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask1, (void)mask2)
 
+#define num_online_cpus()	1
+#define num_possible_cpus()	1
+#define num_present_cpus()	1
+#define cpu_online(cpu)		((cpu) == 0)
+#define cpu_possible(cpu)	((cpu) == 0)
+#define cpu_present(cpu)	((cpu) == 0)
+#define cpu_active(cpu)		((cpu) == 0)
 #else /* NR_CPUS > 1 */
 
 int cpumask_first(const struct cpumask *srcp);
@@ -452,7 +452,15 @@ int cpumask_any_but(const struct cpumask
 	for ((cpu) = cpumask_first_both((mask1), (mask2));	\
 	     (cpu) < nr_cpu_ids;				\
 	     (cpu) = cpumask_next_both((cpu), (mask1), (mask2)))
-#endif
+
+#define num_online_cpus()	cpus_weight(cpu_online_map)
+#define num_possible_cpus()	cpus_weight(cpu_possible_map)
+#define num_present_cpus()	cpus_weight(cpu_present_map)
+#define cpu_online(cpu)		cpu_isset((cpu), cpu_online_map)
+#define cpu_possible(cpu)	cpu_isset((cpu), cpu_possible_map)
+#define cpu_present(cpu)	cpu_isset((cpu), cpu_present_map)
+#define cpu_active(cpu)		cpu_isset((cpu), cpu_active_map)
+#endif /* NR_CPUS */
 
 /*
  * cpumask_var_t: struct cpumask for stack usage.
@@ -552,24 +560,6 @@ extern const DECLARE_BITMAP(cpu_all_bits
 /* First bits of cpu_bit_bitmap are in fact unset. */
 #define cpu_none_mask to_cpumask(cpu_bit_bitmap[0])
 
-#if NR_CPUS > 1
-#define num_online_cpus()	cpus_weight(cpu_online_map)
-#define num_possible_cpus()	cpus_weight(cpu_possible_map)
-#define num_present_cpus()	cpus_weight(cpu_present_map)
-#define cpu_online(cpu)		cpu_isset((cpu), cpu_online_map)
-#define cpu_possible(cpu)	cpu_isset((cpu), cpu_possible_map)
-#define cpu_present(cpu)	cpu_isset((cpu), cpu_present_map)
-#define cpu_active(cpu)		cpu_isset((cpu), cpu_active_map)
-#else
-#define num_online_cpus()	1
-#define num_possible_cpus()	1
-#define num_present_cpus()	1
-#define cpu_online(cpu)		((cpu) == 0)
-#define cpu_possible(cpu)	((cpu) == 0)
-#define cpu_present(cpu)	((cpu) == 0)
-#define cpu_active(cpu)		((cpu) == 0)
-#endif
-
 /* Wrappers to manipulate otherwise-constant masks. */
 void set_cpu_possible(unsigned int cpu, bool possible);
 void set_cpu_present(unsigned int cpu, bool present);
