[dpdk-dev] [RFC PATCH 06/11] ring: use existing power-of-2 function

Bruce Richardson bruce.richardson at intel.com
Wed Jan 11 16:05:20 CET 2017


rather than having a special macro for checking for powers of two in
the ring code, use the existing inline function from rte_common.h

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 lib/librte_ring/rte_typed_ring.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/librte_ring/rte_typed_ring.h b/lib/librte_ring/rte_typed_ring.h
index 03a9bd7..3f7514f 100644
--- a/lib/librte_ring/rte_typed_ring.h
+++ b/lib/librte_ring/rte_typed_ring.h
@@ -1150,9 +1150,6 @@ TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 extern struct rte_tailq_elem rte_ring_tailq;
 
-/* true if x is a power of 2 */
-#define POWEROF2(x) ((((x)-1) & (x)) == 0)
-
 /**
  * Calculate the memory size needed for a ring
  *
@@ -1173,7 +1170,7 @@ TYPE(ring_get_memsize)(unsigned int count)
 	ssize_t sz;
 
 	/* count must be a power of 2 */
-	if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK)) {
+	if ((!rte_is_power_of_2(count)) || (count > RTE_RING_SZ_MASK)) {
 		RTE_LOG(ERR, RING,
 			"Requested size is invalid, must be power of 2, and "
 			"do not exceed the size limit %u\n", RTE_RING_SZ_MASK);
-- 
2.9.3



More information about the dev mailing list