[PATCH 1/2] eal: add RTE_MIN4 and RTE_MAX4 macros
Stephen Hemminger
stephen at networkplumber.org
Thu Mar 12 01:20:26 CET 2026
These are analogous to the existing RTE_MIN3 macros and allow
drivers to take compute minimum of four values without invoking
the shadow warning gods.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
lib/eal/include/rte_common.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 573bf4f2ce..79364170d6 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -812,6 +812,16 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
(_b_min3 < _c_min3 ? _b_min3 : _c_min3); \
})
+/**
+ * Macro to return the minimum of four numbers
+ */
+#define RTE_MIN4(a, b, c, d) \
+ __extension__ ({ \
+ typeof (a) _min4_ab = RTE_MIN((a), (b)); \
+ typeof (c) _min4_cd = RTE_MIN((c), (d)); \
+ RTE_MIN(_min4_ab, _min4_cd); \
+ })
+
/**
* Macro to return the minimum of two numbers
*
@@ -845,6 +855,16 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
(_b_max3 > _c_max3 ? _b_max3 : _c_max3); \
})
+/**
+ * Macro to return the maximum of four numbers
+ */
+#define RTE_MAX4(a, b, c, d) \
+ __extension__ ({ \
+ typeof (a) _max4_ab = RTE_MAX((a), (b)); \
+ typeof (c) _max4_cd = RTE_MAX((c), (d)); \
+ RTE_MAX(_max4_ab, _max4_cd); \
+ })
+
/**
* Macro to return the maximum of two numbers
*
--
2.51.0
More information about the dev
mailing list