From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) by dpdk.org (Postfix) with ESMTP id 7772D6849 for ; Wed, 4 Mar 2015 22:50:22 +0100 (CET) Received: by wevm14 with SMTP id m14so49131629wev.13 for ; Wed, 04 Mar 2015 13:50:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=vYO5XWULOFvEC66KQDYZyGlJ6z/NLkkmffLr28lp0rY=; b=R43avza6iC/zw0HRuJNRyuMgqLEtSaSAc6NRNO9r6xrmk/LTlij4tTd1pVMveZKuar b3dCiLps5lAGHam4wMFHKyESURDPOHRGYrTjXCgO2OlpMIasCN2EMyMHsM7QivQQ2Kzk K0PRWkQ2KZrLxy4SA6wk7cIfzXJgtLP7/Aeb1myuZsyYXK8/ujr2TtBGHVOvDLIEDOsP aakzpkK5PbzFyyp862awQNNJ+dw7E+2HXY8+hjK/lQQy379anhok7YCXXz1a8ld+UVos EbXiIQ3Kkt89e+FmCx8ivVztW9Ken8IiN3Is3jsA39USL/ESImJj0QWX5JMhQS34EtVS 2XGA== X-Gm-Message-State: ALoCoQnjjDrL+r1X7nZ4AshgvyfbYqbMPROd82SoqxEGtPVIrWBoqbaejEL13IVveQVJmgOxguB+ X-Received: by 10.180.83.195 with SMTP id s3mr60952631wiy.54.1425505822344; Wed, 04 Mar 2015 13:50:22 -0800 (PST) Received: from alcyon.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id bf8sm6037947wjb.37.2015.03.04.13.50.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Mar 2015 13:50:21 -0800 (PST) From: David Marchand To: dev@dpdk.org Date: Wed, 4 Mar 2015 22:50:04 +0100 Message-Id: <1425505810-9269-5-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1425505810-9269-1-git-send-email-david.marchand@6wind.com> References: <1425505810-9269-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH 04/10] tailq: use a single cast macro X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2015 21:50:22 -0000 No need to cast everywhere, define a common macro for this, plus it can be used in future commits. Signed-off-by: David Marchand --- 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