]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cpu-set: compare two cpu sets with ha_cpuset_isequal()
authorWilly Tarreau <w@1wt.eu>
Mon, 31 Mar 2025 13:14:53 +0000 (15:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 31 Mar 2025 14:21:37 +0000 (16:21 +0200)
This function returns true if two CPU sets are equal.

include/haproxy/cpuset.h
src/cpuset.c

index 842f09f0d988302ec014a5ff7a6f8bcb8745888c..14c669c250a22380f6526ccefeb6d9d74ad42048 100644 (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);
index 6b5c6d9cafff02e1543c94e415576cea8fdd7b04..b102d11d105b7e482e2f24518f4d16bb8a676baa 100644 (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)