]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core: Introduce first_cpu
authorJan Kiszka <jan.kiszka@siemens.com>
Sun, 26 Jun 2016 09:38:24 +0000 (11:38 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Mon, 27 Jun 2016 09:51:18 +0000 (11:51 +0200)
Extracted from patch of Antonios Motakis: Avoid the barely readable
"for_each_cpu(...) break;" pattern.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/include/jailhouse/control.h

index b83553f64415351f3a248d5eb698126e75d90077..c7da909dcfb3570b56604ecc5d9f1ef9f50bdf54 100644 (file)
@@ -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