diff options
author | Robbie King <robking@cisco.com> | 2015-01-14 23:48:24 +0100 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2015-01-16 17:33:09 +0300 |
commit | 7af97975609758b93db24bcdbf5342a310c60335 (patch) | |
tree | 739f7c42dc43456029c151e4176752e4ef706d5d | |
parent | f8263adac4d4610fe91f3125cd211d3726a303b1 (diff) |
api: cpumask: add odp_cpumask_next
Finding the next element to traverse a mask.
Signed-off-by: Robbie King <robking@cisco.com>
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r-- | platform/linux-generic/include/api/odp_cpumask.h | 21 | ||||
-rw-r--r-- | platform/linux-generic/odp_cpumask.c | 8 |
2 files changed, 29 insertions, 0 deletions
diff --git a/platform/linux-generic/include/api/odp_cpumask.h b/platform/linux-generic/include/api/odp_cpumask.h index a81bca760..ebff9b074 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 3930264e3..d9931b455 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; +} |