From: Robbie King <[email protected]>

Finding the next element to traverse a mask.

Signed-off-by: Robbie King <[email protected]>
Signed-off-by: Anders Roxell <[email protected]>
---
 platform/linux-generic/include/api/odp_cpumask.h | 21 +++++++++++++++++++++
 platform/linux-generic/odp_cpumask.c             |  8 ++++++++
 2 files changed, 29 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_cpumask.h 
b/platform/linux-generic/include/api/odp_cpumask.h
index a81bca7..ebff9b0 100644
--- a/platform/linux-generic/include/api/odp_cpumask.h
+++ b/platform/linux-generic/include/api/odp_cpumask.h
@@ -146,6 +146,27 @@ int odp_cpumask_first(const odp_cpumask_t *mask);
 int odp_cpumask_last(const odp_cpumask_t *mask);
 
 /**
+ * Find next cpu in mask
+ *
+ * Finds the next cpu in the CPU mask, starting at the cpu passed.
+ * Use with odp_cpumask_first to traverse a CPU mask, i.e.
+ *
+ * int cpu = odp_cpumask_first(&mask);
+ * while (0 <= cpu) {
+ *     ...
+ *     ...
+ *     cpu = odp_cpumask_next(&mask, cpu);
+ * }
+ *
+ * @param mask        CPU mask to find next cpu in
+ * @param cpu         CPU to start from
+ * @return cpu found else -1
+ *
+ * @see odp_cpumask_first()
+ */
+int odp_cpumask_next(const odp_cpumask_t *mask, int cpu);
+
+/**
  * @}
  */
 
diff --git a/platform/linux-generic/odp_cpumask.c 
b/platform/linux-generic/odp_cpumask.c
index 3930264..d9931b4 100644
--- a/platform/linux-generic/odp_cpumask.c
+++ b/platform/linux-generic/odp_cpumask.c
@@ -185,3 +185,11 @@ int odp_cpumask_last(const odp_cpumask_t *mask)
                        return cpu;
        return -1;
 }
+
+int odp_cpumask_next(const odp_cpumask_t *mask, int cpu)
+{
+       for (cpu += 1; cpu < CPU_SETSIZE; cpu++)
+               if (odp_cpumask_isset(mask, cpu))
+                       return cpu;
+       return -1;
+}
-- 
2.1.4


_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to