This function will be convenient to test for the presence of a given CPU
in a set.
*/
void ha_cpuset_and(struct hap_cpuset *dst, struct hap_cpuset *src);
+/* returns non-zero if CPU index <cpu> is set in <set>, otherwise 0. */
+int ha_cpuset_isset(const struct hap_cpuset *set, int cpu);
+
/* Returns the count of set index in <set>.
*/
int ha_cpuset_count(const struct hap_cpuset *set);
#endif
}
+int ha_cpuset_isset(const struct hap_cpuset *set, int cpu)
+{
+ if (cpu >= ha_cpuset_size())
+ return 0;
+
+#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)
+ return CPU_ISSET(cpu, &set->cpuset);
+
+#elif defined(CPUSET_USE_ULONG)
+ return !!(set->cpuset & (0x1 << cpu));
+#else
+ return 0;
+#endif
+}
+
int ha_cpuset_count(const struct hap_cpuset *set)
{
#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)