[PATCH v2 01/14] eal: introduce division round up macro
Joshua Washington
joshwash at google.com
Thu Aug 13 19:22:26 CEST 2026
A number of drivers define the DIV_ROUND_UP macro -- add it to
rte_common.h so that other code looking to use that functionality
doesn't have to re-define it.
Signed-off-by: Joshua Washington <joshwash at google.com>
---
Changes in v2:
- Split out patches replacing usages
---
lib/eal/include/rte_common.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 79d2a0ab93..168b0fe592 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -717,6 +717,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
(ceil - (v)) > ((v) - floor) ? floor : ceil; \
})
+/**
+ * Macro to divide dividend n by divisor d, rounding up if d does not divide n.
+ */
+#define RTE_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+
/**
* Checks if a pointer is aligned to a given power-of-two value
*
--
2.55.0.691.gc56d675ccc-goog
More information about the dev
mailing list