[PATCH 06/31] cpumask: new lib/cpumask.c

Previous thread: [PATCH 05/31] cpumask: Provide new cpumask API by Mike Travis on Monday, September 29, 2008 - 11:02 am. (5 messages)

Next thread: [PATCH 03/31] cpumask: remove min from first_cpu/next_cpu by Mike Travis on Monday, September 29, 2008 - 11:02 am. (1 message)
From: Mike Travis
Date: Monday, September 29, 2008 - 11:02 am

Signed-of-by: Mike Travis <travis@sgi.com>
---
 lib/cpumask.c |   36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

--- struct-cpumasks.orig/lib/cpumask.c
+++ struct-cpumasks/lib/cpumask.c
@@ -3,34 +3,40 @@
 #include <linux/cpumask.h>
 #include <linux/module.h>
 
-int __first_cpu(const cpumask_t *srcp)
+int cpus_first(const_cpumask_t srcp)
 {
-	return find_first_bit(srcp->bits, NR_CPUS);
+	return find_first_bit(srcp->bits, nr_cpu_ids);
 }
-EXPORT_SYMBOL(__first_cpu);
+EXPORT_SYMBOL(cpus_first);
 
-int __next_cpu(int n, const cpumask_t *srcp)
+int cpus_next(int n, const_cpumask_t srcp)
 {
-	return find_next_bit(srcp->bits, NR_CPUS, n+1);
+	return find_next_bit(srcp->bits, nr_cpu_ids, n+1);
 }
-EXPORT_SYMBOL(__next_cpu);
+EXPORT_SYMBOL(cpus_next);
 
-#if NR_CPUS > 64
-int __next_cpu_nr(int n, const cpumask_t *srcp)
+int cpus_next_in(int n, const_cpumask_t srcp, const_cpumask_t andp)
 {
-	return find_next_bit(srcp->bits, nr_cpu_ids, n+1);
+	int cpu;
+
+	for (cpu = n + 1; cpu < nr_cpu_ids; cpu++) {
+		cpu = find_next_bit(srcp->bits, nr_cpu_ids, cpu);
+
+		if (cpu < nr_cpu_ids && cpu_isset(cpu, andp))
+			return cpu;
+	}
+	return nr_cpu_ids;
 }
-EXPORT_SYMBOL(__next_cpu_nr);
-#endif
+EXPORT_SYMBOL(cpus_next_in);
 
-int __any_online_cpu(const cpumask_t *mask)
+int any_cpu_in(const_cpumask_t mask, const_cpumask_t andmask)
 {
 	int cpu;
 
-	for_each_cpu_mask(cpu, *mask) {
-		if (cpu_online(cpu))
+	for_each_cpu(cpu, mask) {
+		if (cpu_isset(cpu, andmask))
 			break;
 	}
 	return cpu;
 }
-EXPORT_SYMBOL(__any_online_cpu);
+EXPORT_SYMBOL(any_cpu_in);

-- 
--

Previous thread: [PATCH 05/31] cpumask: Provide new cpumask API by Mike Travis on Monday, September 29, 2008 - 11:02 am. (5 messages)

Next thread: [PATCH 03/31] cpumask: remove min from first_cpu/next_cpu by Mike Travis on Monday, September 29, 2008 - 11:02 am. (1 message)