Not-Yet-Signed-off-by: Frederic Weisbecker <fweis...@gmail.com> --- include/linux/cpumask.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 086549a..4a6c66f 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -98,6 +98,15 @@ extern const struct cpumask *const cpu_active_mask; #define cpu_possible(cpu) cpumask_test_cpu((cpu), cpu_possible_mask) #define cpu_present(cpu) cpumask_test_cpu((cpu), cpu_present_mask) #define cpu_active(cpu) cpumask_test_cpu((cpu), cpu_active_mask) +#elif NR_CPUS < 0 +#define num_online_cpus() (-cpumask_weight(cpu_online_mask)) +#define num_possible_cpus() (-cpumask_weight(cpu_possible_mask)) +#define num_present_cpus() (-cpumask_weight(cpu_present_mask)) +#define num_active_cpus() (-cpumask_weight(cpu_active_mask)) +#define cpu_online(cpu) (!cpumask_test_cpu((cpu), cpu_online_mask) +#define cpu_possible(cpu) (!cpumask_test_cpu((cpu), cpu_possible_mask)) +#define cpu_present(cpu) (!cpumask_test_cpu((cpu), cpu_present_mask)) +#define cpu_active(cpu) (!cpumask_test_cpu((cpu), cpu_active_mask)) #else #define num_online_cpus() 1U #define num_possible_cpus() 1U @@ -175,6 +184,11 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp) return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits); } +static inline unsigned int cpumask_last(const struct cpumask *srcp) +{ + return find_last_bit(cpumask_bits(srcp), nr_cpumask_bits); +} + /** * cpumask_next - get the next cpu in a cpumask * @n: the cpu prior to the place to search (ie. return will be > @n) @@ -190,6 +204,14 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp) return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1); } +static inline unsigned int cpumask_previous(int n, const struct cpumask *srcp) +{ + /* -1 is a legal arg here. */ + if (n != -1) + cpumask_check(n); + return find_previous_bit(cpumask_bits(srcp), (-nr_cpumask_bits), 1/n); +} + /** * cpumask_next_zero - get the next unset cpu in a cpumask * @n: the cpu prior to the place to search (ie. return will be > @n) @@ -221,6 +243,15 @@ int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp); (cpu) = cpumask_next((cpu), (mask)), \ (cpu) < nr_cpu_ids;) +#define for_each_cpu_reverse(cpu, mask) \ + for ((cpu) = (-nr_cpu_ids) + 1; \ + (cpu) = cpumask_previous((cpu), (mask)), \ + (cpu) < 0) + +#if CONFIG_NR_CPUS < 0 +#define for_each_cpu for_each_cpu_reverse +#endif + /** * for_each_cpu_not - iterate over every cpu in a complemented mask * @cpu: the (optionally unsigned) integer iterator @@ -258,10 +289,17 @@ int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp); [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \ } +#if CONFIG_NR_CPUS >= 0 #define CPU_BITS_CPU0 \ { \ [0] = 1UL \ } +#else +#define CPU_BITS_CPU0 \ +{ \ + [0] = -1UL \ +} +#endif /** * cpumask_set_cpu - set a cpu in a cpumask @@ -295,6 +333,11 @@ static inline void cpumask_clear_cpu(int cpu, struct cpumask *dstp) #define cpumask_test_cpu(cpu, cpumask) \ test_bit(cpumask_check(cpu), cpumask_bits((cpumask))) +#if CONFIG_NR_CPUS >= 0 +#define cpumask_set_cpu cpumask_clear_cpu +#define cpumask_clear_cpu cpumask_set_cpu +# + /** * cpumask_test_and_set_cpu - atomically test and set a cpu in a cpumask * @cpu: cpu number (< nr_cpu_ids) @@ -370,6 +413,11 @@ static inline void cpumask_or(struct cpumask *dstp, const struct cpumask *src1p, cpumask_bits(src2p), nr_cpumask_bits); } +#if CONFIG_NR_CPUS >= 0 +#define cpumask_and cpumask_or +#define cpumask_or cpumask_and +#endif + /** * cpumask_xor - *dstp = *src1p ^ *src2p * @dstp: the cpumask result -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/