cpumask: reorder header to minimize separate #ifdefs

cpumask.h is pretty chaotic, let's group things together a bit better.

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

diff -r c55a6c025f16 include/linux/cpumask.h
--- a/include/linux/cpumask.h	Wed Oct 01 12:28:08 2008 +1000
+++ b/include/linux/cpumask.h	Wed Oct 01 12:28:18 2008 +1000
@@ -162,12 +162,25 @@ extern cpumask_t _unused_cpumask_arg_;
 #define	CPUMASK_PTR(v, m) 	cpumask_t *v = &(m->v)
 /* End deprecated region. */
 
+#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
+
 #if 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_MASK_ALL							\
+(cpumask_t) { {								\
+	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD			\
+} }
 #else
 /* Starts at NR_CPUS until we know better. */
 extern int nr_cpu_ids;
+
+#define CPU_MASK_ALL							\
+(cpumask_t) { {								\
+	[0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL,			\
+	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD			\
+} }
 #endif /* NR_CPUS > BITS_PER_LONG */
 
 static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
@@ -357,25 +370,6 @@ static inline const struct cpumask *cpum
 	return (const cpumask_t *)p;
 }
 
-#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
-
-#if NR_CPUS <= BITS_PER_LONG
-
-#define CPU_MASK_ALL							\
-(cpumask_t) { {								\
-	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD			\
-} }
-
-#else
-
-#define CPU_MASK_ALL							\
-(cpumask_t) { {								\
-	[0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL,			\
-	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD			\
-} }
-
-#endif
-
 extern const struct cpumask cpu_mask_all;
 
 #define CPU_MASK_NONE							\
@@ -389,7 +383,6 @@ extern const struct cpumask cpu_mask_all
 } }
 
 #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; })
@@ -399,6 +392,13 @@ extern const struct cpumask cpu_mask_all
 #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 cpumask_t *srcp);
@@ -414,7 +414,15 @@ int cpumask_next_both(int n, const cpuma
 	for ((cpu) = cpumask_first_both((mask1), (mask2));	\
 	     (cpu) < nr_cpu_ids;				\
 	     (cpu) = cpumask_next((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.
@@ -522,24 +530,6 @@ extern cpumask_t cpu_present_map;
 extern cpumask_t cpu_present_map;
 extern cpumask_t cpu_active_map;
 
-#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
-
 #define cpu_is_offline(cpu)	unlikely(!cpu_online(cpu))
 
 #define for_each_possible_cpu(cpu) for_each_cpu((cpu), &cpu_possible_map)
