Skip to content

Commit

Permalink
core: Introduce first_cpu
Browse files Browse the repository at this point in the history
Extracted from patch of Antonios Motakis: Avoid the barely readable
"for_each_cpu(...) break;" pattern.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
jan-kiszka committed Jun 27, 2016
1 parent 902ee9c commit ddc4a66
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hypervisor/include/jailhouse/control.h
Expand Up @@ -33,6 +33,14 @@ extern struct jailhouse_system *system_config;
unsigned int next_cpu(unsigned int cpu, struct cpu_set *cpu_set,
int exception);

/**
* Get the first CPU in a given set.
* @param set CPU set.
*
* @return First CPU in set, or max_cpu_id + 1 if the set is empty.
*/
#define first_cpu(set) next_cpu(-1, (set), -1)

/**
* Loop-generating macro for iterating over all CPUs in a set.
* @param cpu Iteration variable holding the current CPU ID
Expand Down

0 comments on commit ddc4a66

Please sign in to comment.