From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: [PATCH v2 2/5] ring: add a function to return the ring size Date: Thu, 23 Feb 2017 16:42:00 +0000 Message-ID: <1487868123-30262-3-git-send-email-bruce.richardson@intel.com> References: <1487695964-15593-1-git-send-email-bruce.richardson@intel.com> Cc: Bruce Richardson To: dev@dpdk.org Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 4BAF15911 for ; Thu, 23 Feb 2017 17:42:56 +0100 (CET) In-Reply-To: <1487695964-15593-1-git-send-email-bruce.richardson@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Applications and other libraries should not be reading inside the rte_ring structure directly to get the ring size. Instead add a fn to allow it to be queried. Signed-off-by: Bruce Richardson --- lib/librte_ring/rte_ring.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h index e359aff..72ccca5 100644 --- a/lib/librte_ring/rte_ring.h +++ b/lib/librte_ring/rte_ring.h @@ -1108,6 +1108,20 @@ rte_ring_free_count(const struct rte_ring *r) } /** + * Return the size of the ring. + * + * @param r + * A pointer to the ring structure. + * @return + * The number of elements which can be stored in the ring. + */ +static inline unsigned int +rte_ring_get_size(const struct rte_ring *r) +{ + return r->prod.size; +} + +/** * Dump the status of all rings on the console * * @param f -- 2.9.3