From: David Marchand <david.marchand@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 04/10] tailq: use a single cast macro
Date: Wed, 4 Mar 2015 22:50:04 +0100 [thread overview]
Message-ID: <1425505810-9269-5-git-send-email-david.marchand@6wind.com> (raw)
In-Reply-To: <1425505810-9269-1-git-send-email-david.marchand@6wind.com>
No need to cast everywhere, define a common macro for this, plus it can be used
in future commits.
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
lib/librte_eal/common/include/rte_tailq.h | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h
index b34e5ed..6ac4b9b 100644
--- a/lib/librte_eal/common/include/rte_tailq.h
+++ b/lib/librte_eal/common/include/rte_tailq.h
@@ -70,6 +70,12 @@ struct rte_tailq_head {
};
/**
+ * Return the first tailq entry casted to the right struct.
+ */
+#define RTE_TAILQ_CAST(tailq_entry, struct_name) \
+ (struct struct_name *)&(tailq_entry)->tailq_head
+
+/**
* Utility macro to make reserving a tailqueue for a particular struct easier.
*
* @param name
@@ -86,7 +92,7 @@ struct rte_tailq_head {
* element in the rte_tailq_head structure.
*/
#define RTE_TAILQ_RESERVE(name, struct_name) \
- (struct struct_name *)(&rte_eal_tailq_reserve(name)->tailq_head)
+ RTE_TAILQ_CAST(rte_eal_tailq_reserve(name), struct_name)
/**
* Utility macro to make reserving a tailqueue for a particular struct easier.
@@ -106,7 +112,7 @@ struct rte_tailq_head {
* element in the rte_tailq_head structure.
*/
#define RTE_TAILQ_RESERVE_BY_IDX(idx, struct_name) \
- (struct struct_name *)(&rte_eal_tailq_reserve_by_idx(idx)->tailq_head)
+ RTE_TAILQ_CAST(rte_eal_tailq_reserve_by_idx(idx), struct_name)
/**
* Utility macro to make looking up a tailqueue for a particular struct easier.
@@ -125,7 +131,7 @@ struct rte_tailq_head {
* element in the rte_tailq_head structure.
*/
#define RTE_TAILQ_LOOKUP(name, struct_name) \
- (struct struct_name *)(&rte_eal_tailq_lookup(name)->tailq_head)
+ RTE_TAILQ_CAST(rte_eal_tailq_lookup(name), struct_name)
/**
* Utility macro to make looking up a tailqueue for a particular struct easier.
@@ -144,7 +150,7 @@ struct rte_tailq_head {
* element in the rte_tailq_head structure.
*/
#define RTE_TAILQ_LOOKUP_BY_IDX(idx, struct_name) \
- (struct struct_name *)(&rte_eal_tailq_lookup_by_idx(idx)->tailq_head)
+ RTE_TAILQ_CAST(rte_eal_tailq_lookup_by_idx(idx), struct_name)
/**
* Reserve a slot in the tailq list for a particular tailq header
--
1.7.10.4
next prev parent reply other threads:[~2015-03-04 21:50 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 21:50 [dpdk-dev] [PATCH 00/10] eal: rte_tailq api cleanup David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 01/10] eal: remove yet another remaining reference to pm David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 02/10] pci: use lookup tailq api David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 03/10] tailq: remove unneeded inclusion of rte_tailq.h David Marchand
2015-03-04 21:50 ` David Marchand [this message]
2015-03-04 21:50 ` [dpdk-dev] [PATCH 05/10] tailq: get rid of broken "reserve" api David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 06/10] tailq: remove unused RTE_EAL_TAILQ_* macros David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 07/10] tailq: introduce dynamic register system David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 08/10] tailq: move to dynamic tailq David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 09/10] tailq: remove static slots David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 10/10] eal: no need for E_RTE_NO_TAILQ anymore David Marchand
2015-03-04 22:55 ` [dpdk-dev] [PATCH 00/10] eal: rte_tailq api cleanup Thomas Monjalon
2015-03-06 0:26 ` Neil Horman
2015-03-10 11:20 ` Thomas Monjalon
2015-03-11 7:44 ` Tetsuya Mukawa
2015-03-11 8:47 ` David Marchand
2015-03-11 17:28 ` David Marchand
2015-03-11 20:24 ` Mcnamara, John
2015-03-11 21:29 ` David Marchand
2015-03-11 22:25 ` Mcnamara, John
2015-03-12 2:05 ` Tetsuya Mukawa
2015-03-12 2:12 ` Tetsuya Mukawa
2015-03-12 5:44 ` David Marchand
2015-03-12 8:38 ` Liu, Yong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425505810-9269-5-git-send-email-david.marchand@6wind.com \
--to=david.marchand@6wind.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).