[v7,2/6] ring: add a ring start marker

Message ID 20190318213555.17345-3-gage.eads@intel.com (mailing list archive)
State Superseded, archived
Headers
Series Add lock-free ring and mempool handler |

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Eads, Gage March 18, 2019, 9:35 p.m. UTC
  This marker allows us to replace "&r[1]" with "&r->ring" to locate the
start of the ring.

Signed-off-by: Gage Eads <gage.eads@intel.com>
---
 lib/librte_ring/rte_ring.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index c78db6916..f16d77b8a 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -118,6 +118,7 @@  struct rte_ring {
 		struct rte_ring_headtail_ptr cons_ptr __rte_cache_aligned;
 	};
 	char pad2 __rte_cache_aligned; /**< empty cache line */
+	void *ring[] __rte_cache_aligned; /**< empty marker for ring start */
 };
 
 #define RING_F_SP_ENQ 0x0001 /**< The default enqueue is "single-producer". */
@@ -361,7 +362,7 @@  __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,
 	if (n == 0)
 		goto end;
 
-	ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);
+	ENQUEUE_PTRS(r, &r->ring, prod_head, obj_table, n, void *);
 
 	update_tail(&r->prod, prod_head, prod_next, is_sp, 1);
 end:
@@ -403,7 +404,7 @@  __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,
 	if (n == 0)
 		goto end;
 
-	DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, void *);
+	DEQUEUE_PTRS(r, &r->ring, cons_head, obj_table, n, void *);
 
 	update_tail(&r->cons, cons_head, cons_next, is_sc, 0);