MINOR: cpu-set: compare two cpu sets with ha_cpuset_isequal()

This function returns true if two CPU sets are equal.
This commit is contained in:
Willy Tarreau 2025-03-31 15:14:53 +02:00
parent e17512c3b2
commit 3955f151b1
2 changed files with 17 additions and 0 deletions

View File

@ -44,6 +44,9 @@ int ha_cpuset_ffs(const struct hap_cpuset *set);
*/
void ha_cpuset_assign(struct hap_cpuset *dst, struct hap_cpuset *src);
/* returns true if the sets are equal */
int ha_cpuset_isequal(const struct hap_cpuset *dst, const struct hap_cpuset *src);
/* Returns the biggest index plus one usable on the platform.
*/
int ha_cpuset_size(void);

View File

@ -134,6 +134,20 @@ void ha_cpuset_assign(struct hap_cpuset *dst, struct hap_cpuset *src)
#endif
}
/* returns true if the sets are equal */
int ha_cpuset_isequal(const struct hap_cpuset *dst, const struct hap_cpuset *src)
{
#if defined(CPUSET_USE_CPUSET)
return CPU_EQUAL(&dst->cpuset, &src->cpuset);
#elif defined(CPUSET_USE_FREEBSD_CPUSET)
return !CPU_CMP(&src->cpuset, &dst->cpuset);
#elif defined(CPUSET_USE_ULONG)
return dst->cpuset == src->cpuset;
#endif
}
int ha_cpuset_size()
{
#if defined(CPUSET_USE_CPUSET) || defined(CPUSET_USE_FREEBSD_CPUSET)