From: Willy Tarreau Date: Mon, 31 Mar 2025 13:14:53 +0000 (+0200) Subject: MINOR: cpu-set: compare two cpu sets with ha_cpuset_isequal() X-Git-Tag: v3.2-dev9~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3955f151b1fab153de6b7a6310ec2f391ec2392e;p=thirdparty%2Fhaproxy.git MINOR: cpu-set: compare two cpu sets with ha_cpuset_isequal() This function returns true if two CPU sets are equal. --- diff --git a/include/haproxy/cpuset.h b/include/haproxy/cpuset.h index 842f09f0d..14c669c25 100644 --- a/include/haproxy/cpuset.h +++ b/include/haproxy/cpuset.h @@ -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); diff --git a/src/cpuset.c b/src/cpuset.c index 6b5c6d9ca..b102d11d1 100644 --- a/src/cpuset.c +++ b/src/cpuset.c @@ -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)