From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Feb 2017 08:42:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,198,1484035200"; d="scan'208";a="68264718" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by orsmga005.jf.intel.com with ESMTP; 23 Feb 2017 08:42:43 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Date: Thu, 23 Feb 2017 16:42:00 +0000 Message-Id: <1487868123-30262-3-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1487695964-15593-1-git-send-email-bruce.richardson@intel.com> References: <1487695964-15593-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH v2 2/5] ring: add a function to return the ring size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2017 16:42:57 -0000 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